moor_flutter 1.3.0 copy "moor_flutter: ^1.3.0" to clipboard
moor_flutter: ^1.3.0 copied to clipboard

discontinuedreplaced by: drift_sqflite
outdated

Flutter implementation of moor, a safe and reactive persistence library for Dart applications

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:moor_example/bloc.dart';
import 'widgets/homescreen.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  MyAppState createState() {
    return MyAppState();
  }
}

// We use this widget to set up the material app and provide an InheritedWidget that
// the rest of this simple app can then use to access the database
class MyAppState extends State<MyApp> {
  TodoAppBloc bloc;

  @override
  void initState() {
    bloc = TodoAppBloc();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return BlocProvider(
      bloc: bloc,
      child: MaterialApp(
        title: 'moor Demo',
        theme: ThemeData(
          primarySwatch: Colors.orange,
          // use the good-looking updated material text style
          typography: Typography(
            englishLike: Typography.englishLike2018,
            dense: Typography.dense2018,
            tall: Typography.tall2018,
          ),
        ),
        home: HomeScreen(),
      ),
    );
  }
}

class BlocProvider extends InheritedWidget {
  final TodoAppBloc bloc;

  BlocProvider({@required this.bloc, Widget child}) : super(child: child);

  @override
  bool updateShouldNotify(BlocProvider oldWidget) {
    return oldWidget.bloc != bloc;
  }

  static TodoAppBloc provideBloc(BuildContext ctx) =>
      (ctx.inheritFromWidgetOfExactType(BlocProvider) as BlocProvider).bloc;
}
313
likes
0
pub points
94%
popularity

Publisher

verified publishersimonbinder.eu

Flutter implementation of moor, a safe and reactive persistence library for Dart applications

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, meta, moor, path, sqflite

More

Packages that depend on moor_flutter