flutter_data 2.0.0-rc2 copy "flutter_data: ^2.0.0-rc2" to clipboard
flutter_data: ^2.0.0-rc2 copied to clipboard

The seamless way to work with persistent data models in Flutter. Inspired by Ember Data and ActiveRecord.

example/lib/main.dart

import 'dart:io';
import 'package:flutter_data/flutter_data.dart';

import 'main.data.dart';
import 'models/user.dart';

// NOTE: FOR AN UPDATED AND COMPLETE FLUTTER EXAMPLE FOLLOW
// https://github.com/flutterdata/tutorial

void main() async {
  late final Directory _dir;
  late final ProviderContainer container;

  try {
    _dir = Directory.systemTemp.createTempSync();

    container = ProviderContainer(
      overrides: [
        localStorageProvider.overrideWith(
          (ref) => LocalStorage(
            baseDirFn: () => _dir.path,
            clear: LocalStorageClearStrategy.always,
          ),
        ),
      ],
    );

    print('Using temporary directory: ${_dir.path}');

    await container.read(initializeFlutterData(adapterProvidersMap).future);
    container.users.logLevel = 2;
    container.tasks.logLevel = 2;

    await container.tasks.findAll(params: {'user_id': 1, '_limit': 3});

    final user = User(id: 1, name: 'Roman').saveLocal();
    final user2 = container.users.findOneLocalById(1);

    assert(user.name == user2!.name);
    assert(user.tasks.length == 3);
  } finally {
    await container.read(localStorageProvider).destroy();
  }
}
369
likes
0
points
1.54k
downloads

Publisher

verified publisherflutterdata.dev

Weekly Downloads

The seamless way to work with persistent data models in Flutter. Inspired by Ember Data and ActiveRecord.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

analyzer, async, build, build_resolvers, collection, crypto, equatable, glob, http, inflection3, json_annotation, messagepack, meta, path, pool, pubspec_parse, recase, retry, riverpod, source_gen, source_helper, sqlite3, state_notifier

More

Packages that depend on flutter_data