Coder Social home page Coder Social logo

hoc081098 / did_change_dependencies Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 3.0 4.4 MB

Return a Stream that emits null and done event when didChangeDependencies is called for the first time.

Home Page: https://pub.dev/packages/did_change_dependencies

License: MIT License

Dart 100.00%
dart-streams rxdart rxdart-flutter rxdart-bloc rxdart-helper rxdart-debug-operator rxdart-ext rxdart-extension rxdart-extensions flutter-rxdart

did_change_dependencies's Introduction

did_change_dependencies

Return a Stream that emits null and done event when State.didChangeDependencies is called for the first time.

Dart CI Pub Pub codecov GitHub Style

Example

import 'dart:async';

import 'package:did_change_dependencies/did_change_dependencies.dart';
import 'package:flutter/material.dart';
import 'package:rxdart_ext/rxdart_ext.dart';

class Bloc {
  Stream<String> message$ = Stream.empty(); // just demo
}

class MyPage extends StatefulWidget {
  const MyPage({Key? key}) : super(key: key);

  @override
  _MyPageState createState() => _MyPageState();
}

class _MyPageState extends State<MyPage> with DidChangeDependenciesStream {
  final bloc = Bloc();
  final subscriptions = <StreamSubscription<void>>[];

  @override
  void initState() {
    super.initState();

    final handle = (String msg) {
      // safe to access ScaffoldMessengerState.
      ScaffoldMessenger.of(context).showSnackBar(
        SnackBar(content: Text(msg)),
      );
    };
    subscriptions <<
        didChangeDependencies$
            .exhaustMap((value) => bloc.message$)
            .listen(handle);

    subscriptions <<
        didChangeDependencies$.listen((event) {
          // do something when `didChangeDependencies` is called for the first time.
        });
  }

  @override
  void dispose() {
    super.dispose();
    subscriptions.forEach((s) => s.cancel());
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

extension _ListExt<T> on List<T> {
  void operator <<(T t) => add(t);
}

did_change_dependencies's People

Contributors

hoc081098 avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

did_change_dependencies's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/flutter.yml
  • actions/checkout v2
  • subosito/flutter-action v1.5.3
  • codecov/codecov-action v2.1.0
pub
pubspec.yaml
  • flutter
  • pedantic ^1.11.0
  • rxdart_ext ^0.1.2
  • dart >=2.12.0 <3.0.0
  • flutter >=2.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.