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

resizeToAvoidBottomInset:false is not working #116851

Closed
hello-nico-chan opened this issue Dec 11, 2022 · 10 comments
Closed

resizeToAvoidBottomInset:false is not working #116851

hello-nico-chan opened this issue Dec 11, 2022 · 10 comments
Labels
r: solved Issue is closed as solved

Comments

@hello-nico-chan
Copy link

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. There are some Expanded widgets and one of them contains a TextField. They were wrapped up by a Column widget and next a Padding widget. And in the Scaffold, I added resizeToAvoidBottomInset: false;.
  3. Tap on TextField.

Expected results: All of the widgets keep their position.

Actual results: All of them are resized.

Code sample
import 'package:flutter/material.dart';

class Test extends StatefulWidget {
  const Test({super.key});

  @override
  State<Test> createState() => _TestState();
}

class _TestState extends State<Test> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      body: Padding(
        padding: const EdgeInsets.all(50),
        child: Column(
          children: const [
            Expanded(
              flex: 3,
              child: Center(
                child: Text(
                  'Hello! 👏',
                  style: TextStyle(fontSize: 20),
                ),
              ),
            ),
            Expanded(
              flex: 3,
              child: Center(
                child: Text(
                  'Hello! 👏',
                  style: TextStyle(fontSize: 20),
                ),
              ),
            ),
            Expanded(
              flex: 3,
              child: TextField(
                decoration: InputDecoration(labelText: 'username'),
              ),
            ),
            Expanded(
              flex: 3,
              child: Center(
                child: Text(
                  'Hello! 👏',
                  style: TextStyle(fontSize: 20),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
Logs
[✓] Flutter (Channel stable, 3.3.9, on macOS 13.0.1 22A400 darwin-x64, locale zh-Hans-CN)
    • Flutter version 3.3.9 on channel stable at /Users/nico.chan/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (3 weeks ago), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/nico.chan/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.74.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.54.0

[✓] Connected device (4 available)
    • Nico’s iPhone 14 Pro (mobile) • 00008120-000A08CE2ED8C01E            • ios            • iOS 16.1.2 20B110
    • iPhone 14 Pro (mobile)        • AF5E50C7-46D4-474D-B5CC-80A25FA57405 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
    • macOS (desktop)               • macos                                • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
    • Chrome (web)                  • chrome                               • web-javascript • Google Chrome 108.0.5359.98
    ! Error: (null) needs to connect to determine its availability. Check the connection between the device and its companion iPhone, and the connection between
      the iPhone and Xcode. Both devices may also need to be restarted and unlocked. (code 1)

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
RPReplay_Final1670753822.mp4
@iapicca
Copy link
Contributor

iapicca commented Dec 11, 2022

@hello-nico-chan I don't experience the same behavior

full code sample
import 'package:flutter/material.dart';

void main() => runApp(const MaterialApp(home: TestWidget()));

class TestWidget extends StatelessWidget {
  const TestWidget({super.key});

  @override
  Widget build(context) => Scaffold(
        resizeToAvoidBottomInset: false,
        body: Padding(
          padding: const EdgeInsets.all(50),
          child: Column(
            children: const [
              Expanded(
                flex: 3,
                child: Center(
                  child: Text(
                    'Hello! 👏',
                    style: TextStyle(fontSize: 20),
                  ),
                ),
              ),
              Expanded(
                flex: 3,
                child: Center(
                  child: Text(
                    'Hello! 👏',
                    style: TextStyle(fontSize: 20),
                  ),
                ),
              ),
              Expanded(
                flex: 3,
                child: TextField(
                  decoration: InputDecoration(labelText: 'username'),
                ),
              ),
              Expanded(
                flex: 3,
                child: Center(
                  child: Text(
                    'Hello! 👏',
                    style: TextStyle(fontSize: 20),
                  ),
                ),
              ),
            ],
          ),
        ),
      );
}

issue_116851

doctor
[✓] Flutter (Channel stable, 3.3.9, on macOS 13.0.1 22A400 darwin-arm, locale en-EE)
    • Flutter version 3.3.9 on channel stable at /Users/yakforward/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b8f7f1f986 (3 weeks ago), 2022-11-23 06:43:51 +0900
    • Engine revision 8f2221fbef
    • Dart version 2.18.5
    • DevTools version 2.15.0

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] VS Code (version 1.74.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.54.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.0.1 22A400 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 108.0.5359.98

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 2 categories.
xcode version
xcode-select --version
xcode-select version 2396.

@hello-nico-chan
Copy link
Author

Thanks for the reply @iapicca, but it's so weird I remember it worked several weeks ago but now it doesn't work after some flutter upgrades. My flutter is v3.3.9 and dart v2.18.5

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Dec 12, 2022
@darshankawar
Copy link
Member

@hello-nico-chan
I am also unable to replicate this using latest master or stable.

116851.mov

What version of iOS you are using ? Is it a physical device or simulator ?

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 12, 2022
@gillhad
Copy link

gillhad commented Dec 12, 2022

I have the same issue, using Simulator, iOS16
Flutter (Channel stable, 3.3.7, on macOS 12.6 21G115 darwin-x64, locale ca-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)

@hello-nico-chan
Copy link
Author

hello-nico-chan commented Dec 12, 2022

Hi @darshankawar , my OS is iOS 16.1.2, and I have this issue both on my physical device (iOS 16.1.2) and simulator (iOS 16.1)

2022-12-12.17.14.05.mov

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 12, 2022
@iapicca
Copy link
Contributor

iapicca commented Dec 12, 2022

Hi @darshankawar , my OS is iOS 16.1.2, and I have this issue both on my physical device (iOS 16.1.2) and simulator (iOS 16.1)

2022-12-12.17.14.05.mov

@hello-nico-chan
does Test have a parent widget that resize?
what do you get if you run this code sample?

@gillhad
Copy link

gillhad commented Dec 12, 2022

@hello-nico-chan
I solved the issue, in my case I had a previous Scaffold that holds the main display and was not controlling the resizeToAvoidBottomtInsertthere ...
Hope this helps!

@hello-nico-chan
Copy link
Author

hello-nico-chan commented Dec 12, 2022

Hi @darshankawar , my OS is iOS 16.1.2, and I have this issue both on my physical device (iOS 16.1.2) and simulator (iOS 16.1)
2022-12-12.17.14.05.mov

@hello-nico-chan does Test have a parent widget that resize? what do you get if you run this code sample?

Oh @iapicca, the code sample you mentioned works for me! My Test widget is a new page and the sequence is:

  • main.dart: MaterialApp -> Scaffold / NaviBar
  • navi_bar.dart: Scaffold body -> MyApp
  • my_app.dart: Container -> Padding -> Column -> Expand -> MyWelcomeBanner
  • my_welcome_banner.dart: InkWell onTap: Navigator.of(context).push(MaterialPageRoute(builder: (context) => const Test()))
  • test.dart

Then, thanks for @gillhad 's tips, I added resizeToAvoidBottomInset: false, in the main.dart's Scaffold, and it works!!!
Of course, I need to keep this line in the test.dart page, I shouldn't remove it after I add this line in the main.dart file.

My problem is solved!! Thank you all!!!!
@iapicca @darshankawar @gillhad
Thanks!!!

(I'm new to flutter, I don't very clear about many principles and I'm still learning.😄)

@darshankawar darshankawar added r: solved Issue is closed as solved and removed in triage Presently being triaged by the triage team labels Dec 13, 2022
@OdaFra
Copy link

OdaFra commented Feb 7, 2023

Hello people!.

I had the same problem.

In my case it was the other way around, I needed the behavior of the first video in this issue (@hello-nico-chan).

The version I was using was Flutter 3.3.9 (global) with Dart 2.18.5 (stable).

In my pubspec.yaml file the sdk was at ">=2.18.2 <3.0.0", by changing to sdk: ">=2.17.0 <3.0.0" I managed to get the results.

Just to comment I handle the versions with fvm.

@github-actions
Copy link

github-actions bot commented Mar 3, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
r: solved Issue is closed as solved
Projects
None yet
Development

No branches or pull requests

5 participants