Class FlutterEngineFlags

java.lang.Object
io.flutter.embedding.engine.FlutterEngineFlags

public final class FlutterEngineFlags extends Object
Arguments that can be delivered to the Flutter shell on Android.

The term "shell" refers to the native code that adapts Flutter to different platforms. Flutter's Android Java code initializes a native "shell" and passes these arguments to that native shell when it is initialized. See FlutterLoader.ensureInitializationComplete(Context, String[]) for more information.

All of these flags map to a flag listed in shell/common/switches.cc, which contains the full list of flags that can be set across all platforms.

These flags can either be set via the manifest metadata in a Flutter component's AndroidManifest.xml or via the command line. See the inner Flag class for the specification of how to set each flag via the command line and manifest metadata.

If the same flag is provided both via command line arguments and via AndroidManifest.xml metadata, the command line value will take precedence at runtime.

  • Field Details

    • AOT_SHARED_LIBRARY_NAME

      public static final FlutterEngineFlags.Flag AOT_SHARED_LIBRARY_NAME
      Specifies the path to the AOT shared library containing compiled Dart code.

      The AOT shared library that the engine uses will default to the library set by this flag, but will fall back to the libraries set internally by the embedding if the path specified by this argument is invalid.

      Allowed in release to support the same AOT configuration regardless of build mode. Only settable via the manifest.

    • DEPRECATED_AOT_SHARED_LIBRARY_NAME

      @Deprecated public static final FlutterEngineFlags.Flag DEPRECATED_AOT_SHARED_LIBRARY_NAME
      Deprecated.
      Deprecated flag that specifies the path to the AOT shared library containing compiled Dart code.

      Please use AOT_SHARED_LIBRARY_NAME instead.

    • FLUTTER_ASSETS_DIR

      public static final FlutterEngineFlags.Flag FLUTTER_ASSETS_DIR
      Sets the directory containing Flutter assets.

      Allowed in release to specify custom asset locations in production. Only settable via the manifest.

    • DEPRECATED_FLUTTER_ASSETS_DIR

      @Deprecated public static final FlutterEngineFlags.Flag DEPRECATED_FLUTTER_ASSETS_DIR
      Deprecated.
      The deprecated flag that sets the directory containing Flutter assets.

      Please use FLUTTER_ASSETS_DIR infstead.

    • OLD_GEN_HEAP_SIZE

      public static final FlutterEngineFlags.Flag OLD_GEN_HEAP_SIZE
      Sets the old generation heap size for the Dart VM in megabytes.

      Allowed in release for performance tuning. Only settable via the manifest.

    • VM_SNAPSHOT_DATA

      public static final FlutterEngineFlags.Flag VM_SNAPSHOT_DATA
      Specifies the path to the VM snapshot data file.

      Allowed in release to support different snapshot configurations. Only settable via the manifest.

    • ISOLATE_SNAPSHOT_DATA

      public static final FlutterEngineFlags.Flag ISOLATE_SNAPSHOT_DATA
      Specifies the path to the isolate snapshot data file.

      Allowed in release to support different snapshot configurations. Only settable via the manifest.

    • ENABLE_SOFTWARE_RENDERING

      public static final FlutterEngineFlags.Flag ENABLE_SOFTWARE_RENDERING
      Use Skia software backend for rendering.

      Settable via the command line and the manifest.

    • TEST_FLAG

      @VisibleForTesting public static final FlutterEngineFlags.Flag TEST_FLAG
      Fake flag used for integration testing of the Android embedding processing engine flags.

      Only settable via the manifest.

    • LEAK_VM

      public static final FlutterEngineFlags.Flag LEAK_VM
      Set whether leave or clean up the VM after the last shell shuts down. It can be set from app's metadata in the application block in AndroidManifest.xml. Set it to true in to leave the Dart VM, set it to false to destroy VM.

      If your want to let your app destroy the last shell and re-create shells more quickly, set it to true, otherwise if you want to clean up the memory of the leak VM, set it to false.

      Only settable via the manifest.

      TODO(eggfly): Should it be set to false by default? https://github.com/flutter/flutter/issues/96843

    • DISABLE_MERGED_PLATFORM_UI_THREAD

      @VisibleForTesting public static final FlutterEngineFlags.Flag DISABLE_MERGED_PLATFORM_UI_THREAD
      Disables the merging of the UI and platform threads.

      This flag is disabled and only exists for the purpose of throwing an exception when used.

    • ALL_FLAGS

      @VisibleForTesting public static final List<FlutterEngineFlags.Flag> ALL_FLAGS
  • Method Details

    • getFlagByEngineArgument

      public static FlutterEngineFlags.Flag getFlagByEngineArgument(String arg)
      Looks up a FlutterEngineFlags.Flag by its engineArgument.
    • getFlagFromIntentKey

      public static FlutterEngineFlags.Flag getFlagFromIntentKey(String intentKey)
      Looks up a FlutterEngineFlags.Flag by its Intent key.

      Previously, the Intent keys were used to set Flutter shell arguments via Intent. The Intent keys typically match the command line argument without the "--" prefix and "=" suffix if the argument takes a value.

    • isDisabled

      public static boolean isDisabled(FlutterEngineFlags.Flag flag)
      Returns whether or not a flag is disabled and should raise an exception if used.
    • getReplacementFlagIfDeprecated

      public static FlutterEngineFlags.Flag getReplacementFlagIfDeprecated(FlutterEngineFlags.Flag flag)
      Returns the replacement flag of that given if it is deprecated.