From a3c6a4afc17203d76f2d98c1a5cfa693783785ad Mon Sep 17 00:00:00 2001 From: Shams Zakhour Date: Wed, 15 Jan 2025 12:24:45 -0800 Subject: [PATCH] Changing a note to a warning and changing master -> main --- .../add-to-app/android/add-flutter-view.md | 77 +++++++++++-------- .../add-to-app/android/project-setup.md | 10 ++- src/content/add-to-app/index.md | 2 +- src/content/add-to-app/multiple-flutters.md | 4 +- src/content/add-to-app/performance.md | 2 +- 5 files changed, 57 insertions(+), 38 deletions(-) diff --git a/src/content/add-to-app/android/add-flutter-view.md b/src/content/add-to-app/android/add-flutter-view.md index 8f00a977a6..0750b69c62 100644 --- a/src/content/add-to-app/android/add-flutter-view.md +++ b/src/content/add-to-app/android/add-flutter-view.md @@ -38,40 +38,57 @@ for some of the cells in a RecycleView list of cards as seen in the gif above. ## General approach -The general gist of the FlutterView-level integration is that you must recreate -the various interactions between your Activity, the [FlutterView]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) -and the [FlutterEngine]({{site.api}}/javadoc/io/flutter/embedding/engine/FlutterEngine.html) -present in the [FlutterActivityAndFragmentDelegate](https://cs.opensource.google/flutter/engine/+/master:shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java) -in your own application's code. The connections made in the [FlutterActivityAndFragmentDelegate](https://cs.opensource.google/flutter/engine/+/master:shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java) -are done automatically when using a [FlutterActivity]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterActivity.html) -or a [FlutterFragment]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterFragment.html), -but since the [FlutterView]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) -in this case is being added to an Activity or Fragment in your application, -you must recreate the connections manually. Otherwise, the [FlutterView]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) -will not render anything or have other missing functionalities. - -A sample [FlutterViewEngine]({{site.repo.samples}}/blob/main/add_to_app/android_view/android_view/app/src/main/java/dev/flutter/example/androidView/FlutterViewEngine.kt) +The general gist of the FlutterView-level integration is that you +must recreate the various interactions between your Activity, the +[`FlutterView`]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) +and the +[`FlutterEngine`]({{site.api}}/javadoc/io/flutter/embedding/engine/FlutterEngine.html) +present in the [`FlutterActivityAndFragmentDelegate`](https://cs.opensource.google/flutter/engine/+/main:shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java) +in your own application's code. +The connections made in the +[`FlutterActivityAndFragmentDelegate`](https://cs.opensource.google/flutter/engine/+/main:shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java) +are done automatically when using a +[`FlutterActivity`]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterActivity.html) +or a +[`FlutterFragment`]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterFragment.html), +but since the [`FlutterView`]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) +in this case is being added to an `Activity` or `Fragment` in your application, +you must recreate the connections manually. +Otherwise, the [`FlutterView`]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) +won't render anything or have other missing functionalities. + +A sample +[`FlutterViewEngine`]({{site.repo.samples}}/blob/main/add_to_app/android_view/android_view/app/src/main/java/dev/flutter/example/androidView/FlutterViewEngine.kt) class shows one such possible implementation of an application-specific -connection between an Activity, a [FlutterView]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) +connection between an `Activity`, a +[`FlutterView`]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) and a [FlutterEngine]({{site.api}}/javadoc/io/flutter/embedding/engine/FlutterEngine.html). ### APIs to implement -The absolute minimum implementation needed for Flutter to draw anything at all -is to: - -- Call [attachToFlutterEngine]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html#attachToFlutterEngine-io.flutter.embedding.engine.FlutterEngine-) when the - [FlutterView]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) - is added to a resumed Activity's view hierarchy and is visible; and -- Call [appIsResumed]({{site.api}}/javadoc/io/flutter/embedding/engine/systemchannels/LifecycleChannel.html#appIsResumed--) on the [FlutterEngine]({{site.api}}/javadoc/io/flutter/embedding/engine/FlutterEngine.html)'s - `lifecycleChannel` field when the Activity hosting the [FlutterView]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) +The absolute minimum implementation needed for Flutter +to draw anything at all is to: + +* Call [`attachToFlutterEngine`]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html#attachToFlutterEngine-io.flutter.embedding.engine.FlutterEngine-) + when the + [`FlutterView`]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) + is added to a resumed `Activity`'s view hierarchy and is visible; and +* Call [`appIsResumed`]({{site.api}}/javadoc/io/flutter/embedding/engine/systemchannels/LifecycleChannel.html#appIsResumed--) + on the [`FlutterEngine`]({{site.api}}/javadoc/io/flutter/embedding/engine/FlutterEngine.html)'s + `lifecycleChannel` field when the `Activity` hosting the + [`FlutterView`]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html) is visible. -The reverse [detachFromFlutterEngine]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html#detachFromFlutterEngine--) and other lifecycle methods on the [LifecycleChannel]({{site.api}}/javadoc/io/flutter/embedding/engine/systemchannels/LifecycleChannel.html) -class must also be called to not leak resources when the FlutterView or Activity -is no longer visible. - -In addition, see the remaining implementation in the [FlutterViewEngine]({{site.repo.samples}}/blob/main/add_to_app/android_view/android_view/app/src/main/java/dev/flutter/example/androidView/FlutterViewEngine.kt) -demo class or in the [FlutterActivityAndFragmentDelegate](https://cs.opensource.google/flutter/engine/+/master:shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java) -to ensure a correct functioning of other features such as clipboards, system -UI overlay, plugins etc. +The reverse +[`detachFromFlutterEngine`]({{site.api}}/javadoc/io/flutter/embedding/android/FlutterView.html#detachFromFlutterEngine--) +and other lifecycle methods on the +[`LifecycleChannel`]({{site.api}}/javadoc/io/flutter/embedding/engine/systemchannels/LifecycleChannel.html) +class must also be called to not leak resources when the +`FlutterView` or `Activity` is no longer visible. + +In addition, see the remaining implementation in the +[`FlutterViewEngine`]({{site.repo.samples}}/blob/main/add_to_app/android_view/android_view/app/src/main/java/dev/flutter/example/androidView/FlutterViewEngine.kt) +demo class or in the +[`FlutterActivityAndFragmentDelegate`](https://cs.opensource.google/flutter/engine/+/main:shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java) +to ensure a correct functioning of other features such as clipboards, +system UI overlay, plugins, and so on. diff --git a/src/content/add-to-app/android/project-setup.md b/src/content/add-to-app/android/project-setup.md index 903931864a..178d1887d6 100644 --- a/src/content/add-to-app/android/project-setup.md +++ b/src/content/add-to-app/android/project-setup.md @@ -431,10 +431,12 @@ val filePath = settingsDir.parentFile.toString() + "/flutter_module/.android/inc apply(from = File(filePath)) ``` -:::note -The ability to invoke `include_flutter.groovy` from Kotlin code requires Flutter 3.27. -To determine your current Flutter version, run `flutter --version`. If it is not -at least version 3.27, consider changing to either the `master` or `beta` channels. +:::warning +The ability to invoke `include_flutter.groovy` from Kotlin code +requires Flutter 3.27. +To determine your current Flutter version, +run `flutter --version`. If it isn't at least version 3.27, +consider changing to either the `main` or `beta` channels. ::: If you are using Groovy, apply the following changes: diff --git a/src/content/add-to-app/index.md b/src/content/add-to-app/index.md index bcc81b691b..486df38e85 100644 --- a/src/content/add-to-app/index.md +++ b/src/content/add-to-app/index.md @@ -201,7 +201,7 @@ Web limitations: [`FlutterActivity`]: {{site.api}}/javadoc/io/flutter/embedding/android/FlutterActivity.html [java-engine]: {{site.api}}/javadoc/io/flutter/embedding/engine/FlutterEngine.html [ios-engine]: {{site.api}}/ios-embedder/interface_flutter_engine.html -[FlutterFire]: {{site.github}}/firebase/flutterfire/tree/master/packages +[FlutterFire]: {{site.github}}/firebase/flutterfire/tree/main/packages [`FlutterFragment`]: {{site.api}}/javadoc/io/flutter/embedding/android/FlutterFragment.html [`FlutterPlugin`]: {{site.api}}/javadoc/io/flutter/embedding/engine/plugins/FlutterPlugin.html [`FlutterViewController`]: {{site.api}}/ios-embedder/interface_flutter_view_controller.html diff --git a/src/content/add-to-app/multiple-flutters.md b/src/content/add-to-app/multiple-flutters.md index 8860a27e29..fba68e0218 100644 --- a/src/content/add-to-app/multiple-flutters.md +++ b/src/content/add-to-app/multiple-flutters.md @@ -90,5 +90,5 @@ on both Android and iOS on [GitHub][]. [Issue 72009]: {{site.repo.flutter}}/issues/72009 [Pigeon]: {{site.pub}}/packages/pigeon [platform channels]: /platform-integration/platform-channels -[Android API]: https://cs.opensource.google/flutter/engine/+/master:shell/platform/android/io/flutter/embedding/engine/FlutterEngineGroup.java -[iOS API]: https://cs.opensource.google/flutter/engine/+/master:shell/platform/darwin/ios/framework/Headers/FlutterEngineGroup.h +[Android API]: https://cs.opensource.google/flutter/engine/+/main:shell/platform/android/io/flutter/embedding/engine/FlutterEngineGroup.java +[iOS API]: https://cs.opensource.google/flutter/engine/+/main:shell/platform/darwin/ios/framework/Headers/FlutterEngineGroup.h diff --git a/src/content/add-to-app/performance.md b/src/content/add-to-app/performance.md index fe1aab8d05..82edfff9f3 100644 --- a/src/content/add-to-app/performance.md +++ b/src/content/add-to-app/performance.md @@ -207,7 +207,7 @@ For performance details on creating more than one `FlutterEngine`, see [multiple Flutters][]. [android-engine]: {{site.api}}/javadoc/io/flutter/embedding/engine/FlutterEngine.html -[auxiliary threads]: {{site.repo.flutter}}/blob/master/docs/about/The-Engine-architecture.md#threading +[auxiliary threads]: {{site.repo.flutter}}/blob/main/docs/about/The-Engine-architecture.md#threading [CAEAGLLayer]: {{site.apple-dev}}/documentation/quartzcore/caeagllayer [CAMetalLayer]: {{site.apple-dev}}/documentation/quartzcore/cametallayer [Dart `Isolate`]: {{site.dart.api}}/dart-isolate/Isolate-class.html