The argument type 'Container Function(BuildContext, int)' can't be assigned to the parameter type 'Widget Function(BuildContext, int, int)'

3,444

Solution 1

Looks like you need an extra int parameter. You can use '_' if you don't need to use it.

Solution 2

use (BuildContext context, int index, _)

Share:
3,444
SOS video
Author by

SOS video

Updated on December 27, 2022

Comments

  • SOS video
    SOS video over 1 year

    I try to use CarousellSlider.builder, but I get an error. I used the code from the example on the pub.dev page (https://pub.dev/packages/carousel_slider). I get the error on the line (itemBuilder: (BuildContext context, int itemIndex) => Container().

    The error message is: The argument type 'Container Function(BuildContext, int)' can't be assigned to the parameter type 'Widget Function(BuildContext, int, int)'.

    This is my code:

    CarouselSlider.builder(
      itemCount: motivationImages.length,
      itemBuilder: (BuildContext context, int index) {
           Container();
        }
        options: CarouselOptions(
          height: 300,
        ),
    ),
    
    • Shubhamhackz
      Shubhamhackz about 3 years
      Can you share full code of CarouselSlider
    • SOS video
      SOS video about 3 years
      Sorry, i forgot. I've added it now!
  • MwBakker
    MwBakker about 2 years
    what is the purpose of that integer?