7

How can I remove title bar on flutter bar?

displayMap() {
    mapView.show(new MapOptions(
        mapViewType: MapViewType.normal,
        initialCameraPosition:
        new CameraPosition(new Location(11.052992, 106.681612), 3.0),
        showUserLocation: false,
        title: 'Google Map'));

         .....
  }

I tried add Container(height: 0.0) and remove title: 'Google Map' but it only remove 'Google Map' text.

enter image description here

Edited:

My Scaffold

Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Demo App'),
      ),
      body: new Center(
        child: Container(
          child: RaisedButton(
            child: Text('Touch'),
            color: Colors.blue,
            textColor: Colors.white,
            elevation: 7.0,
            onPressed: displayMap,
          ),
        ),
      ),
    );
  }
mirkancal
  • 4,762
  • 7
  • 37
  • 75
Alex
  • 727
  • 1
  • 13
  • 32

2 Answers2

16

In some cases it is necessary to work with the AppBar but without displaying the title and one of these cases is when we have AppBar and TabBar together.

In this case you will need to remove the AppBar title and include the following property: toolbarHeight: 0

DefaultTabController(
  length: 2,
  child: Scaffold(
    backgroundColor: Colors.white,
    appBar: AppBar(
      bottom: TabBar(
        isScrollable: false,
        indicatorColor: Colors.blue,
        onTap: (index) { },
        tabs: [
          Tab(text: "Pending"),
          Tab(text: "Done"),
        ],
      ),
      //this property
      toolbarHeight: 0,
    ), body: TabBarView(...)
  )
)
Zhar
  • 3,330
  • 2
  • 24
  • 25
Walison Silva
  • 161
  • 1
  • 3
10

in your Scaffold you need to remove your appBar property:

    return Scaffold(
        //delete your appBar property in your related Scaffold.
        body: YourBodyWidget(),
    );

Edit : it is related with the map_view plugin

  MapOptions(
      {this.showUserLocation: false,
      this.showMyLocationButton: false,
      this.showCompassButton: false,
      this.hideToolbar = false,
      this.initialCameraPosition: _defaultCamera,
      this.title: "",
      this.mapViewType: MapViewType.normal});

these are the default MapOptions may be you can try to set hideToolbar:true but it is not what you want I think,

I think they are not provide a parameter to close appBar,

Lastly I would recommend to use google_maps_flutter plugin, this plugin only render the map and developed by Flutter Team so you can easily configure other staff in your page/scaffold.

cipli onat
  • 1,943
  • 1
  • 11
  • 26
  • In my `Scaffold` I had remove `AppBar: new AppBar( title: new Text('Demo App'), ),` and remove `title` on `displayMap()` but it not ok – Alex Mar 24 '19 at 10:59