notifier_builder 0.4.0-beta copy "notifier_builder: ^0.4.0-beta" to clipboard
notifier_builder: ^0.4.0-beta copied to clipboard

A Flutter library that provides an alternative to AnimatedBuilder for building widgets that depend on any Listenable notifier/controller

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: const MyHomePage(title: 'Flutter Demo Home Page'),
      );
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({
    required this.title,
    super.key,
  });

  final String title;

  @override
  Widget build(BuildContext context) => NotifierBuilder(
        notifier: () => ValueNotifier<int>(0),
        builder: (context, child, counterNotifier) => Scaffold(
          appBar: AppBar(
            title: Text(title),
          ),
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                const Text(
                  'You have pushed the button this many times:',
                ),
                Text(
                  '${counterNotifier.value}',
                  style: Theme.of(context).textTheme.headlineMedium,
                ),
              ],
            ),
          ),
          floatingActionButton: FloatingActionButton(
            onPressed: () => counterNotifier.value++,
            tooltip: 'Increment',
            child: const Icon(Icons.add),
          ),
        ),
      );
}
4
likes
160
points
21
downloads

Publisher

verified publisherchristianfindlay.com

Weekly Downloads

A Flutter library that provides an alternative to AnimatedBuilder for building widgets that depend on any Listenable notifier/controller

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on notifier_builder