| Flutter iOS Embedder |

FlutterLaunchEngine.m
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
5 #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterLaunchEngine.h"
6
7 @interface FlutterLaunchEngine () {
8 BOOL _didTakeEngine;
9 FlutterEngine* _engine;
10 }
11 @end
12
13 @implementation FlutterLaunchEngine
14
15 - (instancetype)init {
16 self = [super init];
17 if (self) {
18 self->_didTakeEngine = NO;
19 }
20 return self;
21 }
22
23 - (FlutterEngine*)engine {
24 if (!_didTakeEngine && !_engine) {
25 // `allowHeadlessExecution` is set to `YES` since that has always been the
26 // default behavior. Technically, someone could have set it to `NO` in their
27 // nib and it would be ignored here. There is no documented usage of this
28 // though.
29 // `restorationEnabled` is set to `YES` since a FlutterViewController
30 // without restoration will have a nil restorationIdentifier leading no
31 // restoration data being saved. So, it is safe to turn this on in the event
32 // that someone does not want it.
33 _engine = [[FlutterEngine alloc] initWithName:@"io.flutter"
34 project:[[FlutterDartProject alloc] init]
35 allowHeadlessExecution:YES
36 restorationEnabled:YES];
37 // Run engine with default values like initialRoute. Specifying these in
38 // the FlutterViewController was not supported so it's safe to use the
39 // defaults.
40 [_engine run];
41 }
42 return _engine;
43 }
44
45 - (nullable FlutterEngine*)takeEngine {
46 FlutterEngine* result = _engine;
47 _engine = nil;
48 _didTakeEngine = YES;
49 return result;
50 }
51
52 @end
FlutterLaunchEngine.h
engine
id engine
Definition: FlutterTextInputPluginTest.mm:136
FlutterLaunchEngine()::_didTakeEngine
BOOL _didTakeEngine
Definition: FlutterLaunchEngine.m:8
FlutterLaunchEngine()::_engine
FlutterEngine * _engine
Definition: FlutterLaunchEngine.m:9
FlutterDartProject
Definition: FlutterDartProject.mm:263
FlutterEngine
Definition: FlutterEngine.h:61
FlutterLaunchEngine
Definition: FlutterLaunchEngine.h:23
-[FlutterLaunchEngine takeEngine]
nullable FlutterEngine * takeEngine()
Definition: FlutterLaunchEngine.m:45