2019-04-08 04:41:58 +00:00
|
|
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
|
|
|
|
part of 'main.dart';
|
|
|
|
|
|
|
|
// **************************************************************************
|
|
|
|
// JsonModelGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
|
|
|
@generatedSerializable
|
|
|
|
class Todo extends _Todo {
|
|
|
|
Todo({this.text, this.completed});
|
|
|
|
|
|
|
|
@override
|
2021-05-02 06:02:08 +00:00
|
|
|
String? text;
|
2019-04-08 04:41:58 +00:00
|
|
|
|
|
|
|
@override
|
2021-05-02 06:02:08 +00:00
|
|
|
bool? completed;
|
2019-04-08 04:41:58 +00:00
|
|
|
|
2021-05-02 06:02:08 +00:00
|
|
|
Todo copyWith({String? text, bool? completed}) {
|
2019-04-30 15:44:01 +00:00
|
|
|
return Todo(
|
2019-04-08 04:41:58 +00:00
|
|
|
text: text ?? this.text, completed: completed ?? this.completed);
|
|
|
|
}
|
|
|
|
|
2021-05-15 14:37:52 +00:00
|
|
|
@override
|
2019-04-08 04:41:58 +00:00
|
|
|
bool operator ==(other) {
|
|
|
|
return other is _Todo && other.text == text && other.completed == completed;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get hashCode {
|
|
|
|
return hashObjects([text, completed]);
|
|
|
|
}
|
|
|
|
|
2019-04-08 15:00:04 +00:00
|
|
|
@override
|
|
|
|
String toString() {
|
2021-05-15 14:37:52 +00:00
|
|
|
return 'Todo(text=$text, completed=$completed)';
|
2019-04-08 15:00:04 +00:00
|
|
|
}
|
|
|
|
|
2019-04-08 04:41:58 +00:00
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
return TodoSerializer.toMap(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// **************************************************************************
|
|
|
|
// SerializerGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
2019-04-30 15:44:01 +00:00
|
|
|
const TodoSerializer todoSerializer = TodoSerializer();
|
2019-04-08 15:00:04 +00:00
|
|
|
|
|
|
|
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
|
2021-05-15 14:37:52 +00:00
|
|
|
TodoEncoder get encoder => const TodoEncoder();
|
2019-04-08 15:00:04 +00:00
|
|
|
@override
|
2021-05-15 14:37:52 +00:00
|
|
|
TodoDecoder get decoder => const TodoDecoder();
|
2019-04-08 04:41:58 +00:00
|
|
|
static Todo fromMap(Map map) {
|
2019-04-30 15:44:01 +00:00
|
|
|
return Todo(
|
2021-05-02 06:02:08 +00:00
|
|
|
text: map['text'] as String?, completed: map['completed'] as bool?);
|
2019-04-08 04:41:58 +00:00
|
|
|
}
|
|
|
|
|
2022-02-27 04:16:31 +00:00
|
|
|
static Map<String, dynamic> toMap(_Todo? model) {
|
|
|
|
if (model == null) {
|
|
|
|
throw FormatException("Required field [model] cannot be null");
|
|
|
|
}
|
2019-04-08 04:41:58 +00:00
|
|
|
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';
|
|
|
|
}
|