未找到方法:'SystemChrome.setEnabledSystemUIMode'



今天,当我在macOS Big Sur中编译flutter项目时,告诉错误消息如下:

lib/pages/video/page_music_video_player_fullscreen.dart:27:18: Error: Method not found: 'SystemChrome.setEnabledSystemUIMode'.
SystemChrome.setEnabledSystemUIMode(SystemUiMode.leanBack, overlays: const [
^^^^^^^^^^^^^^^^^^^^^^
lib/pages/video/page_music_video_player_fullscreen.dart:63:24: Error: Method not found: 'SystemChrome.setEnabledSystemUIMode'.
SystemChrome.setEnabledSystemUIMode(SystemUiMode.leanBack,
^^^^^^^^^^^^^^^^^^^^^^
lib/pages/video/page_music_video_player_fullscreen.dart:69:24: Error: Method not found: 'SystemChrome.setEnabledSystemUIMode'.
SystemChrome.setEnabledSystemUIMode(

为什么会发生这种情况?有可能解决这个问题吗?这是flutter版本信息:

$ ~/apps/flutter/bin/flutter doctor                                                                                                         ‹ruby-2.7.2›
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.2.3 20D91 darwin-x64, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio (version 2020.3)
✗ Unable to find bundled Java version.
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.2)
[✓] VS Code (version 1.60.2)
[✓] Connected device (3 available)
! Error: xiaoqiang 的 iPhone is not connected. Xcode will continue when xiaoqiang 的 iPhone is connected. (code -13)
! Doctor found issues in 1 category.
(base)

我有同样的问题,首先解释这个问题:你正在使用一些插件,使用flutter 2.5。X或更高在新颤振模型中加入了SystemChrome.setEnabledSystemUIMode方法等新特性。更新到flutter 2.5。

最新更新