Flutter Engine
The Flutter Engine
FlutterPlayStoreSplitApplication.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package io.flutter.app;
6
7import androidx.annotation.CallSuper;
8import com.google.android.play.core.splitcompat.SplitCompatApplication;
9import io.flutter.FlutterInjector;
10import io.flutter.embedding.engine.deferredcomponents.PlayStoreDeferredComponentManager;
11
12/**
13 * Flutter's extension of {@link SplitCompatApplication} that injects a {@link
14 * PlayStoreDeferredComponentManager} with {@link FlutterInjector} to enable Split AOT Flutter apps.
15 *
16 * <p>To use this class, either have your custom application class extend
17 * FlutterPlayStoreSplitApplication or use it directly in the app's AndroidManifest.xml by adding
18 * the following line:
19 *
20 * <pre>{@code
21 * <manifest
22 * ...
23 * <application
24 * android:name="io.flutter.app.FlutterPlayStoreSplitApplication"
25 * ...>
26 * </application>
27 * </manifest>
28 * }</pre>
29 *
30 * This class is meant to be used with the Google Play store. Custom non-play store applications do
31 * not need to extend SplitCompatApplication and should inject a custom {@link
32 * io.flutter.embedding.engine.deferredcomponents.DeferredComponentManager} implementation like so:
33 *
34 * <pre>{@code
35 * FlutterInjector.setInstance(
36 * new FlutterInjector.Builder().setDeferredComponentManager(yourCustomManager).build());
37 * }</pre>
38 */
39public class FlutterPlayStoreSplitApplication extends SplitCompatApplication {
40 @Override
41 @CallSuper
42 public void onCreate() {
43 super.onCreate();
44 // Create and inject a PlayStoreDeferredComponentManager, which is the default manager for
45 // interacting with the Google Play Store.
46 PlayStoreDeferredComponentManager deferredComponentManager =
50 .setDeferredComponentManager(deferredComponentManager)
51 .build());
52 }
53}
Builder setDeferredComponentManager( @Nullable DeferredComponentManager deferredComponentManager)
static void setInstance(@NonNull FlutterInjector injector)