[英]prefer const with constant constructor
I have an error that shows this message "prefer const with constant constructor" when i deleting const on below class splashscreen theres not showing any error but throwing当我在 class 下面删除 const 时,我有一个错误显示此消息“prefer const with constant constructor” splashscreen 没有显示任何错误但抛出
heres my code这是我的代码
const SplashScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
child: Image.network(
"https://cdn.kibrispdr.org/data/white-background-hd-0.jpg"),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 50),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
"name",
height: 50,
),
SizedBox(
height: 18,
),
Row(
children: <Widget>[
Text(
"Management",
style: TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w800),
),
],
) //Image Asset untuk logo splashscreen
],
),
)
can someone help with this error really appreciate your help.有人可以帮助解决这个错误真的很感谢你的帮助。
This is not really an error, it's just an info message.这并不是真正的错误,它只是一条信息消息。 This message comes from the
flutter_lints
package that tells you the recommended best practices.此消息来自
flutter_lints
package,告诉您推荐的最佳实践。
You can learn more about const
in Dart from here .您可以从此处在Dart中了解有关
const
的更多信息。
If you want to disable linting then go to the analysis_options.yaml
file (present inside the root directory of your Flutter project) and comment out the line:如果你想禁用 linting 然后 go 到
analysis_options.yaml
文件(存在于你的 Flutter 项目的根目录中)并注释掉该行:
include: package:flutter_lints/flutter.yaml
But keep in mind this is not recommended.但请记住,不建议这样做。
To prefer const with constant constructors更喜欢使用常量构造函数的 const
Go to analaysis_options.yaml file in your Flutter project folder, then under rules title type Prefer_const_constructors: false Prefer_const_literals_to_create_immutables: false Then save it Tip: Type it not copy it Go 到 Flutter 项目文件夹中的 analaysis_options.yaml 文件,然后在规则标题下键入 Prefer_const_constructors: false Prefer_const_literals_to_create_immutables: false 然后保存 提示:键入它而不是复制它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.