single_store 0.0.4 copy "single_store: ^0.0.4" to clipboard
single_store: ^0.0.4 copied to clipboard

a simple store hold all values in a singleton, recommended for use with ChangeNotifier & AnimatedBuilder.

example/main.dart

import 'package:flutter/material.dart';
import 'package:single_store/single_store.dart';

void main() async {
  runApp(MaterialApp(
    home: Example(),
  ));
}

class MyController with ChangeNotifier {
  int count = 0;

  MyController() {
    count += 1;
  }
}

class Example extends StatelessWidget {
  Example({Key? key}) : super(key: key);
  final ctrl = SingleStore().get(() => MyController());
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: AnimatedBuilder(
        animation: ctrl,
        builder: (ctx, _) {
          return Center(
            child: Text('${ctrl.count}'),
          );
        },
      ),
    );
  }
}
1
likes
120
pub points
0%
popularity

Publisher

unverified uploader

a simple store hold all values in a singleton, recommended for use with ChangeNotifier & AnimatedBuilder.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on single_store