Formatting + README
This commit is contained in:
parent
e6f82341d1
commit
02bc431334
14 changed files with 70 additions and 13 deletions
|
@ -82,6 +82,11 @@ The following files will be generated:
|
|||
* `book.g.dart`
|
||||
* `book.serializer.g.dart`
|
||||
|
||||
Producing these classes:
|
||||
* `Book`: Extends or implements `_Book`; may be `const`-enabled.
|
||||
* `BookSerializer`: static functionality for serializing `Book` models.
|
||||
* `BookFields`: The names of all fields from the `Book` model, statically-available.
|
||||
|
||||
# Serialization
|
||||
|
||||
You can use the generated files as follows:
|
||||
|
|
|
@ -4,4 +4,4 @@ import 'package:angel_serialize/angel_serialize.dart';
|
|||
class _Todo {
|
||||
String text;
|
||||
bool completed;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,8 @@ class GeneratedSerializable {
|
|||
const GeneratedSerializable();
|
||||
}
|
||||
|
||||
const GeneratedSerializable generatedSerializable = const GeneratedSerializable();
|
||||
const GeneratedSerializable generatedSerializable =
|
||||
const GeneratedSerializable();
|
||||
|
||||
/// The supported serialization types.
|
||||
abstract class Serializers {
|
||||
|
|
|
@ -4,4 +4,4 @@ import 'package:angel_serialize/angel_serialize.dart';
|
|||
class _Todo {
|
||||
String text;
|
||||
bool completed;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,18 @@ abstract class AuthorSerializer {
|
|||
}
|
||||
|
||||
abstract class AuthorFields {
|
||||
static const List<String> allFields = const <String>[
|
||||
id,
|
||||
name,
|
||||
age,
|
||||
books,
|
||||
newestBook,
|
||||
secret,
|
||||
obscured,
|
||||
createdAt,
|
||||
updatedAt
|
||||
];
|
||||
|
||||
static const String id = 'id';
|
||||
|
||||
static const String name = 'name';
|
||||
|
@ -125,6 +137,13 @@ abstract class LibrarySerializer {
|
|||
}
|
||||
|
||||
abstract class LibraryFields {
|
||||
static const List<String> allFields = const <String>[
|
||||
id,
|
||||
collection,
|
||||
createdAt,
|
||||
updatedAt
|
||||
];
|
||||
|
||||
static const String id = 'id';
|
||||
|
||||
static const String collection = 'collection';
|
||||
|
@ -177,6 +196,15 @@ abstract class BookmarkSerializer {
|
|||
}
|
||||
|
||||
abstract class BookmarkFields {
|
||||
static const List<String> allFields = const <String>[
|
||||
id,
|
||||
history,
|
||||
page,
|
||||
comment,
|
||||
createdAt,
|
||||
updatedAt
|
||||
];
|
||||
|
||||
static const String id = 'id';
|
||||
|
||||
static const String history = 'history';
|
||||
|
|
|
@ -14,4 +14,4 @@ abstract class _Book extends Model {
|
|||
|
||||
@Alias('camelCase')
|
||||
String camelCaseString;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,18 @@ abstract class BookSerializer {
|
|||
}
|
||||
|
||||
abstract class BookFields {
|
||||
static const List<String> allFields = const <String>[
|
||||
id,
|
||||
author,
|
||||
title,
|
||||
description,
|
||||
pageCount,
|
||||
notModels,
|
||||
camelCaseString,
|
||||
createdAt,
|
||||
updatedAt
|
||||
];
|
||||
|
||||
static const String id = 'id';
|
||||
|
||||
static const String author = 'author';
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
import 'package:angel_serialize/angel_serialize.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'game_pad_button.dart';
|
||||
|
||||
part 'game_pad.g.dart';
|
||||
|
||||
part 'game_pad.serializer.g.dart';
|
||||
|
||||
@Serializable(autoIdAndDateFields: false)
|
||||
abstract class _Gamepad {
|
||||
List<GamepadButton> get buttons;
|
||||
class _Gamepad {
|
||||
List<GamepadButton> buttons;
|
||||
|
||||
Map<String, dynamic> get dynamicMap;
|
||||
}
|
||||
Map<String, dynamic> dynamicMap;
|
||||
|
||||
String _somethingPrivate;
|
||||
}
|
||||
|
|
|
@ -7,9 +7,10 @@ part of 'game_pad.dart';
|
|||
// **************************************************************************
|
||||
|
||||
@generatedSerializable
|
||||
class Gamepad implements _Gamepad {
|
||||
const Gamepad(
|
||||
{List<GamepadButton> this.buttons, Map<String, dynamic> this.dynamicMap});
|
||||
class Gamepad extends _Gamepad {
|
||||
Gamepad({List<GamepadButton> buttons, Map<String, dynamic> dynamicMap})
|
||||
: this.buttons = new List.unmodifiable(buttons ?? []),
|
||||
this.dynamicMap = new Map.unmodifiable(dynamicMap ?? {});
|
||||
|
||||
@override
|
||||
final List<GamepadButton> buttons;
|
||||
|
|
|
@ -29,6 +29,8 @@ abstract class GamepadSerializer {
|
|||
}
|
||||
|
||||
abstract class GamepadFields {
|
||||
static const List<String> allFields = const <String>[buttons, dynamicMap];
|
||||
|
||||
static const String buttons = 'buttons';
|
||||
|
||||
static const String dynamicMap = 'dynamic_map';
|
||||
|
|
|
@ -6,4 +6,4 @@ part 'game_pad_button.serializer.g.dart';
|
|||
abstract class _GamepadButton {
|
||||
String get name;
|
||||
int get radius;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ abstract class GamepadButtonSerializer {
|
|||
}
|
||||
|
||||
abstract class GamepadButtonFields {
|
||||
static const List<String> allFields = const <String>[name, radius];
|
||||
|
||||
static const String name = 'name';
|
||||
|
||||
static const String radius = 'radius';
|
||||
|
|
|
@ -30,6 +30,8 @@ abstract class WithEnumSerializer {
|
|||
}
|
||||
|
||||
abstract class WithEnumFields {
|
||||
static const List<String> allFields = const <String>[type, finalList];
|
||||
|
||||
static const String type = 'type';
|
||||
|
||||
static const String finalList = 'final_list';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import 'package:build_runner/build_runner.dart';
|
||||
import 'applications.dart';
|
||||
|
||||
main() => build(applications, deleteFilesByDefault: true, verbose: false);
|
||||
main() => build(applications, deleteFilesByDefault: true, verbose: false);
|
||||
|
|
Loading…
Reference in a new issue