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

Failed assertion: line 110 pos 12: '_positions.isNotEmpty' #198

Closed
dingzuhua opened this issue Apr 23, 2020 · 5 comments
Closed

Failed assertion: line 110 pos 12: '_positions.isNotEmpty' #198

dingzuhua opened this issue Apr 23, 2020 · 5 comments

Comments

@dingzuhua
Copy link

I have 5 pieces of data in my Swiper, I have an Index record of the current position, and when I delete the last item, I move the Index forward and delete the last item. This is when the error is reported.

flutter: The following assertion was thrown:
flutter: ScrollController not attached to any scroll views.
flutter: 'package:flutter/src/widgets/scroll_controller.dart':
flutter: Failed assertion: line 110 pos 12: '_positions.isNotEmpty'
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.

@dingzuhua
Copy link
Author

As a test, swiperlayout. DEFAULT appears when layout is selected

@weiminghuaa
Copy link

I only can use DEFAULT layout. This bug should be fixed, please do it.

@weiminghuaa
Copy link

If don't set index, it's ok!

@weiminghuaa
Copy link

weiminghuaa commented May 28, 2020

        Swiper(
            loop: false,
            itemBuilder: (BuildContext context, int index) {
              return Center(
                  child: Image.file(
                _imageList[index],
                fit: BoxFit.fill,
              ));
            },
            itemCount: _imageList.length,
            index: _index == widget.initialIndex ? _index : null,
            onIndexChanged: (index) {
              setState(() {
                _index = index;
              });
            },
         )

@amit-rawal
Copy link

    Swiper(
        loop: false,
        itemBuilder: (BuildContext context, int index) {
          return Center(
              child: Image.file(
            _imageList[index],
            fit: BoxFit.fill,
          ));
        },
        itemCount: _imageList.length,
        index: _index == widget.initialIndex ? _index : null,
        onIndexChanged: (index) {
          setState(() {
            _index = index;
          });
        },
     )

Working , thanks brother

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

No branches or pull requests

3 participants