Committed by
GitHub
bugifx: useInheritedMediaQuery 为 false 时,键盘可能覆盖输入框 (#487)
* bugifx: 某些情况下键盘无法弹起 * update readme
Showing
5 changed files
with
33 additions
and
30 deletions
| 1 | # flutter_screenutil | 1 | # flutter_screenutil |
| 2 | 2 | ||
| 3 | -[](https://pub.dev/packages/flutter_screenutil) | ||
| 4 | -[](https://pub.dev/packages/flutter_screenutil/score) | ||
| 5 | -[](https://pub.dev/packages/flutter_screenutil/score) | 3 | +[](https://pub.dev/packages/flutter_screenutil) |
| 4 | +[](https://pub.dev/packages/flutter_screenutil/score) | ||
| 5 | +[](https://pub.dev/packages/flutter_screenutil/score) | ||
| 6 | [](https://www.codefactor.io/repository/github/openflutter/flutter_screenutil) | 6 | [](https://www.codefactor.io/repository/github/openflutter/flutter_screenutil) |
| 7 | 7 | ||
| 8 | **A flutter plugin for adapting screen and font size.Let your UI display a reasonable layout on different screen sizes!** | 8 | **A flutter plugin for adapting screen and font size.Let your UI display a reasonable layout on different screen sizes!** |
| @@ -41,7 +41,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -41,7 +41,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 41 | ### Property | 41 | ### Property |
| 42 | 42 | ||
| 43 | | Property | Type | Default Value | Description | | 43 | | Property | Type | Default Value | Description | |
| 44 | -| --------------- |--------------|---------------|-----------------------------------------------------------------------------| | 44 | +| --------------- |--------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------| |
| 45 | | deviceSize | Size | null | The size of the physical device | | 45 | | deviceSize | Size | null | The size of the physical device | |
| 46 | | designSize | Size | Size(360,690) | The size of the device screen in the design draft, in dp | | 46 | | designSize | Size | Size(360,690) | The size of the device screen in the design draft, in dp | |
| 47 | | builder | Function | null | Return widget that uses the library in a property (ex: MaterialApp's theme) | | 47 | | builder | Function | null | Return widget that uses the library in a property (ex: MaterialApp's theme) | |
| @@ -51,7 +51,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | @@ -51,7 +51,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 51 | | splitScreenMode | bool | false | support for split screen | | 51 | | splitScreenMode | bool | false | support for split screen | |
| 52 | | minTextAdapt | bool | false | Whether to adapt the text according to the minimum of width and height | | 52 | | minTextAdapt | bool | false | Whether to adapt the text according to the minimum of width and height | |
| 53 | | context | BuildContext | null | Get physical device data if not provided, by MediaQuery.of(context) | | 53 | | context | BuildContext | null | Get physical device data if not provided, by MediaQuery.of(context) | |
| 54 | -| useInheritedMediaQuery | bool | true | Set this to true for Flutter 3.10 to avoid keyboard overlay on TextField | | 54 | +| useInheritedMediaQuery | bool | false | Recommended use `false` avoid rebuild very frequently <br/><br/> ~~Set this to true for Flutter 3.10 to avoid keyboard overlay on TextField~~ | |
| 55 | 55 | ||
| 56 | **Note : You must either provide builder, child or both.** | 56 | **Note : You must either provide builder, child or both.** |
| 57 | 57 |
| 1 | # flutter_screenutil | 1 | # flutter_screenutil |
| 2 | 2 | ||
| 3 | -[](https://pub.dartlang.org/packages/flutter_screenutil) | ||
| 4 | -[](https://pub.dev/packages/flutter_screenutil/score) | ||
| 5 | -[](https://pub.dev/packages/flutter_screenutil/score) | 3 | +[](https://pub.dev/packages/flutter_screenutil) |
| 4 | +[](https://pub.dev/packages/flutter_screenutil/score) | ||
| 5 | +[](https://pub.dev/packages/flutter_screenutil/score) | ||
| 6 | +[](https://www.codefactor.io/repository/github/openflutter/flutter_screenutil) | ||
| 6 | 7 | ||
| 7 | **flutter 屏幕适配方案,用于调整屏幕和字体大小的flutter插件,让你的UI在不同尺寸的屏幕上都能显示合理的布局!** | 8 | **flutter 屏幕适配方案,用于调整屏幕和字体大小的flutter插件,让你的UI在不同尺寸的屏幕上都能显示合理的布局!** |
| 8 | 9 |
| 1 | # I don’t speak Portuguese, and other developers have translated the first version. I later modified it based on the translation software. It is recommended to read the English/Chinese version. | 1 | # I don’t speak Portuguese, and other developers have translated the first version. I later modified it based on the translation software. It is recommended to read the English/Chinese version. |
| 2 | # flutter_screenutil | 2 | # flutter_screenutil |
| 3 | -[](https://pub.dartlang.org/packages/flutter_screenutil) | ||
| 4 | -[](https://pub.dev/packages/flutter_screenutil/score) | ||
| 5 | -[](https://pub.dev/packages/flutter_screenutil/score) | 3 | +[](https://pub.dev/packages/flutter_screenutil) |
| 4 | +[](https://pub.dev/packages/flutter_screenutil/score) | ||
| 5 | +[](https://pub.dev/packages/flutter_screenutil/score) | ||
| 6 | +[](https://www.codefactor.io/repository/github/openflutter/flutter_screenutil) | ||
| 6 | 7 | ||
| 7 | **Um plugin Flutter para adaptação de tamanho de tela e fontes. Deixe sua UI exibir um layout aceitável em diferentes tamanhos de tela!** | 8 | **Um plugin Flutter para adaptação de tamanho de tela e fontes. Deixe sua UI exibir um layout aceitável em diferentes tamanhos de tela!** |
| 8 | 9 |
| @@ -9,7 +9,7 @@ class MyApp extends StatelessWidget { | @@ -9,7 +9,7 @@ class MyApp extends StatelessWidget { | ||
| 9 | Widget build(BuildContext context) { | 9 | Widget build(BuildContext context) { |
| 10 | // In first method you only need to wrap [MaterialApp] with [ScreenUtilInit] and that's it | 10 | // In first method you only need to wrap [MaterialApp] with [ScreenUtilInit] and that's it |
| 11 | return ScreenUtilInit( | 11 | return ScreenUtilInit( |
| 12 | - useInheritedMediaQuery: true, | 12 | + useInheritedMediaQuery: false, |
| 13 | builder: (_, child) { | 13 | builder: (_, child) { |
| 14 | return MaterialApp( | 14 | return MaterialApp( |
| 15 | debugShowCheckedModeBanner: false, | 15 | debugShowCheckedModeBanner: false, |
| @@ -69,20 +69,14 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | @@ -69,20 +69,14 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | ||
| 69 | MediaQueryData get mediaQueryData => _mediaQueryData!; | 69 | MediaQueryData get mediaQueryData => _mediaQueryData!; |
| 70 | 70 | ||
| 71 | MediaQueryData get newData { | 71 | MediaQueryData get newData { |
| 72 | - if (widget.useInheritedMediaQuery) { | ||
| 73 | final data = MediaQuery.maybeOf(context); | 72 | final data = MediaQuery.maybeOf(context); |
| 74 | 73 | ||
| 75 | if (data != null) { | 74 | if (data != null) { |
| 75 | + if (widget.useInheritedMediaQuery) { | ||
| 76 | wrappedInMediaQuery = true; | 76 | wrappedInMediaQuery = true; |
| 77 | - return data; | ||
| 78 | } | 77 | } |
| 79 | - } else { | ||
| 80 | - final data = MediaQuery.maybeOf(context); | ||
| 81 | - | ||
| 82 | - if (data != null) { | ||
| 83 | return data; | 78 | return data; |
| 84 | } | 79 | } |
| 85 | - } | ||
| 86 | 80 | ||
| 87 | return MediaQueryData.fromView(View.of(context)); | 81 | return MediaQueryData.fromView(View.of(context)); |
| 88 | } | 82 | } |
| @@ -127,18 +121,21 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | @@ -127,18 +121,21 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | ||
| 127 | if (mediaQueryData.size == Size.zero) return const SizedBox.shrink(); | 121 | if (mediaQueryData.size == Size.zero) return const SizedBox.shrink(); |
| 128 | if (!wrappedInMediaQuery) { | 122 | if (!wrappedInMediaQuery) { |
| 129 | return MediaQuery( | 123 | return MediaQuery( |
| 130 | - // key: GlobalObjectKey('mediaQuery'), | ||
| 131 | data: mediaQueryData, | 124 | data: mediaQueryData, |
| 132 | child: Builder( | 125 | child: Builder( |
| 133 | builder: (__context) { | 126 | builder: (__context) { |
| 134 | - final deviceData = MediaQuery.maybeOf(__context); | ||
| 135 | - final deviceSize = deviceData?.size ?? widget.designSize; | ||
| 136 | - ScreenUtil.init(__context, | 127 | + ScreenUtil.init( |
| 128 | + __context, | ||
| 137 | designSize: widget.designSize, | 129 | designSize: widget.designSize, |
| 138 | splitScreenMode: widget.splitScreenMode, | 130 | splitScreenMode: widget.splitScreenMode, |
| 139 | minTextAdapt: widget.minTextAdapt, | 131 | minTextAdapt: widget.minTextAdapt, |
| 140 | - scaleByHeight: widget.scaleByHeight); | ||
| 141 | - return Container( | 132 | + scaleByHeight: widget.scaleByHeight, |
| 133 | + ); | ||
| 134 | + final deviceData = MediaQuery.maybeOf(__context); | ||
| 135 | + final deviceSize = deviceData?.size ?? widget.designSize; | ||
| 136 | + return MediaQuery( | ||
| 137 | + data: MediaQueryData.fromView(View.of(__context)), | ||
| 138 | + child: Container( | ||
| 142 | width: deviceSize.width, | 139 | width: deviceSize.width, |
| 143 | height: deviceSize.height, | 140 | height: deviceSize.height, |
| 144 | child: FittedBox( | 141 | child: FittedBox( |
| @@ -152,19 +149,22 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | @@ -152,19 +149,22 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | ||
| 152 | height: deviceSize.height, | 149 | height: deviceSize.height, |
| 153 | child: widget.builder(__context, widget.child), | 150 | child: widget.builder(__context, widget.child), |
| 154 | ), | 151 | ), |
| 155 | - )); | 152 | + ), |
| 153 | + ), | ||
| 154 | + ); | ||
| 156 | }, | 155 | }, |
| 157 | ), | 156 | ), |
| 158 | ); | 157 | ); |
| 159 | } | 158 | } |
| 160 | 159 | ||
| 161 | - ScreenUtil.init(_context, | 160 | + ScreenUtil.init( |
| 161 | + _context, | ||
| 162 | designSize: widget.designSize, | 162 | designSize: widget.designSize, |
| 163 | splitScreenMode: widget.splitScreenMode, | 163 | splitScreenMode: widget.splitScreenMode, |
| 164 | minTextAdapt: widget.minTextAdapt, | 164 | minTextAdapt: widget.minTextAdapt, |
| 165 | - scaleByHeight: widget.scaleByHeight); | 165 | + scaleByHeight: widget.scaleByHeight, |
| 166 | + ); | ||
| 166 | final deviceData = MediaQuery.maybeOf(_context); | 167 | final deviceData = MediaQuery.maybeOf(_context); |
| 167 | - | ||
| 168 | final deviceSize = deviceData?.size ?? widget.designSize; | 168 | final deviceSize = deviceData?.size ?? widget.designSize; |
| 169 | return Container( | 169 | return Container( |
| 170 | width: deviceSize.width, | 170 | width: deviceSize.width, |
| @@ -180,6 +180,7 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | @@ -180,6 +180,7 @@ class _ScreenUtilInitState extends State<ScreenUtilInit> | ||
| 180 | height: deviceSize.height, | 180 | height: deviceSize.height, |
| 181 | child: widget.builder(_context, widget.child), | 181 | child: widget.builder(_context, widget.child), |
| 182 | ), | 182 | ), |
| 183 | - )); | 183 | + ), |
| 184 | + ); | ||
| 184 | } | 185 | } |
| 185 | } | 186 | } |
-
Please register or login to post a comment