Initial commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
class Dinosaur {
|
||||
final String name, pronunciation, meaning, family, dietType, classification, locomotion, period, region, description, imagePath;
|
||||
final int periodIndex; // 0: Triassic, 1: Jurassic, 2: Cretaceous
|
||||
final double weightKg;
|
||||
final double lengthMeters;
|
||||
|
||||
const Dinosaur({
|
||||
required this.name, required this.pronunciation, required this.meaning, required this.family,
|
||||
required this.dietType, required this.classification, required this.locomotion,
|
||||
required this.period, required this.periodIndex, required this.weightKg,
|
||||
required this.lengthMeters, required this.region, required this.description, required this.imagePath,
|
||||
});
|
||||
|
||||
factory Dinosaur.fromJson(Map<String, dynamic> json) {
|
||||
return Dinosaur(
|
||||
name: json['name'] ?? '',
|
||||
pronunciation: json['pronunciation'] ?? '',
|
||||
meaning: json['meaning'] ?? '',
|
||||
family: json['family'] ?? 'Unknown',
|
||||
dietType: json['dietType'] ?? '',
|
||||
classification: json['classification'] ?? '',
|
||||
locomotion: json['locomotion'] ?? '',
|
||||
period: json['period'] ?? '',
|
||||
periodIndex: json['periodIndex'] ?? 0,
|
||||
weightKg: (json['weightKg'] as num).toDouble(),
|
||||
lengthMeters: (json['lengthMeters'] as num).toDouble(),
|
||||
region: json['region'] ?? '',
|
||||
description: json['description'] ?? '',
|
||||
imagePath: json['imagePath'] ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user