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