Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
io.flutter.FlutterInjector Class Reference

Classes

class  Builder
 

Public Member Functions

FlutterLoader flutterLoader ()
 
DeferredComponentManager deferredComponentManager ()
 
ExecutorService executorService ()
 
FlutterJNI.Factory getFlutterJNIFactory ()
 

Static Public Member Functions

static void setInstance (@NonNull FlutterInjector injector)
 
static FlutterInjector instance ()
 
static void reset ()
 

Detailed Description

This class is a simple dependency injector for the relatively thin Android part of the Flutter engine.

This simple solution is used facilitate testability without bringing in heavier app-development centric dependency injection frameworks such as Guice or Dagger2 or spreading construction injection everywhere.

Definition at line 25 of file FlutterInjector.java.

Member Function Documentation

◆ deferredComponentManager()

DeferredComponentManager io.flutter.FlutterInjector.deferredComponentManager ( )
inline

Returns the DeferredComponentManager instance to use for the Flutter Android engine embedding.

Definition at line 99 of file FlutterInjector.java.

99 {
100 return deferredComponentManager;
101 }

◆ executorService()

ExecutorService io.flutter.FlutterInjector.executorService ( )
inline

Definition at line 103 of file FlutterInjector.java.

103 {
104 return executorService;
105 }

◆ flutterLoader()

FlutterLoader io.flutter.FlutterInjector.flutterLoader ( )
inline

Returns the io.flutter.embedding.engine.loader.FlutterLoader instance to use for the Flutter Android engine embedding.

Definition at line 90 of file FlutterInjector.java.

90 {
91 return flutterLoader;
92 }

◆ getFlutterJNIFactory()

FlutterJNI.Factory io.flutter.FlutterInjector.getFlutterJNIFactory ( )
inline

Definition at line 108 of file FlutterInjector.java.

108 {
109 return flutterJniFactory;
110 }

◆ instance()

static FlutterInjector io.flutter.FlutterInjector.instance ( )
inlinestatic

Retrieve the static instance of the FlutterInjector to use in your program.

Once you access it, you can no longer change the values injected.

If no override is provided for the injector, reasonable defaults are provided.

Definition at line 54 of file FlutterInjector.java.

54 {
55 accessed = true;
56 if (instance == null) {
57 instance = new Builder().build();
58 }
59 return instance;
60 }
std::shared_ptr< DlVertices > build()
Finalizes and the constructed DlVertices object.
Definition: dl_vertices.cc:279
DlVertices::Builder Builder

◆ reset()

static void io.flutter.FlutterInjector.reset ( )
inlinestatic

Definition at line 65 of file FlutterInjector.java.

65 {
66 accessed = false;
67 instance = null;
68 }

◆ setInstance()

static void io.flutter.FlutterInjector.setInstance ( @NonNull FlutterInjector  injector)
inlinestatic

Use FlutterInjector.Builder to specify members to be injected via the static
FlutterInjector
.

This can only be called at the beginning of the program before the instance() is accessed.

Definition at line 37 of file FlutterInjector.java.

37 {
38 if (accessed) {
39 throw new IllegalStateException(
40 "Cannot change the FlutterInjector instance once it's been "
41 + "read. If you're trying to dependency inject, be sure to do so at the beginning of "
42 + "the program");
43 }
44 instance = injector;
45 }

The documentation for this class was generated from the following file: