route_lifecycle 0.0.2 copy "route_lifecycle: ^0.0.2" to clipboard
route_lifecycle: ^0.0.2 copied to clipboard

outdated

a new way to manage routes lifecycle.

route_lifecycle #

a new way to manage routes lifecycle.

Route路由生命周期管理插件

install #

Add to pubspec #

the latest version is pub package

dependencies:
  route_lifecycle: $latest_version

import in dart code #

import 'package:route_lifecycle/route_lifecycle.dart';

Usage #

route_lifecycle has the follow lifecycle callbacks:

  • init
  • resumed
  • inactive
  • disposed

/// config navigatorObservers

MaterialApp(
      navigatorObservers: [
        ...
        RouteMixin.getRouteLifecycleObserver(),
      ],
    );


/// with RouteMixin<T> 

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

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

class _HomePageState extends State<HomePage> with RouteMixin<HomePage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: InkWell(
        onTap: () {
        },
        child: Container(
        ),
      ),
    );
  }

  @override
  String getRouteName() {
    ///return your route name
    return "/main";
  }

  @override
  void init() {
    super.init();
  }

  @override
  void resumed() {
    super.resumed();
  }

  @override
  void inactive() {
    super.inactive();
  }

  @override
  void disposed() {
    super.disposed();
  }
}

2
likes
0
pub points
0%
popularity

Publisher

verified publishernewtab.work

a new way to manage routes lifecycle.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on route_lifecycle