Skip to content

Instantly share code, notes, and snippets.

@theniceboy
theniceboy / state.dart
Last active October 31, 2023 01:38
Simple stream-based state management in Flutter/Dart
import 'dart:async';
import 'package:async/async.dart';
import 'package:flutter/widgets.dart';
/*
This class is a little bit different than the [ValueNotifier] class:
- Setting the value ALWAYS notifies listeners, even if the value is the same.
- It uses streams over [ValueListenableBuilder]'s setState approach to make it
easier to use with other async code.