Flutter 之 页面启动黑屏

现象:打开Flutter对应的Activity(io.flutter.app.FlutterFragmentActivity),因为第一次渲染慢,会闪一下黑屏

解决方案:

AndroidManifest添加meta-data


代码如下:


            
        

IOS同理

代码如下:

#pragma mark - life cycle
- (instancetype)init {
    self = [super init];
    if (self) {
        UIView *view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
        view.backgroundColor = [UIColor whiteColor];
        self.splashScreenView = view;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    if (self.navigationController) {
        [self.navigationController setNavigationBarHidden:YES animated:YES];
    }
}

@end

你可能感兴趣的:(Flutter 之 页面启动黑屏)