brick_offline_first_with_rest_abstract 1.0.1 copy "brick_offline_first_with_rest_abstract: ^1.0.1" to clipboard
brick_offline_first_with_rest_abstract: ^1.0.1 copied to clipboard

Annotations and models required by the Offline First with Rest domain.

example/example.dart

import 'package:brick_rest/rest.dart';

import 'package:brick_offline_first_abstract/annotations.dart';
import 'package:brick_offline_first_abstract/abstract.dart';

/// A child association
@ConnectOfflineFirstWithRest(
  restConfig: RestSerializable(
    endpoint: '=> /hats;',
  ),
)
class Hat extends OfflineFirstWithRestModel {
  final int? id;

  final String? color;

  Hat({
    this.id,
    this.color,
  });
}

/// A parent association
@ConnectOfflineFirstWithRest(
  restConfig: RestSerializable(
    endpoint: '=> /people;',
  ),
)
class Person extends OfflineFirstWithRestModel {
  /// given an API response of
  /// { "hat_id" : 1}
  /// this will automatically fetch or hydrate the association based on the unique lookup of
  /// Hat.id
  @OfflineFirst(where: {'id': "data['hat_id']"})

  /// for upsert and delete, the rest key must be defined
  @Rest(name: 'hat_id')
  final Hat? hat;

  Person({
    this.hat,
  });
}
0
likes
110
pub points
3%
popularity

Publisher

unverified uploader

Annotations and models required by the Offline First with Rest domain.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

brick_core, brick_offline_first_abstract, brick_rest, brick_sqlite_abstract, meta

More

Packages that depend on brick_offline_first_with_rest_abstract