Flutter 底部板材顶部显示弹簧条的颤振

Flutter 底部板材顶部显示弹簧条的颤振,flutter,dart,flutter-layout,android-snackbar,flutter-widget,Flutter,Dart,Flutter Layout,Android Snackbar,Flutter Widget,在我的代码中,我调用一个底部工作表来显示一个平铺列表。这些平铺包含显示小吃条的按钮。该功能工作正常,唯一的问题是snackbar显示在底部工作表的后面,因此只有关闭底部工作表时才能看到它。使用以下代码调用它们中的每一个: 1。底页: void _settingModalBottomSheet(context, stream, scaffoldKey ) { if (_availableRides.length == 0) { return null; } else

在我的代码中,我调用一个底部工作表来显示一个平铺列表。这些平铺包含显示小吃条的按钮。该功能工作正常,唯一的问题是snackbar显示在底部工作表的后面,因此只有关闭底部工作表时才能看到它。使用以下代码调用它们中的每一个:

1。底页:

  void _settingModalBottomSheet(context, stream, scaffoldKey ) {
    if (_availableRides.length == 0) {
      return null;
    } else {
      return scaffoldKey.currentState.showBottomSheet((context) {
        return Column(
          children: Widgets;
      });
    }
  }
2。Snackbar

widget.scaffoldKey.currentState.showSnackBar(SnackBar(
         content: Text("Created", textAlign: 
    TextAlign.center,),),

有人知道如何将snackbar放置在底部工作表的前面吗?因此,我可以通过向底部工作表添加另一个Scaffold()并向其传递一个新的Scaffold键来解决这个问题。snackbar有一个属性。它被称为
行为
,您可以这样做:

SnackBar(
    behavior: SnackBarBehavior.floating,
    ...

漂浮→ 康斯特斯纳克巴比霍尔

此行为将导致SnackBar显示在中其他小部件的上方 脚手架。这包括显示在屏幕上方 底部导航栏和浮动操作按钮

有关详细信息,请参见material.io/design/components/snackbar.html


我通过将
bottomSheet
更改为
bottomNavigationBar
解决了这个问题,因为浮动快餐店解决方案对我不起作用。

我通过设置(从底部填充到SnackBar)和高度(bottomSheet:height)来解决

在这种情况下,我有一张底片:

bottomSheet: Container(
          child: RaisedButton(...),
          width: MediaQuery.of(context).size.width,
          height: AppBar().preferredSize.height * 0.85,
        ),
还有这个小吃条:

_scaffoldKey.currentState.showSnackBar(SnackBar(
padding:EdgeInsetsDirectional.only(
bottom:AppBar().preferredSize.height * 0.85),
backgroundColor: Colors.red,
duration: new Duration(milliseconds: 3000),
content: Text('ETC..'),
                ));
你可以使用软件包。我认为这是更好的选择,如果需要使用底部

底片内的任何事件

 CustomFlushBar().flushBar(text: 'Thank you for your payment!', context: context,duration: 2);
CustomFlushBar类

  class CustomFlushBar {
      void flushBar({int duration, @required String text, Color iconColor, IconData iconData, Color backgroundColor, @required BuildContext context}) async {
        await dismiss();
        Flushbar(
          margin: EdgeInsets.all(8),
          borderRadius: 8,
          backgroundColor: backgroundColor ?? Palette.greenButton,
          icon: Icon(iconData ?? Icons.done, color: iconColor ?? Palette.white),
          flushbarStyle: FlushbarStyle.FLOATING,
          message: text,
          duration: Duration(seconds: duration ?? 3),
        )..show(context);
      }
    
      Future<void> dismiss() async {
        if (!Flushbar().isDismissed()) {
          await Flushbar().dismiss();
        }
      }
    }
类自定义刷新栏{
void flushBar({int duration,@required String text,Color iconColor,IconData IconData,Color backgroundColor,@required BuildContext context})异步{
等待解雇();
冲水杆(
保证金:全部(8),
边界半径:8,
backgroundColor:backgroundColor??调色板.greenButton,
图标:图标(iconData??Icons.done,颜色:iconColor??调色板。白色),
flushbarStyle:flushbarStyle.FLOATING,
信息:文本,
持续时间:持续时间(秒:持续时间±3),
)…显示(上下文);
}
异步的{
如果(!Flushbar().isdissed()){
等待刷新条()。退出();
}
}
}

哦,天哪。我只是重构了一个
GlobalKey
到处显示一个
SnackBar
,因为
BottomSheet
无法访问它的父
Scaffold
,现在我不得不把所有东西都扔掉。你能分享一些代码片段吗不幸的是,它显示的比底部sheet甚至是FAB都高,这看起来很奇怪。我希望有一个选项可以在底部显示它,就像SnackBarBehavior.fixed中那样,但在底部的工作表上。很抱歉,建议的解决方案对我不起作用。谢谢。不工作,兄弟…@AnandKumar
context
应该是你页面的上下文,而不是底页上下文。你在哪里做的这个更改?请分享。谢谢。
Scaffold
同时具有bottomSheet和bottomNavigationBar属性。当scaffold具有底部表单小部件时,snackbar不会显示在小部件前面。当我将其更改为bottomNavigationBar时,小部件前面显示了snackbar。我已经有了bottomNavigationBar、bottomModelSheet和snackbar。bottomModelSheet显示为正在工作的bottomNavigationBar的覆盖。但当我想在底部模型表上显示snackbar时,它不会显示。Snackbar显示在bottomNavigationBar和bottomModelSheet之间。如果你有这方面的经验。请分享你的想法。谢谢。