flutter_carousel_slider icon indicating copy to clipboard operation
flutter_carousel_slider copied to clipboard

The itemBuilder Runs when itemCount is zero

Open omidraha opened this issue 3 years ago • 1 comments

The itemBuilder Runs when itemCount is zero

import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: SafeArea(
        child: Scaffold(
          body: CarouselSlider.builder(
            itemCount: 0,
            itemBuilder:
                (BuildContext context, int sliderIndex, int realIndex) {
              return Center(
                child: Container(
                  child: Text('Why ??'),
                ),
              );
            },
            options: CarouselOptions(),
          ),
        ),
      ),
    );
  }
}

omidraha avatar Apr 16 '21 05:04 omidraha

It is due to the code found in this file https://github.com/serenader2014/flutter_carousel_slider/blob/master/lib/carousel_slider.dart is what I think.

I don't know you could try setting the value to -1, maybe it could solve, I am not sure.

prateekmedia avatar Apr 27 '21 16:04 prateekmedia