Search code examples
flutterbottom-sheetflutter-layout

Permanent Persistent Bottom sheet flutter


I want my bottom sheet to stay on the screen till I close it from a code. Normally the bottom sheet can be closed by pressing back button(device or appbar) or even just by a downward gesture. How can I disable that?

_scaffoldKey.currentState
        .showBottomSheet<Null>((BuildContext context) {
      final ThemeData themeData = Theme.of(context);
      return new ControlBottom(
        songName: songName,
        url: url,
        play: play,
        pause: pause,
        state: test,
        themeData: themeData,
      );
    }).closed.whenComplete((){

    });

Control botton is a different widget.


Solution

  • Scaffold now has a bottom sheet argument and this bottom sheet cannot be dismissed by swiping down the screen.

      @override
      Widget build(BuildContext context) {
        return Scaffold(
            appBar: AppBar(....),
            bottomSheet: Container(
                child: Text('Hello World'),
            ),
        );
      }