flutter - 如何修复这个颤振错误'package:flutter/scr/painting/image_resolution.dart''assetName!= null'不正确
问题描述
我还是 Flutter 的新手。我的代码一切都很好,但是每当我尝试启动该应用程序时,它总是在屏幕上出现这种错误。所以这是来自 main.dart 错误:“package:flutter/src/painting/image_resolution.dart”断言失败:fline 134 pos 15assetName != null' is not true
import 'package:autibuddyapp/Notification.dart';
import 'package:autibuddyapp/profile.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:autibuddyapp/griddashboard.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>{
final pages = [Notify(), MyHomePage() ,Profile(),] ;
var mypages = 1;
@override
Widget build(BuildContext context) {
String greeting() {
var hour = DateTime.now().hour;
if (hour < 12) {
return 'Good Morning Buddy';
} if (hour < 15) {
return 'Good Aftenoon Buddy';
} if (hour < 19) {
return 'Good Evening Buddy';
}
return
'Good Night Buddy, time to get some sleep';
}
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.purple,
title: Text("Auti Buddy", style: TextStyle(
color: Colors.black
),),
),
body: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/buddy.png"),fit: BoxFit.fill),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Good Morning Buddy',
semanticsLabel: greeting(),
style: TextStyle(
fontSize: 30.0,
color: Colors.black,
),
),
SizedBox(
height: 60,
),
Padding(
padding: EdgeInsets.only(left: 16, right: 16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Welcome!",
style: GoogleFonts.cairo(
textStyle: TextStyle(
color: Colors.black54,
fontSize: 26,
fontWeight: FontWeight.bold)),
),
SizedBox(
height: 4,
),
Text(
"Home",
style: GoogleFonts.openSans(
textStyle: TextStyle(
color: Color(0xffa29aac),
fontSize: 16,
fontWeight: FontWeight.w600)),
),
],
),
],
),
),
SizedBox(
height: 40,
),
GridDashboard()
],
),
),
),
bottomNavigationBar: CurvedNavigationBar(
index : 1,
color: Colors.purple,
backgroundColor: Colors.white,
buttonBackgroundColor: Colors.purpleAccent,
height: 50,
animationDuration: Duration (
milliseconds: 200
),
animationCurve: Curves.bounceInOut,
onTap: (index){
setState(() {
mypages = index;
});
},
items:<Widget>[
Icon(Icons.notifications_none,size: 20, color: Colors.black,),
Icon(Icons.home,size: 20, color: Colors.black),
Icon(Icons.account_circle,size: 20, color: Colors.black,),
],
),
);
解决方案
推荐阅读
- java - 身份核心迁移到 Java
- c++ - 使用类模板需要模板参数列表 c++ Visual Studios
- python - 代码显示类型错误必须是 str,而不是 int
- python - Error on Connect Selenium Driver to an Existing Chrome Browser Instance
- mysql - MySQL 前 10 天的普通价格与当前价格 - MySQL 性能改进
- math - 累积同质变换:旋转有效,但平移无效?
- python - 我必须为每个 Kivy Screen 创建一个新类吗?如果是这样,为什么?
- tensorflow - Tensorflow或通用神经网络:我的一个损失太高了!(损失 = u + v)
- python - 无法确定我的扫描脚本将输入视为字符串而不是预期的列表。谁能解释一下?
- python - R中是否有与Kde2d函数等效的python函数,它以x、y和z的形式返回相同的输出?