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

Working with PageController - doesn't reset to initalpage #70

Open
timow512 opened this issue Jun 7, 2021 · 0 comments
Open

Working with PageController - doesn't reset to initalpage #70

timow512 opened this issue Jun 7, 2021 · 0 comments

Comments

@timow512
Copy link

timow512 commented Jun 7, 2021

Hello,

i´m having problems with updating the state of my PageController.

I have a swipe gallery in my card, where I use some dotsIndicators.

The Problem:
When i swipe to the next card, it will display first everything correctly. But after the animation is finished, the card updates the state again and the pagecontroller won´t reset to the initial page. (see recording)

Anyone an idea, how to solve this?

WhatsApp.Video.2021-06-07.at.11.48.09.mp4

Here is the code, which i use widget cardBuilder used for the cardBuilder:

class SwipeCardContainer extends StatelessWidget {
  final spot;

  const SwipeCardContainer({Key key, this.spot}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final PageController imageController = PageController(initialPage: 0);
    return Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        SwipeCardHeader(
          travelSpot: spot,
        ),
        Flexible(
          flex: 3,
          child: Stack(
            children: [
              SwipeGallery(
                pictures: spot.pictures,
                controller: imageController,
                travelSpotId: spot.id,
              ),
              if (spot.pictures.isNotEmpty)
                AboutPictureIcon(controller: imageController, spot: spot),
            ],
          ),
        ),
        AddedItemList(
          items: spot.categories,
          isEditable: false,
          outlineColor: Colors.white,
          labelColor: Colors.white,
          backgroundColor: Colors.transparent,
        ),
        Flexible(
          flex: 5,
          child: Padding(
            padding: EdgeInsets.all(10),
            child: SwipeCardDescription(
              description: spot.description,
              small: false,
            ),
          ),
        ),
        Flexible(
          flex: 1,
          child: Container(),
        ),
      ],
    );
  }
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

1 participant