Search packages, repositories and app categories

GitHub repositoryfelangel/inherited_stream

inherited_stream

An inherited widget for Streams, which updates its dependencies when the stream emits data.

inherited_stream project cover
Stars
23
Forks
2
Last push (UTC)
Mar 27, 2025
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

Inherited Stream

Pub build coverage License: MIT

An InheritedWidget for Streams, which updates its dependencies when the Stream emits.

Usage

Create an InheritedStream
class ProgressModel extends InheritedStream<ValueStream<double>> {
  const ProgressModel({
    Key? key,
    required ValueStream<double> stream,
    required Widget child,
  }) : super(key: key, stream: stream, child: child);

  static double of(BuildContext context) {
    return context
        .dependOnInheritedWidgetOfExactType<ProgressModel>()!
        .stream
        .value!;
  }
}
Insert into the Widget Tree
class _MyState extends State<MyPage> {
  final _subject = BehaviorSubject<double>.seeded(0.0);

  @override
  void dispose() {
    _subject.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ProgressModel(
        stream: _subject.stream,
        child: Progress(),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => _subject.add(Random.nextDouble()),
      ),
    );
  }
}
Register Dependant(s)
class Progress extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CircularProgressIndicator(value: ProgressModel.of(context));
  }
}
Felix Angelov GitHub avatar
GitHub author

Felix Angelov ↗

software engineer by day, software engineer by night.

LanguagesC++CMakeDartHTMLCSwiftKotlinObjective-C

Dependencies used

Dependency list 2 items

  • flutter{"sdk":"flutter"}
  • flutter_testDevelopment{"sdk":"flutter"}

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