[英]Why is flutter unable to load asset image?
No errors in the code and as far as I can see the pubspec.yaml file is functional, as it worked before.代码中没有错误,据我所知,pubspec.yaml 文件可以正常工作,就像以前一样。
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SafeArea(
child: Column(
children: [
Card(
child: Image.asset('anyaparent.jpeg'),
),
],
),
),
),
);
try doing like this尝试这样做
Image.asset('images/anyaparent.jpeg'),
Check your image path images/anyaparent.jpeg
检查您的图像
path images/anyaparent.jpeg
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SafeArea(
child: Column(
children: [
Card(
child: Image.asset('images/anyaparent.jpeg'),
),
],
),
),
),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.