| 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
5 #import "flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h"
6
7 #include "flutter/fml/logging.h"
8
9 @implementation UIViewController (FlutterScreenAndSceneIfLoaded)
10
11 - (UIWindowScene*)flutterWindowSceneIfViewLoaded {
12 if (self.viewIfLoaded == nil) {
13 FML_LOG(WARNING) << "Trying to access the window scene before the view is loaded.";
14 return nil;
15 }
16 return self.viewIfLoaded.window.windowScene;
17 }
18
19 - (UIScreen*)flutterScreenIfViewLoaded {
20 if (@available(iOS 13.0, *)) {
21 if (self.viewIfLoaded == nil) {
22 FML_LOG(WARNING) << "Trying to access the screen before the view is loaded.";
23 return nil;
24 }
25 return [self flutterWindowSceneIfViewLoaded].screen;
26 }
27 return UIScreen.mainScreen;
28 }
29
30 @end
UIViewController(FlutterScreenAndSceneIfLoaded)
Definition: UIViewController+FlutterScreenAndSceneIfLoaded.h:10
UIViewController+FlutterScreenAndSceneIfLoaded.h