89 lines
2.1 KiB
Dart
89 lines
2.1 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
part of 'main.dart';
|
|
|
|
// **************************************************************************
|
|
// JsonModelGenerator
|
|
// **************************************************************************
|
|
|
|
@generatedSerializable
|
|
class Todo extends _Todo {
|
|
Todo({this.text, this.completed});
|
|
|
|
@override
|
|
final String text;
|
|
|
|
@override
|
|
final bool completed;
|
|
|
|
Todo copyWith({String text, bool completed}) {
|
|
return new Todo(
|
|
text: text ?? this.text, completed: completed ?? this.completed);
|
|
}
|
|
|
|
bool operator ==(other) {
|
|
return other is _Todo && other.text == text && other.completed == completed;
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
return hashObjects([text, completed]);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return "Todo(text=$text, completed=$completed)";
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return TodoSerializer.toMap(this);
|
|
}
|
|
}
|
|
|
|
// **************************************************************************
|
|
// SerializerGenerator
|
|
// **************************************************************************
|
|
|
|
const TodoSerializer todoSerializer = const TodoSerializer();
|
|
|
|
class TodoEncoder extends Converter<Todo, Map> {
|
|
const TodoEncoder();
|
|
|
|
@override
|
|
Map convert(Todo model) => TodoSerializer.toMap(model);
|
|
}
|
|
|
|
class TodoDecoder extends Converter<Map, Todo> {
|
|
const TodoDecoder();
|
|
|
|
@override
|
|
Todo convert(Map map) => TodoSerializer.fromMap(map);
|
|
}
|
|
|
|
class TodoSerializer extends Codec<Todo, Map> {
|
|
const TodoSerializer();
|
|
|
|
@override
|
|
get encoder => const TodoEncoder();
|
|
@override
|
|
get decoder => const TodoDecoder();
|
|
static Todo fromMap(Map map) {
|
|
return new Todo(
|
|
text: map['text'] as String, completed: map['completed'] as bool);
|
|
}
|
|
|
|
static Map<String, dynamic> toMap(_Todo model) {
|
|
if (model == null) {
|
|
return null;
|
|
}
|
|
return {'text': model.text, 'completed': model.completed};
|
|
}
|
|
}
|
|
|
|
abstract class TodoFields {
|
|
static const List<String> allFields = <String>[text, completed];
|
|
|
|
static const String text = 'text';
|
|
|
|
static const String completed = 'completed';
|
|
}
|