如何在Flutter中创建自定义工具栏?

时间:2020-06-19 14:03:58

标签: flutter flutter-layout

我想在Flutter中创建这样的AppBar。

enter image description here

但是我不知道如何创建图像中给出的AppBar。 另外,我想随时隐藏或显示AppBar中的每个按钮。

2 个答案:

答案 0 :(得分:0)

尝试

Private Sub InStr2Example()
    Dim i As Integer
    Dim searchThisString As String: searchThisString = "abcddddddd"
                                                       '1234567890
    Dim forThisSubString As String: forThisSubString = "dd"
    i = InStr2(1, searchThisString, forThisSubString, vbTextCompare, 3, True)
    Debug.Print "3rd occurrence occurs at character position "; i
    i = InStr2(1, searchThisString, forThisSubString, vbTextCompare, 3, False)
    Debug.Print "Prohibbitting overlap, 3rd occurrence occurs at character position "; i
End Sub

答案 1 :(得分:0)

您可以在其中添加带有圆角的装饰,以在AppBar的底部获得圆角。使用“行”窗口小部件在AppBar内添加子组件,例如文本和图标

Scaffold(
  appBar: PreferredSize(
    preferredSize: Size(double.infinity, 100),
    child: Container(
      decoration: BoxDecoration(
        boxShadow: [BoxShadow(
          color: Colors.black12,
          spreadRadius: 5,
          blurRadius: 2
        )]
      ),
      width: MediaQuery.of(context).size.width,
      height: 100,
      child: Container(
        decoration: BoxDecoration(
          color: Colors.blueAccent,
          borderRadius: BorderRadius.only(bottomLeft: Radius.circular(20),bottomRight: Radius.circular(20))
        ),
        child: Container(
          margin: EdgeInsets.fromLTRB(0, 20, 0, 0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Icon(Icons.navigate_before,size: 40,color: Colors.white,),
              Text("Foodbar",style: TextStyle(fontSize: 30,color: Colors.white),),
              Icon(Icons.navigate_before,color: Colors.transparent,),
            ],
          ),
        ),
      ),
    ),
  ),

  body: Center(
  ),
);

enter image description here