Viewing version 2.0.35. Open the latest package page.

flutter_plugin_android_lifecycle

2.0.35

Flutter plugin for accessing an Android Lifecycle within other plugins.

Download archive

Readme

Flutter Android Lifecycle Plugin

pub package

A Flutter plugin for Android to allow other Flutter plugins to access Android Lifecycle objects in the plugin's binding.

The purpose of having this plugin instead of exposing an Android Lifecycle object in the engine's Android embedding plugins API is to force plugins to have a pub constraint that signifies the major version of the Android Lifecycle API they expect.

Android
Support SDK 24+

Example

Use a FlutterLifecycleAdapter within another Flutter plugin's Android implementation, as shown below:

import androidx.lifecycle.Lifecycle;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.FlutterPlugin.FlutterPluginBinding;
import io.flutter.embedding.engine.plugins.lifecycle.FlutterLifecycleAdapter;

public class MyPlugin implements FlutterPlugin, ActivityAware {
  @Override
  public void onAttachedToActivity(ActivityPluginBinding binding) {
    Lifecycle lifecycle = FlutterLifecycleAdapter.getActivityLifecycle(binding);
    // Use lifecycle as desired.
  }

  //...
}

Feedback welcome and Pull Requests are most welcome!

Changelog

2.0.35

  • Bumps the androidx group across 10 directories with 1 update.
  • Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.

2.0.34

  • Updates build files from Groovy to Kotlin.
  • Updates README to reflect currently supported OS version.

2.0.33

  • Bumps com.android.tools.build:gradle from 8.12.1 to 8.13.1.

2.0.32

  • Updates Java compatibility version to 17 and minimum supported SDK version to Flutter 3.35/Dart 3.9.

2.0.31

  • Resolves Gradle 9 deprecations.

2.0.30

  • Bumps com.android.tools.build:gradle to 8.12.1.
  • Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.

2.0.29

  • Updates kotlin version to 2.2.0 to enable gradle 8.11 support.

2.0.28

  • Removes obsolete code related to supporting SDK <21.

2.0.27

  • Bumps flutter supported version to 3.27 and use flutter.compileSdkVersion.

2.0.26

  • Removes flutter.compileSdkVersion for 35 to support flutter versions prior to 3.27.

2.0.25

  • Updates compileSdk 35 to flutter.compileSdkVersion.

2.0.24

  • Updates annotation to 1.9.1.

2.0.23

  • Updates Java compatibility version to 11.
  • Updates minimum supported SDK version to Flutter 3.24/Dart 3.5.

2.0.22

  • Bumps com.android.tools.build:gradle from 7.2.1 to 8.5.1.

2.0.21

  • Updates lint checks to ignore NewerVersionAvailable.

2.0.20

  • Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
  • Removes support for apps using the v1 Android embedding.

2.0.19

  • Updates minSdkVersion to 19.
  • Updates minimum supported SDK version to Flutter 3.16/Dart 3.2.

2.0.18

  • Updates minimum supported SDK version to Flutter 3.13/Dart 3.1.
  • Updates compileSdk version to 34.

2.0.17

  • Updates annotations lib to 1.7.0.

2.0.16

  • Adds pub topics to package metadata.
  • Updates minimum supported SDK version to Flutter 3.7/Dart 2.19.

2.0.15

  • Fixes Java lints.
  • Updates minimum supported SDK version to Flutter 3.3/Dart 2.18.

2.0.14

  • Fixes compatibility with ActivityPluginBinding.

2.0.13

  • Fixes compatibility with AGP versions older than 4.2.

2.0.12

  • Adds targetCompatibilty matching sourceCompatibility for older toolchains.

2.0.11

  • Adds a namespace for compatibility with AGP 8.0.

2.0.10

  • Sets an explicit Java compatibility version.
  • Aligns Dart and Flutter SDK constraints.

2.0.9

  • Updates annotation and espresso dependencies.
  • Updates compileSdkVersion to 33.

2.0.8

  • Updates links for the merge of flutter/plugins into flutter/packages.
  • Updates minimum Flutter version to 3.0.

2.0.7

  • Bumps gradle from 3.5.0 to 7.2.1.

2.0.6

  • Adds OS version support information to README.
  • Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors lint warnings.

2.0.5

  • Updates compileSdkVersion to 31.

2.0.4

  • Updated Android lint settings.
  • Remove placeholder Dart file.

2.0.3

  • Remove references to the Android V1 embedding.

2.0.2

  • Migrate maven repo from jcenter to mavenCentral.

2.0.1

  • Make sure androidx.lifecycle.DefaultLifecycleObservable doesn't get shrunk away.

