• Bruno Leroux's avatar
    Fix floating SnackBar throws when FAB is on the top (#129274) · 97e0a058
    Bruno Leroux authored
    ## Description
    
    This PR updates how a floating snack bar is positionned when a `Scaffold` defines a FAB with `Scaffold.floatingActionButtonLocation` sets to one of the top locations.
    
    **Before this PR:**
    - When a FAB location is set to the top of the `Scaffold`, a floating `SnackBar` can't be displayed and an assert throws in debug mode.
    
    **After this PR:**
    - When a FAB location is set to the top of the `Scaffold`, a floating `SnackBar` will be displayed at the bottom of the screen, above a `NavigationBar` for instance (the top FAB is ignored when computing the floating snack bar position).
    
    ![image](https://github.com/flutter/flutter/assets/840911/08fcee6c-b286-4749-ad0b-ba09e653bd94)
    
    ## Motivation
    
    This is a edge case related to a discrepancy between the Material spec and the Flutter `Scaffold` customizability:
    - Material spec states that a floating `SnackBar` should be displayed above a FAB. But, in Material spec, FABs are expected to be on the bottom.
    - Since https://github.com/flutter/flutter/issues/51465, Flutter `Scaffold` makes it valid to show a FAB on the top of the `Scaffold`.
    
    ## Related Issue
    
    fixes https://github.com/flutter/flutter/issues/128150
    
    ## Tests
    
    Adds 1 test.
    97e0a058
snack_bar_theme.dart 11.7 KB