simple_lifecycle 0.0.4 copy "simple_lifecycle: ^0.0.4" to clipboard
simple_lifecycle: ^0.0.4 copied to clipboard

The simple_lifecycle package provides a simple and intuitive way to manage the state of your Flutter application. It allows you to categorize the app's lifecycle events into two distinct state, active [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:simple_lifecycle/simple_lifecycle.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: ExampleScreen(),
    );
  }
}

class ExampleScreen extends StatefulWidget {
  @override
  _ExampleScreenState createState() => _ExampleScreenState();
}

class _ExampleScreenState extends State<ExampleScreen> {
  SimpleLifecycle _lifecycle = SimpleLifecycle();

  @override
  void initState() {
    super.initState();
    _lifecycle.initialize();
    _lifecycle.onAppActive = () {
      print("App is active");
    };
    _lifecycle.onAppPaused = () {
      print("App has been paused");
    };
  }

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Example'),
      ),
      body: Center(
        child: Text('Example Screen'),
      ),
    );
  }
}
2
likes
135
points
17
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

The simple_lifecycle package provides a simple and intuitive way to manage the state of your Flutter application. It allows you to categorize the app's lifecycle events into two distinct state, active and paused. The philosophy is that users are in two binary states, either active or inactive.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on simple_lifecycle