1

I have a weird behavior inside my app... I am using a PageView and on the 2nd page I am focusing a TextField on the pages init. That is working fine. However on the first page my Widgets are moving a little bit even though I set in the wrapping Scaffold: resizeToAvoidBottomInset = false.

Here is a Screenvideo for a better understanding.

This is my Wrapping View:

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      backgroundColor: AppColors.secondary,
      body: SafeArea(
        child: Column(
          children: [
            _buildDismissButton(),
            Expanded(
              child: PageView(
                controller: _pageController,
                onPageChanged: (index) {
                  if (index == 0) {
                    FocusScope.of(context).unfocus();
                  }
                },
                children: [
                  AddPhotoPage(onNextPage: () {
                    _pageController.nextPage(
                        duration: Duration(milliseconds: 350),
                        curve: Curves.easeInOut);
                  }),
                  AddTitlePage(),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

And the problem is on the AddPhotoPage:

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: sidePadding),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            'Foto wählen',
            style: AppTextStyles.montserratH2SemiBold,
          ),
          Spacer(flex: 1),
          _buildEmptyImageStateWidgets(),
          Spacer(
            flex: 3,
          ),
          RoundedCornersTextButton(
            title: 'Weiter',
            isLoading: isUploadingImage,
            onTap: () {
              widget.onNextPage();
            },
          ),
          SizedBox(
            height: 50.scaled,
          ),
        ],
      ),
    );
  }

I feel like it has got something to do with the Spacer(). Because if I removed them and just place SizedBoxes with a specific height, the behavior does not occur.

What am I missing here? Let me know if you need any more info!

Chris
  • 1,828
  • 6
  • 40
  • 108

1 Answers1

0

Check if there is a Scaffold above in the widget tree. I had a similar problem, and it turned out that I also had a Scaffold in my main.dart file. After adding resizeToAvoidBottomInset: false to that Scaffold(), the elements stopped moving.

Tomasz Kot
  • 302
  • 2
  • 6