2.0.0

  • Bump Dart SDK for null-safety compatibility.
  • Fix outdated links across a number of markdown files (#3276)

1.0.12

  • Update Flutter SDK constraint.

1.0.11

  • Keep handling deprecated Android v1 classes for backward compatibility.

1.0.10

  • Update android compileSdkVersion to 29.

1.0.9

  • Let the no-op plugin implement the FlutterPlugin interface.

1.0.8

  • Post-v2 Android embedding cleanup.

1.0.7

1.0.6

  • Make the pedantic dev_dependency explicit.

1.0.5

  • Add notice in example this plugin only provides Android Lifecycle API.

1.0.4

  • Require Flutter SDK 1.12.13 or greater.
  • Change to avoid reflection.

1.0.3

  • Remove the deprecated author: field from pubspec.yaml
  • Require Flutter SDK 1.10.0 or greater.

1.0.2

1.0.1

  • Register the E2E plugin in the example app.

1.0.0

  • Introduces a FlutterLifecycleAdapter, which can be used by other plugins to obtain a Lifecycle reference from a FlutterPluginBinding.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'flutter_plugin_android_lifecycle:2.0.35'
pubspec.yaml
name: flutter_plugin_android_lifecycle
description: Flutter plugin for accessing an Android Lifecycle within other plugins.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_plugin_android_lifecycle
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_plugin_android_lifecycle%22
version: 2.0.35

environment:
  sdk: ^3.10.0
  flutter: ">=3.38.0"

flutter:
  plugin:
    platforms:
      android:
        package: io.flutter.plugins.flutter_plugin_android_lifecycle
        pluginClass: FlutterAndroidLifecyclePlugin

dependencies:
  flutter:
    sdk: flutter

dev_dependencies:
  flutter_test:
    sdk: flutter

topics:
  - android
  - plugin-development

Version history

VersionPublishedArchiveSHA-256
1.0.0On demandDownload5ce133b8…30db6c
1.0.2On demandDownload7c46db69…832bc9
1.0.3On demandDownload8c02ec5a…82c65d
1.0.4On demandDownload9fa01e53…bec5ec
1.0.5On demandDownloadfd25f7c9…aaceea
1.0.6On demandDownload874c97e1…3db6e9
1.0.7On demandDownload38a45d4d…b93cda
1.0.8On demandDownload09aaed87…1a6086
1.0.9On demandDownload6f1c7bbf…cd1318
1.0.11On demandDownloadf64fc84e…3361ae
2.0.0-nullsafetyOn demandDownloadc3efba4f…2605a5
2.0.0-nullsafety.2On demandDownload9cfac091…d974ea
2.0.0On demandDownload0ba8a185…53421d
2.0.1On demandDownload6f25e9e3…07e2c7
2.0.2On demandDownloadaa36b33c…7d2162
2.0.3On demandDownload98000684…51ab9c
2.0.4On demandDownload7ad4cb6d…b8ebda
2.0.5On demandDownload5c574d21…8ed387
2.0.6On demandDownload6ffe524c…24e74a
2.0.7On demandDownload60fc7b78…63503b
2.0.8On demandDownload4bef6346…14e5d2
2.0.9On demandDownloadc224ac89…29ffdf
2.0.11On demandDownloadbdf9744b…99992a
2.0.12On demandDownload2818f523…a7e656
2.0.13On demandDownload8ffe990d…69b1bb
2.0.14On demandDownload96af49aa…0bd0b0
2.0.15On demandDownload950e77c2…1ea360
2.0.16On demandDownloadf185ac89…15f02c
2.0.17On demandDownloadb068ffc4…c456da
2.0.18On demandDownload592dc01a…32cadf
2.0.19On demandDownload8cf40eeb…43809f
2.0.20On demandDownloadc6b0b4c0…a4d03e
2.0.21On demandDownload9d98bd47…89a6de
2.0.22On demandDownload9ee02950…ff6eda
2.0.23On demandDownload9b78450b…721398
2.0.24On demandDownload615a505a…a0ce0e
2.0.25On demandDownload1f74d9bd…f583e9
2.0.26On demandDownload1c2b787f…6134bf
2.0.27On demandDownload5a1e6fb2…02eea3
2.0.28On demandDownloadf948e346…022b5e
2.0.29On demandDownload6382ce71…f16cab
2.0.30On demandDownloadb0694b7f…db0c31
2.0.31On demandDownloadc2fe1001…4b8476
2.0.32On demandDownload306f0596…003687
2.0.33Cached · Upstream SHA-256 matchedDownloadee8068e0…9b7fd1
2.0.34On demandDownload38d1c268…2055a0
2.0.35Cached · Upstream SHA-256 matchedDownload3854fe5e…969785

Dependencies

flutter { "sdk": "flutter" }