brick_offline_first_abstract 2.0.0 copy "brick_offline_first_abstract: ^2.0.0" to clipboard
brick_offline_first_abstract: ^2.0.0 copied to clipboard

Annotations and models required by the Offline First domain.

example/main.dart

import 'dart:convert';

import 'package:brick_offline_first_abstract/abstract.dart';

/// When we don't want to make a separate association but have complex data that can be stored in a single column
/// Serdes classes cannot be queried like model members.
class Horse extends OfflineFirstSerdes<Map<String, dynamic>, String> {
  final String? breed;

  Horse({
    this.breed,
  });

  factory Horse.fromRest(Map<String, dynamic> data) {
    return Horse(breed: data['breed']);
  }

  factory Horse.fromSqlite(String data) => Horse.fromRest(jsonDecode(data));

  @override
  Map<String, dynamic> toRest() {
    return {'breed': breed};
  }

  @override
  String toSqlite() => jsonEncode(toRest());
}
0
likes
150
points
246
downloads

Publisher

unverified uploader

Weekly Downloads

Annotations and models required by the Offline First domain.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

brick_core, brick_sqlite_abstract, meta

More

Packages that depend on brick_offline_first_abstract