【问题标题】:fixed snackBar in bottom of screen修复了屏幕底部的snackBar
【发布时间】:2023-03-12 11:55:01
【问题描述】:

我是飞镖新手 所以我对snackBar 只出现在正文的页脚感到沮丧。 及以上的 persistentFooterButtons 和 bottomNavigationBar 请有人帮我修复屏幕末尾的小吃吧。

这是我的代码:

    Widget build(BuildContext context) {
       return Scaffold(

  key: scaffoldKey,

  backgroundColor: Colors.white,

  appBar: AppBar(),

  body:  SafeArea(

          Material(

             color: Color(0xFF43bdd2), 

             borderRadius: BorderRadius.circular(25.0),

             child: MaterialButton(

                       onPressed:(){ _showSnack; },

                        child: Text('إرسال'),

                                  ),



                         ),  ),

  persistentFooterButtons: <Widget>[

               Text('hello everyone'),

           ],

  bottomNavigationBar: BottomAppBar(

    child: Container(

      padding: EdgeInsets.only(bottom: 3),

          child: Text("©Copyright flutter 2020",style:   TextStyle(color:Colors.black,fontWeight:     FontWeight.bold),textAlign: TextAlign.center,),



    ),  

  ),);}



         _showSnack(){scaffoldKey.currentState.showSnackBar(SnackBar(content:   Text('hi, here i am a snackBar'),)) ;}

【问题讨论】:

  • 请添加屏幕截图,说明您目前获得的内容..以及您想要获得的内容..

标签: flutter dart snackbar scaffold


【解决方案1】:

您可以使用 Flushbar 在底部显示类似的小部件。

FlatButton(
  child: Text('Show Snackbar'),
  onPressed: () {
    Flushbar(
      flushbarPosition: FlushbarPosition.BOTTOM, //Make sure at the bottom
    )
      ..title = 'hi, here i am a snackBar'
      ..show(context);
  },
),

安装包(https://pub.dartlang.org/packages/flushbar

在 pubspec.ymal 中添加这个

dependencies:
  flushbar: ^1.10.4

然后在你所在的文件中导入flushber

import 'package:flushbar/flushbar.dart';

【讨论】:

    猜你喜欢
    • 2012-09-12
    • 1970-01-01
    • 1970-01-01
    • 2017-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-16
    相关资源
    最近更新 更多