Skip to content

Instantly share code, notes, and snippets.

@Aditsyal Aditsyal/mapType.dart Secret
Last active Apr 10, 2019

Embed
What would you like to do?
MapType _defaultMapType = MapType.normal;
void _changeMapType() {
setState(() {
_defaultMapType = _defaultMapType == MapType.normal ? MapType.satellite : MapType.normal;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Maps in Flutter'),
centerTitle: true,
),
body: Stack(
children: <Widget>[
GoogleMap(
mapType: _defaultMapType,
myLocationEnabled: true,
onMapCreated: _onMapCreated,
initialCameraPosition: _initialPosition,
),
Container(
margin: EdgeInsets.only(top: 80, right: 10),
alignment: Alignment.topRight,
child: Column(
children: <Widget>[
FloatingActionButton(
child: Icon(Icons.layers),
elevation: 5,
backgroundColor: Colors.teal[200],
onPressed: () {
_changeMapType();
print('Changing the Map Type');
}),
]),
),
]),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.