35 lines
753 B
Dart
35 lines
753 B
Dart
// To parse this JSON data, do
|
|
//
|
|
// final country = countryFromJson(jsonString);
|
|
|
|
import 'package:meta/meta.dart';
|
|
import 'dart:convert';
|
|
|
|
Country countryFromJson(String str) => Country.fromJson(json.decode(str));
|
|
|
|
String countryToJson(Country data) => json.encode(data.toJson());
|
|
|
|
class Country {
|
|
Country({
|
|
required this.id,
|
|
required this.name,
|
|
required this.code,
|
|
});
|
|
|
|
final int? id;
|
|
final String? name;
|
|
final String? code;
|
|
|
|
factory Country.fromJson(Map<String, dynamic> json) => Country(
|
|
id: json["id"],
|
|
name: json["name"],
|
|
code: json["code"].toString(),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"name": name,
|
|
"code": code,
|
|
};
|
|
}
|