skip to Main Content

attached image for reference 1

i am new to flutter looking for suggestions. Can anybody suggest how can i achieve this kind of design in flutter. Any suggestions would be appreciated.I think i need to implement grid view inside CarouselSlider.
any codesnippets for this design would be appreciated

2

Answers


  1. Column(
                children: [
     Container(
                          child: CarouselSlider.builder(
                          itemCount: {ur_array}.length,
                          options: CarouselOptions(
                            autoPlay: true,
                            aspectRatio: 4.0,
                            enlargeCenterPage: true,
                          ),
                          itemBuilder: (context, index, i) {
                            return InkWell(
                              onTap: () {
                   
                              },
                              child: ClipRRect(
                                borderRadius: BorderRadius.circular(15.0),
                                child: Container(
                                  child: Center(
                                      child: Image.network(
                                          {imageurlyouwanttoshow},
                                          fit: BoxFit.cover,
                                          width: 1000)),
                                ),
                              ),
                            );
                          },
                        )),
                  Flexible(
                    child: GridView.builder(
                      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                          crossAxisCount: 2,
                          crossAxisSpacing: 6.0,
                          mainAxisSpacing: 6.0),
                      itemCount: controller.datas.length,
                      itemBuilder: (context, i) {
                        return InkWell(
                          child: ClipRRect(
                            borderRadius: BorderRadius.all(Radius.circular(10.0)),
                            child: ImageCacheing(url: controller.datas[i].imgurl!),
                          ),
                        );
                      },
                    ),
                  ),
                ],
              ),
    Login or Signup to reply.
  2. Are you using the carousel_slider library? If so, here’s an example:

    import 'package:carousel_slider/carousel_slider.dart';
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return const MaterialApp(
          home: HomePage(),
        );
      }
    }
    
    class HomePage extends StatelessWidget {
      const HomePage({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(),
          body: CarouselSlider(
            options: CarouselOptions(
              viewportFraction: 1,
              height: 300,
            ),
            items: [
              GridView(
                padding: const EdgeInsets.all(8),
                gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                  crossAxisCount: 3,
                  mainAxisSpacing: 5,
                  crossAxisSpacing: 5,
                ),
                children: List.generate(
                  6,
                  (index) => Container(
                    color: Colors.grey,
                    alignment: Alignment.center,
                    child: Text('Item $index'),
                  ),
                ),
              ),
              Container(
                color: Colors.orange,
              ),
            ],
          ),
        );
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search