0

so i want 3 different images on this code


body: Container(
        height: MediaQuery.of(context).size.height / 2,
        width: MediaQuery.of(context).size.width,
        child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Swiper(
              itemBuilder: (BuildContext context, int index) {
                return Image.network(
                  "https://github.com/jzoom/images/raw/master/swiper-example.gif",
                  fit: BoxFit.fill,
                );
              },
              itemCount: 3,
              viewportFraction: 0.9,
              scale: 0.9,
            )),
      ),

i want 3 images within use of one method.

3
  • You can’t add multiple images inside one Image.network image. Do you have a list of urls to images you want to show? Commented Jul 12, 2023 at 9:00
  • yes, i can use any three just help me this , atleast just make a template that works with this code , i will fill the links by myself Commented Jul 12, 2023 at 9:10
  • Check out the answer from VivekChib. Commented Jul 12, 2023 at 9:21

1 Answer 1

2
  1. Create a list of images (replace "" with your URLs)

    List<String> _images = ["","",""];

  2. Now make these changes in your swiper widget:

    2.1 return Image.network(_images[index]);

    2.1 itemCount: _images.length

Sign up to request clarification or add additional context in comments.

2 Comments

return Image.network(_images[index]); what to add inside[index]
the index is from itemBuilder: (BuildContext context, int index) leave it as it is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.