Home > Mobile >  Unable to load asset images
Unable to load asset images

Time:09-30

 @override
Widget build(BuildContext context) {
 return Scaffold(
    body: SafeArea(
        child: Row(
  children: [
    Expanded(
      //il flex è di default quindi prende 1/6 della pagina
      child: Column(
        children: [
          DrawerHeader(child: Image.asset("assets\images\logo.png"))
        ],
      ),
    ),
    Expanded(
      //prende 5/6 della pagina
      flex: 5,
      child: Container(
        color: Colors.blue,
      ),
    ),
  ],
)));
 }

// This is my code as you can see I have entered everything right, only that in the terminal on output it does not give me any kind of error while if I load the google page, I get the error I wrote in the title now I am attaching the screenshot of the page.

error of images //I also checked the pubspec.yamal but theoretically it is right I also leave you the one below

pubspec.yamal

assets: - assets/images/ - assets/icons/

//now I am also attaching the screenshot of the folders

folders

CodePudding user response:

You should use / instead of \ when you enter the path for image.

@override
Widget build(BuildContext context) {
 return Scaffold(
    body: SafeArea(
        child: Row(
  children: [
    Expanded(
      //il flex è di default quindi prende 1/6 della pagina
      child: Column(
        children: [
          DrawerHeader(child: Image.asset("assets/images/logo.png"))
        ],
      ),
    ),
    Expanded(
      //prende 5/6 della pagina
      flex: 5,
      child: Container(
        color: Colors.blue,
      ),
    ),
  ],
)));
 }
  • Related