35 lines
739 B
Dart
35 lines
739 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"],
|
||
|
);
|
||
|
|
||
|
Map<String, dynamic> toJson() => {
|
||
|
"id": id,
|
||
|
"name": name,
|
||
|
"code": code,
|
||
|
};
|
||
|
}
|