flutter_jsonable

Last updated:

0 purchases

flutter_jsonable Image
flutter_jsonable Images
Add to Cart

Description:

flutter jsonable

A flutter package support jsonable class.
Features #
Getting started #
Usage #
/// a struct description a people
///
class People {
People({
required this.name,
this.age = 10,
required this.sex,
this.children = const <People>[],
this.parents = const <String, People>{},
});

factory People.fromJson(final Map<String, dynamic> json) => People(
name: getValueFromJsonOrNull<String>(json, 'name'),
age: getValueFromJsonOrDefault<int>(json, 'age', 10),
sex: getValueFromJsonOrNull<String>(json, 'sex'),
children: getListFromJson<People>(json, 'children'),
parents: getMapFromJson<People>(json, 'parents'),
);

final String? name;

final int age;

final String? sex;

final List<People> children;

final Map<String, People> parents;

Map<String, dynamic> toJson() => <String, dynamic>{
'name': name,
'age': age,
'sex': sex,
'children': getJsonFromList(children),
'parents': getJsonFromMap(parents),
};
}

copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.