flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.69k stars 27.61k forks source link

App Bar pulled down and requires remove padding #159417

Open Angeloem opened 1 day ago

Angeloem commented 1 day ago

Steps to reproduce

  1. I updated the sdk and start playing with editing status bar colors natively and then, flutter causes appbars to render very below their point with some padding.

Expected results

Screens with appbars should render just fine starting from the top like illustrated on the image Screenshot_1732542519

Actual results

Screenshot_1732542252

Above is a screenshot with the results displayed without telling MediaQuery to remove padding on the build function.

Code sample

Widget build(BuildContext context){
    return Container(
      decoration: BoxDecoration(
        border: Border.all(color: Colors.black, width: 4),
        color: Colors.green,
      ),
      child: Scaffold(
        backgroundColor: Colors.amber,
        appBar: AppBar(
          backgroundColor: Colors.pink,
          title: Text('orders'.tr),
        ),
      ),
    );
}

Explanation Without the media query to remove the space manually, it displays the space above the appbar.

To remove it, I have to manually replace with the below code:

MediaQuery.removePadding(
      context: context,
      removeTop: true,
      child: Container(
        decoration: BoxDecoration(
          border: Border.all(color: Colors.black, width: 4),
          color: Colors.green,
        ),
        child: Scaffold(
          backgroundColor: Colors.amber,
          appBar: AppBar(
            backgroundColor: Colors.pink,
            title: Text('orders'.tr),
          ),
        ),
      ),
    );

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console [ ] Installing APK. [ +1 ms] Installing build/app/outputs/flutter-apk/app-debug.apk... [ ] executing: /Users/angeloem/Library/Android/sdk/platform-tools/adb -s emulator-5554 install -t -r /Users/angeloem/IdeaProjects/chapchap-app/build/app/outputs/flutter-apk/app-debug.apk [+1608 ms] Performing Streamed Install Success [ +1 ms] Installing build/app/outputs/flutter-apk/app-debug.apk... (completed in 1,609ms) [ +1 ms] executing: /Users/angeloem/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell echo -n aa8238a4e03de1b20b4c93ff8345ac13d4e33ab8 > /data/local/tmp/sky.tz.co.codeblock.chapchap.sha1 [ +30 ms] executing: /Users/angeloem/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell -x logcat -v time -t 1 [ +149 ms] --------- beginning of system 11-25 16:56:59.264 E/AppOps ( 551): attributionTag VCN not declared in manifest of android [ +14 ms] executing: /Users/angeloem/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x20000000 --ez enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true tz.co.codeblock.chapchap/tz.co.codeblock.chapchap.MainActivity [ +157 ms] Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x20000000 cmp=tz.co.codeblock.chapchap/.MainActivity (has extras) } [ ] Waiting for VM Service port to be available... [+2278 ms] VM Service URL on device: http://127.0.0.1:36423/MorA0clNSjI=/ [ ] executing: /Users/angeloem/Library/Android/sdk/platform-tools/adb -s emulator-5554 forward tcp:0 tcp:36423 [ +10 ms] D/FlutterGeolocator(13784): Attaching Geolocator to activity [ +15 ms] 59607 [ ] Forwarded host port 59607 to device port 36423 for VM Service [ +4 ms] Caching compiled dill [ +164 ms] Connecting to service protocol: http://127.0.0.1:59607/MorA0clNSjI=/ [ +55 ms] D/FlutterGeolocator(13784): Creating service. [ +4 ms] D/FlutterGeolocator(13784): Binding to location service. [ +169 ms] D/FlutterGeolocator(13784): Geolocator foreground service connected [ ] D/FlutterGeolocator(13784): Initializing Geolocator services [ ] D/FlutterGeolocator(13784): Flutter engine connected. Connected engine count 1 [ +41 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:59607/MorA0clNSjI=/. [ +119 ms] DDS is listening at http://127.0.0.1:59610/lyvNtb52qgw=/. [ +55 ms] Successfully connected to service protocol: http://127.0.0.1:59607/MorA0clNSjI=/ [ +50 ms] DevFS: Creating new filesystem on the device (null) [ +16 ms] DevFS: Created new filesystem on the device (file:///data/user/0/tz.co.codeblock.chapchap/code_cache/chapchap-appMYCPJD/chapchap-app/) [ +1 ms] Updating assets [ +464 ms] Manifest contained wildcard assets. Inserting missing file into build graph to force rerun. for more information see #56466. [ +2 ms] Syncing files to device sdk gphone16k arm64... [ +1 ms] Compiling dart to kernel with 0 updated files [ ] Processing bundle. [ ] <- recompile package:chapchap/main.dart 28e3adc3-f18a-4b22-8ea0-c86b8c80e732 [ ] <- 28e3adc3-f18a-4b22-8ea0-c86b8c80e732 [ +4 ms] Bundle processing done. [ +2 ms] W/FlutterJNI(13784): FlutterJNI.loadLibrary called more than once [ ] I/ResourceExtractor(13784): Found extracted resources res_timestamp-94-1732543018889 [ ] W/FlutterJNI(13784): FlutterJNI.prefetchDefaultFontManager called more than once [ ] W/FlutterJNI(13784): FlutterJNI.init called more than once [ ] I/FLTFireBGExecutor(13784): Creating background FlutterEngine instance, with args: [--enable-dart-profiling] [ ] D/Android: [Awesome Notifications](13784): Awesome Notifications plugin attached to Android 35 (AwesomeNotificationsPlugin:155) [ ] D/Android: [Awesome Notifications](13784): Awesome Notifications attached to engine for Android 35 (AwesomeNotificationsPlugin:137) [ ] D/FlutterGeolocator(13784): Geolocator foreground service connected [ ] D/FlutterGeolocator(13784): Initializing Geolocator services [ ] D/FlutterGeolocator(13784): Flutter engine connected. Connected engine count 2 [ +203 ms] I/flutter (13784): Navigated from Unknown to / [ +38 ms] I/FLTFireMsgService(13784): FlutterFirebaseMessagingBackgroundService started! [ +93 ms] I/flutter (13784): INITING THE CART WIDGET [ +87 ms] Updating files. [ ] Pending asset builds completed. Writing dirty entries. [ ] DevFS: Sync finished [ ] Syncing files to device sdk gphone16k arm64... (completed in 432ms) [ ] Synced 0.0MB. [ +1 ms] <- accept [ +3 ms] Connected to _flutterView/0xb4007abb701b1450. [ ] Connected to _flutterView/0xb4007abb701c4c40. [ +2 ms] Flutter run key commands. [ ] r Hot reload. 🔥🔥🔥 [ ] R Hot restart. [ ] h List all available interactive commands. [ ] d Detach (terminate "flutter run" but leave application running). [ ] c Clear the screen [ ] q Quit (terminate the application on the device). [ ] A Dart VM Service on sdk gphone16k arm64 is available at: http://127.0.0.1:59610/lyvNtb52qgw=/ [ +111 ms] The Flutter DevTools debugger and profiler on sdk gphone16k arm64 is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:59610/lyvNtb52qgw=/ [ +744 ms] I/flutter (13784): Navigated from / to /home_page [ +46 ms] I/flutter (13784): INITING THE CART WIDGET [ +100 ms] W/WindowOnBackDispatcher(13784): OnBackInvokedCallback is not enabled for the application. [ ] W/WindowOnBackDispatcher(13784): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest. [ +178 ms] D/EGL_emulation(13784): app_time_stats: avg=173.96ms min=3.00ms max=926.90ms count=6 [+1004 ms] D/EGL_emulation(13784): app_time_stats: avg=5.39ms min=0.57ms max=46.61ms count=59 [ +673 ms] D/ProfileInstaller(13784): Installing profile for tz.co.codeblock.chapchap [ +341 ms] D/EGL_emulation(13784): app_time_stats: avg=18.39ms min=8.68ms max=116.49ms count=55 [+1018 ms] D/EGL_emulation(13784): app_time_stats: avg=16.86ms min=5.60ms max=40.59ms count=59 [+1015 ms] D/EGL_emulation(13784): app_time_stats: avg=18.36ms min=13.37ms max=117.86ms count=55 [+1015 ms] D/EGL_emulation(13784): app_time_stats: avg=16.43ms min=13.89ms max=20.22ms count=61 [+1037 ms] D/EGL_emulation(13784): app_time_stats: avg=17.98ms min=1.03ms max=118.52ms count=48 [+1012 ms] D/EGL_emulation(13784): app_time_stats: avg=16.24ms min=5.69ms max=24.99ms count=61 [+1000 ms] D/EGL_emulation(13784): app_time_stats: avg=13.80ms min=1.22ms max=20.65ms count=55 [+1000 ms] D/EGL_emulation(13784): app_time_stats: avg=18.41ms min=13.41ms max=117.26ms count=54 [ +306 ms] I/flutter (13784): Navigated from /home_page to OrdersListNew [ +17 ms] D/STATUS_BAR_CHANGE_TAG(13784): beginning the call handler with method changeColor [ +1 ms] D/STATUS_BAR_CHANGE_TAG(13784): data passed is {background=#ffffff, foreground=#ffffff} [ +59 ms] W/WindowOnBackDispatcher(13784): OnBackInvokedCallback is not enabled for the application. [ ] W/WindowOnBackDispatcher(13784): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest. [ +175 ms] I/flutter (13784): incoming data of value 2 and present data 0 ```

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.24.3, on macOS 15.0.1 24A348 darwin-arm64, locale en-TZ) • Flutter version 3.24.3 on channel stable at /Users/angeloem/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2663184aa7 (3 months ago), 2024-09-11 16:27:48 -0500 • Engine revision 36335019a8 • Dart version 3.5.3 • DevTools version 2.37.3 [!] Android toolchain - develop for Android devices (Android SDK version 35.0.0) • Android SDK at /Users/angeloem/Library/Android/sdk • Platform android-35, build-tools 35.0.0 • ANDROID_HOME = /Users/angeloem/Library/Android/sdk • Java binary at: /Users/angeloem/Library/Java/JavaVirtualMachines/corretto-17.0.12/Contents/Home/bin/java • Java version OpenJDK Runtime Environment Corretto-17.0.12.7.1 (build 17.0.12+7-LTS) ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/to/macos-android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 16.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 16A242d • CocoaPods version 1.15.2 [✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/to/macos-android-setup for detailed instructions). [✓] IntelliJ IDEA Ultimate Edition (version 2024.3) • IntelliJ at /Users/angeloem/Applications/IntelliJ IDEA Ultimate.app • Flutter plugin version 82.2.4 • Dart plugin version 243.22562.3 [✓] VS Code (version 1.95.3) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.100.0 [✓] Connected device (3 available) • sdk gphone16k arm64 (mobile) • emulator-5554 • android-arm64 • Android 15 (API 35) (emulator) • macOS (desktop) • macos • darwin-arm64 • macOS 15.0.1 24A348 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.0.1 24A348 darwin-arm64 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 3 categories. ```
darshankawar commented 9 hours ago

@Angeloem On latest stable 3.24.5, running the given code using android emulator shows me below:

Screenshot 2024-11-26 at 1 09 39 PM

I observed that the appbar size is same if we use the official example:

Screenshot 2024-11-26 at 1 16 39 PM
  1. updated the sdk

What version were you on before upgrading ? In previous version, did it show different behavior ?

Angeloem commented 9 hours ago

@darshankawar ,

That is interesting. I was on flutter 3.1+ before upgrading.

Yes, it showed a different behavior before. And the app was nearly finished. Waiting to deploy it.

I will try applying as set in the official example and will get back to you.