Flutter Engine
 
Loading...
Searching...
No Matches
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
6
7@interface FlutterLaunchEngine () {
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
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
FlutterEngine engine
Definition main.cc:84
nullable FlutterEngine * takeEngine()
int BOOL