-1

i am tring to add images in carousel flutter and i make a list of images from my assets but i am facing this error.

ArgumentError (Invalid argument(s): No host specified in URI file:///home/zr/untitled%20folder/snap/flutter/PROJECTS/nic/nic/assets/images/ataltunel.jpg)

note: (i dont't want to load images from network) please give some ideas to solve it.

this is the code....!!!!!

body: Container(
            child: Column(
              children: [
                CarouselSlider(
                  options: CarouselOptions(
                      height: 170.0, autoPlay: true, enlargeCenterPage: true),
                  items: _slideimages.map((i) {
                    return Builder(
                      builder: (BuildContext context) {
                        return Container(
                          width: MediaQuery.of(context).size.width,
                          child: Image.network(i),
                        );
                      },
                    );
                  }).toList(),
                ),
              ],
            ),
          ),
Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
Zeher
  • 15
  • 4

3 Answers3

0

if you using images from asset then use Image.asset("path"); or you using image file then you can use Image.file("file path");

0

You need to use Image.asset to load from assets.

child: Image.network(i), /// make sure to provide current path.

Make sure to add on pubspec.yaml file. Find more about assets-and-images .

Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
  • Thanks God I find You bro, I need help bro. I stuck on this issue, Kindly help me on this [https://stackoverflow.com/questions/75831070/flutter-how-to-swipe-button-on-both-direction] – For Stack Mar 26 '23 at 08:41
0

If you dont't want to load images from network, then try loading the images from local assets, for which create a folder /assests and include that in your pubspec.yml file and run pub get command and once done add those images in _slideimages list and use it. use Image.assert(i)

Kothai
  • 115
  • 1
  • 6