Skip to content

fix: remove hidden BottomAppBar SafeArea gap in sub-editors#791

Open
faizahmaddae wants to merge 3 commits intohm21:stablefrom
faizahmaddae:fix/sub-editor-bottom-bar-gap
Open

fix: remove hidden BottomAppBar SafeArea gap in sub-editors#791
faizahmaddae wants to merge 3 commits intohm21:stablefrom
faizahmaddae:fix/sub-editor-bottom-bar-gap

Conversation

@faizahmaddae
Copy link
Contributor

Problem

When a user sets EditorSafeArea(bottom: false) on any sub-editor config (paint, text, blur, filter, tune, crop/rotate), a hidden gap appears between the subtool toolbar row and the bottom action row (Close/Undo/Redo/Done).

The gap is approximately 34px on devices with a bottom safe area (e.g. iPhone with home indicator).

Visual

┌────────────────────────────┐
│   Image / Canvas Area      │
├────────────────────────────┤
│ Color │ Thickness │ Opacity│  ← subtool toolbar (BottomAppBar, 65px)
│                            │
│     ~34px hidden gap       │  ← THIS IS THE BUG
│                            │
├────────────────────────────┤
│  ✕  │  ↩  │  ↪  │  ✓     │  ← bottom action row (GroundedBottomBar)
└────────────────────────────┘

Root Cause

Flutter's BottomAppBar widget internally wraps its content in SafeArea(bottom: true) (source: bottom_app_bar.dart line 230):

// Inside Flutter's BottomAppBar.build():
final Widget child = SizedBox(
  height: height,           // 65px
  child: Padding(
    padding: widget.padding, // EdgeInsets.zero
    child: widget.child,
  ),
);

return PhysicalShape(
  child: Material(
    child: SafeArea(child: child),  // ← adds bottom padding externally
  ),
);

When the editor's outer SafeArea(bottom: false) is set:

  • It does NOT add visible padding (correct)
  • It does NOT consume the viewPadding.bottom from MediaQuery (this is the issue)

So the BottomAppBar's internal SafeArea(bottom: true) still sees the full viewPadding.bottom (~34px) and adds it as invisible padding below the SizedBox(height: 65), expanding the BottomAppBar beyond its intended 65px height.

Since BottomAppBar is used inside a Column (via GroundedBottomWrapper) alongside GroundedBottomBar, this extra padding creates a visible gap between the two bars.

Fix

Wrap each sub-editor's Scaffold in MediaQuery.removePadding(removeBottom: ...):

// Before:
SafeArea(
  bottom: config.safeArea.bottom,  // false
  child: Scaffold(
    bottomNavigationBar: _buildBottomBar(),  // BottomAppBar sees full padding
  ),
)

// After:
SafeArea(
  bottom: config.safeArea.bottom,  // false
  child: MediaQuery.removePadding(
    context: context,
    removeBottom: !config.safeArea.bottom,  // true when safeArea.bottom is false
    child: Scaffold(
      bottomNavigationBar: _buildBottomBar(),  // BottomAppBar sees zero padding
    ),
  ),
)

MediaQuery.removePadding(removeBottom: true) zeroes out viewPadding.bottom in the MediaQuery data for all descendants, so BottomAppBar's internal SafeArea has nothing to add.

Backward Compatibility

User's safeArea.bottom removeBottom value Effect
true (default) !truefalse No-op. MediaQuery.removePadding(removeBottom: false) changes nothing. Zero impact on existing users.
false (explicitly set) !falsetrue Fixes the gap. Bottom padding is consumed before it reaches BottomAppBar.

This is a fully backward-compatible fix. Users on default settings experience zero change.

Files Changed

File Change
lib/features/paint_editor/paint_editor.dart Wrap Scaffold in MediaQuery.removePadding
lib/features/text_editor/text_editor.dart Wrap Scaffold in MediaQuery.removePadding
lib/features/blur_editor/blur_editor.dart Wrap Scaffold in MediaQuery.removePadding
lib/features/filter_editor/filter_editor.dart Wrap Scaffold in MediaQuery.removePadding
lib/features/tune_editor/tune_editor.dart Wrap Scaffold in MediaQuery.removePadding
lib/features/crop_rotate_editor/crop_rotate_editor.dart Wrap Scaffold in MediaQuery.removePadding

Reproduction Steps

  1. Set safeArea: EditorSafeArea(top: false, bottom: false) on any sub-editor config (e.g. paintEditor)
  2. Open the paint editor on a device with bottom safe area (iPhone with home indicator)
  3. Observe the gap between the subtool toolbar and the bottom action row

How to Verify the Fix

  1. Apply this change
  2. Set safeArea: EditorSafeArea(top: false, bottom: false) on any sub-editor
  3. Open the sub-editor on an iPhone (or simulator with home indicator)
  4. The subtool toolbar and bottom action row should be directly adjacent with no gap

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

Successfully merging this pull request may close these issues.

1 participant