Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ScreenBeforeFlutter.m
Go to the documentation of this file.
1// Copyright 2019 The Chromium 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
7
8@implementation ScreenBeforeFlutter
9
10@synthesize engine = _engine;
11
12- (id)initWithEngineRunCompletion:(dispatch_block_t)engineRunCompletion {
13 self = [super init];
14 _engine = [[FlutterEngine alloc] initWithScenario:@"poppable_screen"
15 withCompletion:engineRunCompletion];
16 return self;
17}
18
19- (void)viewDidLoad {
20 [super viewDidLoad];
21 self.view.backgroundColor = UIColor.grayColor;
22
23 UIButton* showFlutterButton = [UIButton buttonWithType:UIButtonTypeSystem];
24 showFlutterButton.translatesAutoresizingMaskIntoConstraints = NO;
25 showFlutterButton.backgroundColor = UIColor.blueColor;
26 [showFlutterButton setTitle:@"Show Flutter" forState:UIControlStateNormal];
27 showFlutterButton.tintColor = UIColor.whiteColor;
28 showFlutterButton.clipsToBounds = YES;
29 [showFlutterButton addTarget:self
30 action:@selector(showFlutter:)
31 forControlEvents:UIControlEventTouchUpInside];
32
33 [self.view addSubview:showFlutterButton];
34 [[showFlutterButton.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor] setActive:YES];
35 [[showFlutterButton.centerYAnchor constraintEqualToAnchor:self.view.centerYAnchor] setActive:YES];
36 [[showFlutterButton.heightAnchor constraintEqualToConstant:50] setActive:YES];
37 [[showFlutterButton.widthAnchor constraintEqualToConstant:150] setActive:YES];
38
39 [_engine runWithEntrypoint:nil];
40}
41
42- (FlutterViewController*)showFlutter:(dispatch_block_t)showCompletion {
43 FlutterViewController* flutterVC = [[FlutterViewController alloc] initWithEngine:_engine
44 nibName:nil
45 bundle:nil];
46 [self presentViewController:flutterVC animated:NO completion:showCompletion];
47 return flutterVC;
48}
49
51 return _engine;
52}
53
54@end
FlutterEngine engine
Definition main.cc:68
fml::scoped_nsobject< FlutterEngine > _engine
const uintptr_t id