Formatting + README

This commit is contained in:
Tobe O 2018-07-11 11:49:46 -04:00
parent e6f82341d1
commit 02bc431334
14 changed files with 70 additions and 13 deletions

View file

@ -82,6 +82,11 @@ The following files will be generated:
* `book.g.dart` * `book.g.dart`
* `book.serializer.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 # Serialization
You can use the generated files as follows: You can use the generated files as follows:

View file

@ -42,7 +42,8 @@ class GeneratedSerializable {
const GeneratedSerializable(); const GeneratedSerializable();
} }
const GeneratedSerializable generatedSerializable = const GeneratedSerializable(); const GeneratedSerializable generatedSerializable =
const GeneratedSerializable();
/// The supported serialization types. /// The supported serialization types.
abstract class Serializers { abstract class Serializers {

View file

@ -66,6 +66,18 @@ abstract class AuthorSerializer {
} }
abstract class AuthorFields { 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 id = 'id';
static const String name = 'name'; static const String name = 'name';
@ -125,6 +137,13 @@ abstract class LibrarySerializer {
} }
abstract class LibraryFields { abstract class LibraryFields {
static const List<String> allFields = const <String>[
id,
collection,
createdAt,
updatedAt
];
static const String id = 'id'; static const String id = 'id';
static const String collection = 'collection'; static const String collection = 'collection';
@ -177,6 +196,15 @@ abstract class BookmarkSerializer {
} }
abstract class BookmarkFields { abstract class BookmarkFields {
static const List<String> allFields = const <String>[
id,
history,
page,
comment,
createdAt,
updatedAt
];
static const String id = 'id'; static const String id = 'id';
static const String history = 'history'; static const String history = 'history';

View file

@ -47,6 +47,18 @@ abstract class BookSerializer {
} }
abstract class BookFields { 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 id = 'id';
static const String author = 'author'; static const String author = 'author';

View file

@ -1,12 +1,16 @@
import 'package:angel_serialize/angel_serialize.dart'; import 'package:angel_serialize/angel_serialize.dart';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'game_pad_button.dart'; import 'game_pad_button.dart';
part 'game_pad.g.dart'; part 'game_pad.g.dart';
part 'game_pad.serializer.g.dart'; part 'game_pad.serializer.g.dart';
@Serializable(autoIdAndDateFields: false) @Serializable(autoIdAndDateFields: false)
abstract class _Gamepad { class _Gamepad {
List<GamepadButton> get buttons; List<GamepadButton> buttons;
Map<String, dynamic> get dynamicMap; Map<String, dynamic> dynamicMap;
String _somethingPrivate;
} }

View file

@ -7,9 +7,10 @@ part of 'game_pad.dart';
// ************************************************************************** // **************************************************************************
@generatedSerializable @generatedSerializable
class Gamepad implements _Gamepad { class Gamepad extends _Gamepad {
const Gamepad( Gamepad({List<GamepadButton> buttons, Map<String, dynamic> dynamicMap})
{List<GamepadButton> this.buttons, Map<String, dynamic> this.dynamicMap}); : this.buttons = new List.unmodifiable(buttons ?? []),
this.dynamicMap = new Map.unmodifiable(dynamicMap ?? {});
@override @override
final List<GamepadButton> buttons; final List<GamepadButton> buttons;

View file

@ -29,6 +29,8 @@ abstract class GamepadSerializer {
} }
abstract class GamepadFields { abstract class GamepadFields {
static const List<String> allFields = const <String>[buttons, dynamicMap];
static const String buttons = 'buttons'; static const String buttons = 'buttons';
static const String dynamicMap = 'dynamic_map'; static const String dynamicMap = 'dynamic_map';

View file

@ -21,6 +21,8 @@ abstract class GamepadButtonSerializer {
} }
abstract class GamepadButtonFields { abstract class GamepadButtonFields {
static const List<String> allFields = const <String>[name, radius];
static const String name = 'name'; static const String name = 'name';
static const String radius = 'radius'; static const String radius = 'radius';

View file

@ -30,6 +30,8 @@ abstract class WithEnumSerializer {
} }
abstract class WithEnumFields { abstract class WithEnumFields {
static const List<String> allFields = const <String>[type, finalList];
static const String type = 'type'; static const String type = 'type';
static const String finalList = 'final_list'; static const String finalList = 'final_list';