skip to Main Content

how to make section 1 carousel horizontal and section 2 listview builder vertical with infintescroll flutter

enter image description here

I try using API and want create example news app there is a problem when combining with columns, horizontal and vertical and infinitescroll

2

Answers


  1. Chosen as BEST ANSWER

    problem, is section 2 using listview builder vertical with infinite scroll not working, can make infinite scroll Is it possible in one page?


  2. You can use the flutter_carousel_widget: package. Documentation for this package https://pub.dev/packages/flutter_carousel_widget

    You can also review my code as an example. (I didn’t bother with the design, I just wanted to show you what it looks like when it works)

    Example:

    Column(
              children: <Widget>[
                FlutterCarousel(
                  options: CarouselOptions(
                    height: 200.0,
                    scrollDirection: Axis.horizontal,
                    showIndicator: true,
                    slideIndicator: CircularSlideIndicator(),
                  ),
                  items: [1, 2, 3, 4, 5].map((i) {
                    return Builder(
                      builder: (BuildContext context) {
                        return Container(
                            width: MediaQuery.of(context).size.width,
                            margin: EdgeInsets.symmetric(horizontal: 5.0),
                            decoration: BoxDecoration(color: Colors.amber),
                            child: Text(
                              'text $i',
                              style: TextStyle(fontSize: 16.0),
                            ));
                      },
                    );
                  }).toList(),
                ),
                Text("Just Another News"),
                Container(
                  height: 300,
                  child: FlutterCarousel(
                    options: CarouselOptions(
                      autoPlay: true,
                      scrollDirection: Axis.vertical,
                      autoPlayInterval: const Duration(seconds: 2),
                    ),
                    items: [1,2,3,4,5].map((i) {
                      return Builder(
                        builder: (BuildContext context) {
                          return Container(
                              width: MediaQuery.of(context).size.width,
                              child: Image.network('https://images.unsplash.com/photo-1575936123452-b67c3203c357?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8aW1hZ2V8ZW58MHx8MHx8fDA%3D&w=1000&q=80')
                          );
                        },
                      );
                    }).toList(),
                  ),
                )
              ],
            )
    

    Output:

    enter image description here

    I hope I have helped.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search