Showing a map with Google Maps

With everything ready for iOS and Android, we can now add a GoogleMap widget to the main screen of our app, as follows:

  1. To use a package, as usual, we can import it at the top of the file. So, let's include the required Google Maps dependency in the main.dart file, like this:
import 'package:flutter/material.dart';import 'package:google_maps_flutter/google_maps_flutter.dart';
  1. Then, remove the stateful widget from the default app, and create a new stateful widget called MainMap, as follows:
class MainMap extends StatefulWidget {  @override _MainMapState createState() => _MainMapState(); ...

Get Flutter Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.