advanced_value_notifier 0.0.1+1 copy "advanced_value_notifier: ^0.0.1+1" to clipboard
advanced_value_notifier: ^0.0.1+1 copied to clipboard

A value notifier which has super powers, like allows to see past value along with the new

example/lib/main.dart

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

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: MyHomePage(title: 'History Value Notifier'),
    );
  }
}

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

  final String title;

  final HistoryValueNotifier<int> counter = HistoryValueNotifier(0);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            HistoryValueListenableListener<int>(
              historyValueNotifier: counter,
              historyValueWidgetListener: (int prevValue, int value) {
                print("Prev $prevValue Curr $value");
              },
              child: const Text(
                'Hello',
              ),
            ),
            HistoryValueListenableBuilder<int>(
              historyValueNotifier: counter,
              historyValueBuilder: (BuildContext context, int prevValue,
                  int value, Widget? child) {
                return Text(
                  "Prev $prevValue Curr $value",
                  style: Theme.of(context).textTheme.headlineMedium,
                );
              },
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          counter.value++;
        },
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
1
likes
0
points
31
downloads

Publisher

verified publisherabhishak.in

Weekly Downloads

A value notifier which has super powers, like allows to see past value along with the new

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on advanced_value_notifier