android_activity_lifecycle 1.0.0 copy "android_activity_lifecycle: ^1.0.0" to clipboard
android_activity_lifecycle: ^1.0.0 copied to clipboard

PlatformAndroid

This flutter plugin for listen to FlutterActivity lifecycle state change on flutter Android app

example/lib/main.dart

import 'dart:developer';

import 'package:flutter/material.dart';

import 'package:android_activity_lifecycle/android_activity_lifecycle.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _nAndroidLifecyclePlugin = AndroidActivityLifecycle();

  @override
  void initState() {
    super.initState();
    _nAndroidLifecyclePlugin.stateStream.listen((event) {
      final message = "ActivityLifeCycleState = $event";
      log(message);
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: [
              StreamBuilder<ActivityLifeCycleStateEnum>(
                stream: _nAndroidLifecyclePlugin.stateStream,
                builder: (_, s) {
                  final message = "ActivityLifeCycleState = ${s.data}";
                  return Text(message);
                },
              ),
              const Text('Open logging for more information\n'),
            ],
          ),
        ),
      ),
    );
  }
}
2
likes
130
points
36
downloads

Publisher

unverified uploader

Weekly Downloads

This flutter plugin for listen to FlutterActivity lifecycle state change on flutter Android app

Homepage
Repository (GitHub)
View/report issues

Topics

#platform-channels #plugin-development

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_plugin_android_lifecycle, plugin_platform_interface

More

Packages that depend on android_activity_lifecycle

Packages that implement android_activity_lifecycle