Flutter Engine
The Flutter Engine
FlutterEngineProvider.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.embedding.android;
6
7import android.content.Context;
8import androidx.annotation.NonNull;
9import androidx.annotation.Nullable;
10import io.flutter.embedding.engine.FlutterEngine;
11
12/**
13 * Provides a {@link io.flutter.embedding.engine.FlutterEngine} instance to be used by a {@code
14 * FlutterActivity} or {@code FlutterFragment}.
15 *
16 * <p>{@link io.flutter.embedding.engine.FlutterEngine} instances require significant time to warm
17 * up. Therefore, a developer might choose to hold onto an existing {@link
18 * io.flutter.embedding.engine.FlutterEngine} and connect it to various {@link FlutterActivity}s
19 * and/or {@code FlutterFragment}s. This interface facilitates providing a cached, pre-warmed {@link
20 * io.flutter.embedding.engine.FlutterEngine}.
21 */
22public interface FlutterEngineProvider {
23 /**
24 * Returns the {@link io.flutter.embedding.engine.FlutterEngine} that should be used by a child
25 * {@code FlutterFragment}.
26 *
27 * <p>This method may return a new {@link io.flutter.embedding.engine.FlutterEngine}, an existing,
28 * cached {@link FlutterEngine}, or null to express that the {@code FlutterEngineProvider} would
29 * like the {@code FlutterFragment} to provide its own {@code FlutterEngine} instance.
30 *
31 * @param context The current context. e.g. An activity.
32 * @return The Flutter engine.
33 */
34 @Nullable
35 FlutterEngine provideFlutterEngine(@NonNull Context context);
36}
FlutterEngine provideFlutterEngine(@NonNull Context context)