2

I have this code below, I want to hide the bar app, is it possible? I've tried straight through the Android Theme but I did not get Success. :(

  @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(),
          )
        ],
      ),
J Roberto
  • 21
  • 1
  • 1
  • 2

3 Answers3

5

To hide the appBar simply set the appBar property as null in any screen. This change will be reflected in IOS as well as Android. :)

  Widget build(BuildContext context) {
    return WebviewScaffold(
       url: "https://flutter.dev/",                    // Your url
       appBar: null                                    // No action bar will build
       );
    }
Aditi Soni
  • 61
  • 1
  • 5
3

Just don't build the AppBar depending on a boolean flag:

return WebviewScaffold(
    appBar: _ifHideAppBar ? null : AppBar(
        ...
    ),
    ...
);
Abion47
  • 22,211
  • 4
  • 65
  • 88
0

You can also use Visibility widget to do this but note that appBar required type of PreferredSizedWidget and Visibility is of type Widget because of that we have to wrap with PreferedSize widget and give sizes(Checking if null is less code but in this way you can have your custom app bar).

WebviewScaffold(
  appBar: PreferredSize(
    preferredSize: Size(double.infinity, 56),
    child: Visibility(
      visible: true,
      child: AppBar(),
    ),
  ),
  //....
);
Blasanka
  • 21,001
  • 12
  • 102
  • 104