Skip to content
pubscout

watch_it

2.5.0, released 2 months ago by flutter-it.dev

State management powered by get_it to observe changes and rebuild widgets automatically.

WASM-ready
$ flutter pub add watch_it
Source repository

What it does

Allows Flutter widgets to observe changes of objects inside the get_it service locator and automatically rebuild when data changes. It eliminates boilerplate builders like ValueListenableBuilder and StreamBuilder.

AI-written summary of version 2.5.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are already using get_it for dependency injection and want reactive UI updates
  • You want to avoid widget tree nesting and boilerplate builders

Skip it when

  • You prefer built-in Flutter mechanisms like InheritedWidget or setState
  • You cannot follow the strict watch ordering rules

Strengths

  • Zero boilerplate with no builders or manual subscriptions
  • Automatic disposal of subscriptions when widgets are destroyed
  • Type safe with compile-time error checking via generics

Weaknesses

  • Requires strict adherence to watch ordering rules (index-based retrieval)
  • Tight coupling with get_it service locator

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
2

Requires adding watch_it and get_it to pubspec.yaml.

class CounterWidget extends WatchingWidget {
  @override
  Widget build(BuildContext context) {
    final count = watchValue((CounterModel m) => m.count);
    return Text('$count');
  }
}

Alternatives

Packages that do the same job and could replace watch_it.

  • yx_state

    A state management library for Dart and Flutter applications.

  • bloc_tools

    Command-line tools for generating and linting bloc and cubit components.

  • riverpod

    A reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze.

  • listen

    A package to notify state changes to interested listeners in pure Dart.

Works with

Packages commonly used together with watch_it: ones it builds on, ones built on it, and its own family.