如何在Flutter 3.10.0中获得键盘高度?

ylamdve6  于 2023-05-19  发布在  Flutter
关注(0)|答案(1)|浏览(301)

我以前知道MediaQuery.of(context).viewInsets.bottom是Flutter中获取键盘高度的代码。然而,在我今天早上将Flutter的版本从3.7.1升级到3.10.0和Dart 3.0.0之后,我检查了这些代码不再给予我键盘的高度。仅显示0。我研究了一下,发现有一个View.of(context).viewInsets.bottom代码,并尝试了一下。但给予我的结果似乎不是键盘的高度。在Flutter 3.10.0中获取键盘高度是否有变化?下面是我的pc中flutter doctor -v的结果。

[✓] Flutter (Channel stable, 3.10.0, on macOS 13.3.1 22E261 darwin-arm64, locale ko-KR)
    • Flutter version 3.10.0 on channel stable at /Users/daehyeon/Documents/flutter-dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 84a1e904f4 (2일 전), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9
    • Dart version 3.0.0
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/daehyeon/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.0

[✓] Android Studio (version 2022.2)
    • 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 17.0.6+0-17.0.6b802.4-9586694)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 73.0.3
    • Dart plugin version 223.8888

[✓] VS Code (version 1.78.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.64.0

[✓] Connected device (2 available)
    • 회사 iphone (mobile) • 00008101-000909362681001E            • ios • iOS 16.4.1 20E252
    • iPhone 14 (mobile) • DC9CA49D-A287-4843-83FF-D826BC6F6F04 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
nbewdwxp

nbewdwxp1#

ScreenUtilInit(
      useInheritedMediaQuery: true,
      designSize: const Size(376, 812),
      builder: (context, child) {
        return const Scaffold(
          resizeToAvoidBottomInset: false,
          body: Column(
            children: [
              Spacer(),
              TextField(),
            ],
          ),
        );
      },
    );

相关问题