Flutter iOS Embedder
UIViewController+FlutterScreenAndSceneIfLoaded.mm
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 #include "flutter/fml/logging.h"
9 
11 
13 
14 - (UIWindowScene*)flutterWindowSceneIfViewLoaded {
15  if (self.viewIfLoaded == nil) {
16  FML_LOG(WARNING) << "Trying to access the window scene before the view is loaded.";
17  return nil;
18  }
19  return self.viewIfLoaded.window.windowScene;
20 }
21 
22 - (UIScreen*)flutterScreenIfViewLoaded {
23  if (@available(iOS 13.0, *)) {
24  if (self.viewIfLoaded == nil) {
25  FML_LOG(WARNING) << "Trying to access the screen before the view is loaded.";
26  return nil;
27  }
28  return [self flutterWindowSceneIfViewLoaded].screen;
29  }
30  return UIScreen.mainScreen;
31 }
32 
33 @end
FlutterMacros.h
UIViewController(FlutterScreenAndSceneIfLoaded)
Definition: UIViewController+FlutterScreenAndSceneIfLoaded.h:10
UIViewController+FlutterScreenAndSceneIfLoaded.h
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13