title: Marker with Textinput in Flutter
body: <p>How can i add a marker on Google Maps in Flutter, where the User can change the Title and the snippet. It should be a User input, but i dont know how to do this. In this code, the user is able to set a marker by long press on the map. But the Info widget is only the text i choosed befor in the code. (How can i change my code, that the user is able to set a marker, than a window open and the user is able to typ a title and a snipet in it. After closing the window the marker have the Title and snipet from the user.) This is just an idea !!!</p>
  
  <pre><code>import 'package:flutter/cupertino.dart';
  import 'package:flutter/material.dart';
  import 'dart:async';
  import 'package:google_maps_flutter/google_maps_flutter.dart';
  import 'package:location/location.dart';
  
  
  GoogleMapController mapController;
  
  class MapsDemo extends StatefulWidget {
    MapsDemo() : super();
  
  
  
    @override
    MapsDemoState createState() =&gt; MapsDemoState();
  }
  
  class MapsDemoState extends State&lt;MapsDemo&gt; {
    //
  
  
    Completer&lt;GoogleMapController&gt; _controller = Completer();
    static const LatLng _center = const LatLng(51, 10);
    List&lt;Marker&gt; _markers = [];
    LatLng _lastMapPosition = _center;
    MapType _currentMapType = MapType.normal;
  
  
  
    void _currentLocation() async {
      final GoogleMapController controller = await _controller.future;
      LocationData currentLocation;
      var location = new Location();
      try {
        currentLocation = await location.getLocation();
      } on Exception {
        currentLocation = null;
      }
  
      controller.animateCamera(CameraUpdate.newCameraPosition(
        CameraPosition(
          bearing: 0,
          target: LatLng(currentLocation.latitude, currentLocation.longitude),
          zoom: 18.0,
        ),
      ));
    }
  
    _onMapCreated(GoogleMapController controller) {
      _controller.complete(controller);
    }
  
    _onCameraMove(CameraPosition position) {
      _lastMapPosition = position.target;
    }
  
    _onMapTypeButtonPressed() {
      setState(() {
        _currentMapType = _currentMapType == MapType.normal
            ? MapType.hybrid
            : MapType.normal;
      });
    }
  
    Future _addMarkerLongPressed(LatLng latlang) async {
      setState(() {
        final MarkerId markerId = MarkerId("RANDOM_ID");
        Marker marker = Marker(
          markerId: markerId,
          draggable: true,
          position: latlang, //With this parameter you automatically obtain latitude and longitude
          infoWindow: InfoWindow(
            title: 'This is a Marker',
            snippet: 'This looks good',
          ),
          icon: BitmapDescriptor.defaultMarker,
        );
        markers[markerId] = marker;
  
      });
  
      //This is optional, it will zoom when the marker has been created
      GoogleMapController controller = await _controller.future;
      controller.animateCamera(CameraUpdate.newLatLngZoom(latlang, 18.0));
    }
  
    Widget button(Function function, IconData icon) {
      return FloatingActionButton(
        onPressed: function,
        materialTapTargetSize: MaterialTapTargetSize.padded ,
        backgroundColor: Colors.blue,
        child: Icon(
          icon,
          size: 36.0,
        ),
      );
    }
  
    Map&lt;MarkerId, Marker&gt; markers = &lt;MarkerId, Marker&gt;{};
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
  
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          resizeToAvoidBottomPadding: false,
          appBar: PreferredSize(
            preferredSize: Size.fromHeight(40),
  
              child: AppBar(
  
                automaticallyImplyLeading: false,
                centerTitle: true,
                title:  Column(
                  children: &lt;Widget&gt;[
                    const Text("Viewist", style: TextStyle(fontSize: 35.0),textAlign: TextAlign.center,),
                    const Text("", style: TextStyle(fontSize: 8.0),textAlign: TextAlign.center,),
                  ],
                ),
                flexibleSpace: Container(
                  decoration: BoxDecoration(
                      gradient: LinearGradient(
                          begin: Alignment.topLeft,
                          end: Alignment.bottomRight,
                          colors: &lt;Color&gt;[
                            Colors.greenAccent,
                            Colors.blueAccent
                          ])
                  ),
  
                ),
              ),
  
          ),
          body:
          Stack(
  
              children: [Container(
                padding: new EdgeInsets.all(0.0),
                  child: GoogleMap(
                    mapType: _currentMapType,
                    onMapCreated: _onMapCreated,
                    onCameraMove: _onCameraMove,
                    myLocationEnabled: true,
                    myLocationButtonEnabled: false,
                    initialCameraPosition: CameraPosition(
                      target: _center,
                      zoom: 6.0,
                    ),
                    compassEnabled: true,
                    tiltGesturesEnabled: false,
                    onLongPress: (latlang) {
                      _addMarkerLongPressed(latlang); //we will call this function when pressed on the map
                    },
                    markers: Set&lt;Marker&gt;.of(markers.values), //all markers are here
                  ),
              ),
  
  
              Padding(
  
                padding: EdgeInsets.all(20.0),
                child: Align(
                  alignment: Alignment.topRight,
                  child: Column(
                    children: &lt;Widget&gt;[
                      button(_onMapTypeButtonPressed, Icons.map),
                      SizedBox(
                        height: 18.0,
                      ),
                      button(_currentLocation, Icons.location_searching),
                    ],
                  ),
  
                ),
              ),
              ],
          ),
          drawer: Drawer(
            child: ListView(
                padding: new EdgeInsets.all(0.0),
              children: &lt;Widget&gt;[
                DrawerHeader(
                    decoration: BoxDecoration(
                        gradient: LinearGradient(colors: &lt;Color&gt;[
                          Colors.green,
                          Colors.lightBlueAccent
                        ])
                    ),
                    child: Container(
                      child: Column(
                        children: &lt;Widget&gt;[
                          Material(
                            borderRadius: BorderRadius.all(Radius.circular(40.0)),
                            elevation: 10,
                            child: Padding(padding: EdgeInsets.all(8.0),
                            child: Image.asset('images/a.png',width: 80,height: 80,),
                            ),
                          ),
                          Padding(padding: EdgeInsets.all(2.0), child: Text ('Viewist', style: TextStyle(color: Colors.white, fontSize: 30.0,),
                          )
                          )],
                      ),
                    )),
                CustomListTile(Icons.person, 'Profile', ()=&gt;{}),
                CustomListTile(Icons.notifications, 'Notification', ()=&gt;{}),
                CustomListTile(Icons.settings, 'Settings', ()=&gt;{}),
                CustomListTile(Icons.lock, 'Log Out', ()=&gt;{}),
              ],
            ),
          ),
  
        ),
  
      );
    }
  
  }
  
  
    class CustomListTile extends StatelessWidget {
    IconData icon;
    String text;
    Function onTap;
  
    CustomListTile(this.icon,this.text,this.onTap);
  
      @override
      Widget build(BuildContext context) {
        // TODO: implement createState
        return Padding(
          padding: const EdgeInsets.fromLTRB(8.0, 0, 8.0, 0),
          child: Container(
            decoration: BoxDecoration(
              border: Border(bottom: BorderSide(color: Colors.grey.shade400))
            ),
            child: InkWell(
              splashColor: Colors.lightBlueAccent,
              onTap: onTap,
              child: Container(
                height: 50,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: &lt;Widget&gt;[
                    Row(
                      children: &lt;Widget&gt;[
                        Icon(icon),
                        Padding(
                          padding: const EdgeInsets.all(8.0),
                          child: Text(text, style: TextStyle(
                            fontSize: 16.0
                          ),),
                        ),
                      ],
                    ),
                    Icon(Icons.arrow_right)
                  ],
                ),
              ),
            ),
          ),
        );
  
      }
  
  
    }
  </code></pre>