GithubHelp home page GithubHelp logo

ouxiaoyong / route_life Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 155 KB

a flutter package for listen route lifecycle

License: Apache License 2.0

Kotlin 0.87% Swift 8.12% Objective-C 0.27% Dart 90.74%

route_life's Introduction

if you wan to listen route lifecycle in widget, this is a way.

Usage

1.import route_life.dart

import 'package:route_life/route_life.dart';

2.set navigatorObservers

RouteLifeObserver routeLifeObserver = RouteLifeObserver();

MaterialApp(
      navigatorObservers: [
        routeLifeObserver
      ],
    );
  1. with RouteLifeMixin or AppLifeMixin
class _GamePageState extends State<GamePage> with RouteLifeMixin,AppLifeMixin{
  @override
  void initState() {
    super.initState();
    _playGamePageMusic();
  }

  @override
  void dispose() {
    _stopGamePageMusic();
    super.dispose();
  }

  @override
  void onRoutePause(Route nextRoute) {
    _pauseGamePageMusic();
  }

  @override
  void onRouteResume(Route nextRoute) {
    _resumeGamePageMusic();
  }

  @override
  void onAppLifeChanged(bool resume) {
    if(!isRouteShowing){
      return;
    }
    if(resume){
      _resumeGamePageMusic();
    }else{
      _pauseGamePageMusic();
    }
  }
}

route_life's People

Contributors

ouxiaoyong avatar

Watchers

James Cloos avatar  avatar

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.