OpenFlutter / flutter_screenutil

Flutter screen adaptation, font adaptation, get screen information
https://pub.dartlang.org/packages/flutter_screenutil
Apache License 2.0
3.88k stars 494 forks source link

BottomSheet Keyboard issue when used ScreenUtil in ThemeData #338

Closed parmarravi closed 2 years ago

parmarravi commented 2 years ago

I have a project with a getx and ScreenUtil

When I add a custom theme data which has different text size and border radius that are imported from screen util
The project works but when a bottom sheet dialog is loaded that have TextFormField the bottom sheet does not resize due to the Media Query that is added in main file.

After 5.0.3 v things get break!!

environment: sdk: ">=2.16.0 <3.0.0"

version get: ^4.6.1 flutter_screenutil: ^5.1.1

Sample Code

return MediaQuery(
      data: MediaQueryData.fromWindow(WidgetsBinding.instance!.window), // when removed the bottom sheet resize works 
      child: ScreenUtilInit(
        designSize: const Size(384, 806),
        builder: () => GetMaterialApp(
          title: 'Sample',
          debugShowCheckedModeBanner: false,
          useInheritedMediaQuery: true,
          builder: (context, widget) {
            ScreenUtil.setContext(context);
            return MediaQuery(
              //Setting font does not change with system font size
              data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
              child: widget!,
            );
          },
          theme: ThemeData(
            primarySwatch: Colors.green,
            textTheme: TextTheme(button: TextStyle(fontSize: 45.sp)),
          ),
          initialRoute: "/",
          enableLog: true,
          getPages: [
            GetPage(
              name: "/",
              page: () => const HomeScreen(),
            ),
          ],
        ),
      ),
    );
  }

Flutter doctor

[✓] Flutter (Channel stable, 2.10.0, on macOS 12.1 21C52 darwin-arm, locale en-IN) • Flutter version 2.10.0 at /Users/raviparmar/Documents/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5f105a6ca7 (8 days ago), 2022-02-01 14:15:42 -0800 • Engine revision 776efd2034 • Dart version 2.16.0 • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at /Users/raviparmar/Library/Android/sdk • Platform android-32, build-tools 32.0.0 • ANDROID_HOME = /Users/raviparmar/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] VS Code (version 1.63.2) • VS Code at /Users/raviparmar/Downloads/Visual Studio Code.app/Contents • Flutter extension version 3.34.0

[✓] Connected device (2 available) • HD1901 (mobile) • 6578118d • android-arm64 • Android 11 (API 30) • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability • All required HTTP hosts are available

• No issues found!