如何在Flutter中创建的应用程序中隐藏AppBar

时间:2019-02-01 19:53:36

标签: flutter

我下面有这段代码,我想隐藏酒吧应用程序,可以吗?我已经尝试过Android主题,但是没有成功。 :(

  @override
  Widget build(BuildContext context) {
    return WebviewScaffold(
      appBar: AppBar(
        title: TextField(
          autofocus: false,
          controller: controller,
          textInputAction: TextInputAction.go,
          onSubmitted: (url) => launchUrl(),
          style: TextStyle(color: Colors.white),
          decoration: InputDecoration(
            border: InputBorder.none,
            hintText: "Digite a URL",
            hintStyle: TextStyle(color: Colors.white),
          ),
        ),
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.navigate_next),
            onPressed: () => launchUrl(),
          )
        ],
      ),

3 个答案:

答案 0 :(得分:0)

仅根据布尔标志不构建AppBar:

class CalendarButt(Button):

    def button_clicked(self):
        if self.state == 'down':
            print('Hello')

答案 1 :(得分:0)

您也可以使用Visibility小部件来执行此操作,但请注意,appBar必需的类型为PreferredSizedWidgetVisibility的类型为Widget,因为我们必须用PreferedSize小部件并提供尺寸(检查null的代码是否较少,但可以使用自定义应用栏)。

WebviewScaffold(
  appBar: PreferredSize(
    preferredSize: Size(double.infinity, 56),
    child: Visibility(
      visible: true,
      child: AppBar(),
    ),
  ),
  //....
);

答案 2 :(得分:0)

要隐藏appBar,只需在任何屏幕中将appBar属性设置为null。此更改将反映在IOS和Android中。 :)

  Widget build(BuildContext context) {
    return WebviewScaffold(
       url: "https://flutter.dev/",                    // Your url
       appBar: null                                    // No action bar will build
       );
    }
相关问题