首页 > 解决方案 > 即使使用小部件图像也可以加载图像

问题描述

错误是这样的

无法获取文件状态"C:\Users\gio\Desktop\flutter\TodoAppV2\assets\Magic_Menu_Image.webp": file not found.

但我无法加载它。下面是我的代码。

主要飞镖:

Widget build(BuildContext context) {
return Scaffold(
  appBar: AppBar(
    title: Text('Home'),
  ),
  drawer: Drawer(
    child: ListView(
      padding: EdgeInsets.all(0),
      children: <Widget>[
        DrawerHeader(
          child: null,//Image.asset('assets/Magic_Menu_Image.jpg'),
          decoration: BoxDecoration(color: Colors.black),
        ),
        ListTile(
          title: Container(
            color: Colors.orange[900],
            child: Row(
              children: <Widget>[
                Icon(
                  Icons.home,
                  size: 30,
                ),
                Text(
                  'Home',
                  style: TextStyle(fontSize: 20,),
                )
              ]
            )
          ),
        )
      ]
    )
  ),
);

} }

并且不在 pubspec.yaml 文件中:

flutter:
  assets:
    - assets/Magic_Menu_Image.jpg

如果有人可以帮助解决此错误。

标签: flutter

解决方案


推荐阅读