'SystemChrome' 未在 Flutter 中定义
'SystemChrome' not defined in Flutter
我是 Flutter 的新手,我想更改我的应用程序的状态栏颜色。经过一番谷歌搜索后,我找到了一种方法。就是在我的main
函数中加入如下代码
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.white
));
但在添加它和 运行 我的应用程序后,我收到以下错误:-
Compiler message:
lib/main.dart:15:40: Error: Method not found: 'SystemUiOverlayStyle'.
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
^^^^^^^^^^^^^^^^^^^^
lib/main.dart:15:3: Error: Getter not found: 'SystemChrome'.
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
^^^^^^^^^^^^
请告诉我问题是什么。
提前致谢!
我的main
函数:-
void main() {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.white
));
runApp(WilliamClient());
}
我的pubspec.yaml
文件:-
name: william_client
description: Client App for William Assistant and TV.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
firebase_auth: 0.8.4+5
cloud_firestore: 0.10.1
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
fonts:
- family: Montserrat
fonts:
- asset: fonts/Montserrat.ttf
- family: MontserratLight
fonts:
- asset: fonts/Montserrat-Light.ttf
- family: RobotoMono
fonts:
- asset: fonts/RobotoMono.ttf
你应该添加
import 'package:flutter/services.dart';
我是 Flutter 的新手,我想更改我的应用程序的状态栏颜色。经过一番谷歌搜索后,我找到了一种方法。就是在我的main
函数中加入如下代码
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.white
));
但在添加它和 运行 我的应用程序后,我收到以下错误:-
Compiler message:
lib/main.dart:15:40: Error: Method not found: 'SystemUiOverlayStyle'.
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
^^^^^^^^^^^^^^^^^^^^
lib/main.dart:15:3: Error: Getter not found: 'SystemChrome'.
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
^^^^^^^^^^^^
请告诉我问题是什么。 提前致谢!
我的main
函数:-
void main() {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.white
));
runApp(WilliamClient());
}
我的pubspec.yaml
文件:-
name: william_client
description: Client App for William Assistant and TV.
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
firebase_auth: 0.8.4+5
cloud_firestore: 0.10.1
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
fonts:
- family: Montserrat
fonts:
- asset: fonts/Montserrat.ttf
- family: MontserratLight
fonts:
- asset: fonts/Montserrat-Light.ttf
- family: RobotoMono
fonts:
- asset: fonts/RobotoMono.ttf
你应该添加
import 'package:flutter/services.dart';