deposit 0.0.2 copy "deposit: ^0.0.2" to clipboard
deposit: ^0.0.2 copied to clipboard

A data backend agnostic repository pattern package for Dart and Flutter

example/main.dart

import 'package:deposit/deposit.dart';

class MovieEntity extends Entity {
  MovieEntity({
    this.id,
    required this.title,
  });

  factory MovieEntity.fromJSON(Map<String, dynamic> data) {
    return MovieEntity(
      id: data['id'] as int?,
      title: data['title'] as String? ?? 'No title',
    );
  }

  int? id;

  String title;

  @override
  Map<String, dynamic> toJSON() {
    return <String, dynamic>{
      'id': id,
      'title': title,
    };
  }

  @override
  String toString() => '$id: $title';
}

class MovieDeposit extends Deposit<MovieEntity, int> {
  MovieDeposit() : super('movies', MovieEntity.fromJSON);
}

Future<void> main() async {
  Deposit.defaultAdapter = MemoryDepositAdapter();

  final movieDeposit = MovieDeposit();
  await movieDeposit.add(MovieEntity(title: 'The Godfather'));
  await movieDeposit.add(MovieEntity(title: 'Avatar'));

  final movie = await movieDeposit.getById(1);
  print('Movie id: ${movie.id}');

  print(await movieDeposit.page(orderBy: OrderBy('title', ascending: true)));
}
12
likes
160
pub points
32%
popularity

Publisher

verified publisherblue-fire.xyz

A data backend agnostic repository pattern package for Dart and Flutter

Homepage
Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

MIT (license)

More

Packages that depend on deposit