Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 08bc69a

Browse files
committed
fix build issue by moving flutterScreenIfViewLoaded
1 parent bf26c49 commit 08bc69a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,13 @@ FLUTTER_DARWIN_EXPORT
164164
- (instancetype)initWithOwner:(FlutterTextInputPlugin*)textInputPlugin NS_DESIGNATED_INITIALIZER;
165165

166166
@end
167+
168+
@interface UIViewController (FlutterScreenAndSceneIfLoaded)
169+
170+
/// Before iOS 13, returns the main screen; After iOS 13, returns the screen the UIViewController is
171+
/// attached to if its view is loaded, and nil otherwise.
172+
- (UIScreen*)flutterScreenIfViewLoaded;
173+
174+
@end
175+
167176
#endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTPLUGIN_H_

shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,3 +2762,26 @@ - (BOOL)handlePress:(nonnull FlutterUIPressProxy*)press API_AVAILABLE(ios(13.4))
27622762
return NO;
27632763
}
27642764
@end
2765+
2766+
@implementation UIViewController (FlutterScreenAndSceneIfLoaded)
2767+
2768+
- (UIWindowScene*)flutterWindowSceneIfViewLoaded {
2769+
if (self.viewIfLoaded == nil) {
2770+
FML_LOG(WARNING) << "Trying to access the window scene before the view is loaded.";
2771+
return nil;
2772+
}
2773+
return self.viewIfLoaded.window.windowScene;
2774+
}
2775+
2776+
- (UIScreen*)flutterScreenIfViewLoaded {
2777+
if (@available(iOS 13.0, *)) {
2778+
if (self.viewIfLoaded == nil) {
2779+
FML_LOG(WARNING) << "Trying to access the screen before the view is loaded.";
2780+
return nil;
2781+
}
2782+
return [self flutterWindowSceneIfViewLoaded].screen;
2783+
}
2784+
return UIScreen.mainScreen;
2785+
}
2786+
2787+
@end

0 commit comments

Comments
 (0)