Q:

Flutter- Timeout occurred trying to load from AssetImage

I am trying to fetch color from image using palette_generator.  i am passing image to method to generate palette so i can fetch dominant color from it. but when  i try to fetch that palette color the error occurs as " Timeout occurred trying to load from AssetImage(bundle: null, name: "1.jpg") " and log cat shows " Unable to load asset: 1.jpg "
But that image is loading perfectly in the build method if i load the image using Image.asset().
NOTE - There is no issue of flutter asset folder linking
here is my code
Future<PaletteGenerator>_updatePaletteGenerator ()async
{
  paletteGenerator = await PaletteGenerator.fromImageProvider(
    Image.asset("1.jpg").image,
  );
return paletteGenerator;
}

this above method is used to generate palette
now here is my build method
 @override
  Widget build(BuildContext context) {

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("Image from assets"),
        ),
        body: Column (
            mainAxisAlignment: MainAxisAlignment.center,
              children:<Widget>[
                Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children:<Widget>[
                      new Image.asset('assets/images/6.jpg',
                        color: face, colorBlendMode:BlendMode.modulate ,
                        fit:BoxFit.cover,
                        height: 50,
                        width: 50,
                      ),

                new Image.asset('assets/images/1.jpg',
              color: face, colorBlendMode: BlendMode.modulate,
            fit:BoxFit.cover,
                  height: 200,
                  width: 200,
          ),]),

                FutureBuilder<PaletteGenerator>(
                  future: _updatePaletteGenerator(), // async work
                  builder: (BuildContext context, AsyncSnapshot<PaletteGenerator> snapshot) {
                    switch (snapshot.connectionState) {
                      case ConnectionState.waiting: return new Text('Loading....');
                      default:
                        if (snapshot.hasError)
                          return new Text('Error: ${snapshot.error}');
                        else
                          return new Text('Result: ${snapshot.data.dominantColor}');
                    }
                  },
                )

          //   <-- image
                ])),
    );
  }

Images are loading perfectly in build methods there is no such pubspec.yaml asset issue

A:

The problem is that at your _updatePaletteGenerator the path that you provide to Image.asset() is wrong. You have to give 'assets/images/1.jpg'

