Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing null check operator in nextPage, previousPage with null aware operator #417

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AhmedAbogameel
Copy link

@AhmedAbogameel AhmedAbogameel commented Aug 27, 2023

We faced this bug in our release

CarouselControllerImpl.nextPage
FlutterError - Null check operator used on a null value 

so i handled it by replacing all null check operator inside nextPage and previousPage functions with null aware operator

@AhmedAbogameel AhmedAbogameel changed the title handle null check operator in nextPage, previousPage Replacing null check operator in nextPage, previousPage with null aware operator Aug 27, 2023
@mohamed-foly
Copy link

@serenader2014 Please check this

@antonderevyanko
Copy link

Also faced issue
Null check operator used on a null value
is there a solution for this problem?

@nain93
Copy link

nain93 commented Mar 7, 2024

Declare final at the top and use it outside of the rendered widget

final CarouselController carouselController = CarouselController();  <- here

class CarouselDemo extends StatelessWidget {
/// CarouselController carouselController = CarouselController(); <- not here

 @override
  Widget build(BuildContext context) => Column(
    children: <Widget>[
      CarouselSlider(
        items: child,
        carouselController: carouselController,
        options: CarouselOptions(
          autoPlay: false,
          enlargeCenterPage: true,
          viewportFraction: 0.9,
          aspectRatio: 2.0,
          initialPage: 2,
        ),
      ),
      RaisedButton(
        onPressed: () => carouselController.nextPage(
            duration: Duration(milliseconds: 300), curve: Curves.linear),
        child: Text('→'),
      )
    ]
  );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants