lifecycle_provider 0.0.12 copy "lifecycle_provider: ^0.0.12" to clipboard
lifecycle_provider: ^0.0.12 copied to clipboard

Based on the provider and combined with GetX, a state management tool is developed, which enables the widget to have an Android-like life cycle.

example/lib/main.dart

import 'package:example/page_view/bottom_nav_page.dart';
import 'package:example/page_view/tab_page.dart';
import 'package:example/pages/dialog_page.dart';
import 'package:example/pages/drawer_page.dart';
import 'package:example/pages/pop_page.dart';
import 'package:example/pages/pop_until_page.dart';
import 'package:example/pages/replace_page.dart';
import 'package:example/pages/update_page.dart';
import 'package:flutter/material.dart';
import 'package:lifecycle_provider/lifecycle_provider.dart';

import 'home_page.dart';
import 'root_controller.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  AppLifecycleManager.instance.listen();
  runApp(const MyApp());
}

class MyApp extends BasePage<RootController> {
  const MyApp({super.key});

  @override
  RootController createController(BuildContext context) {
    return RootController();
  }

  @override
  Widget providerStateBuild(BuildContext context, RootController controller) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(primarySwatch: Colors.blue, useMaterial3: false),
      routes: {
        "/tabPage": (_) => const TabPage(),
        "/bottomNav": (_) => const BottomNavPage(),
        "/drawer": (_) => const DrawerPage(),
        "/popPage": (_) => const PopPage(),
        "/popUntilPage": (_) => const PopUntilPage(),
        "/replace": (_) => const ReplacePage(),
        "/dialog": (_) => const DialogPage(),
        "/updatePage": (_) => const UpdatePage(),
      },
      home: const HomePage(),
      navigatorObservers: [LifecycleRouteObserver()],
    );
  }
}
1
likes
130
points
93
downloads

Publisher

unverified uploader

Weekly Downloads

Based on the provider and combined with GetX, a state management tool is developed, which enables the widget to have an Android-like life cycle.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, meta, provider

More

Packages that depend on lifecycle_provider