flutter_google_places_autocomplete 0.0.1 copy "flutter_google_places_autocomplete: ^0.0.1" to clipboard
flutter_google_places_autocomplete: ^0.0.1 copied to clipboard

discontinued
outdatedDart 1 only

Google places autocomplete widgets for flutter.

example/lib/main.dart

import 'package:flutter_google_places_autocomplete/flutter_google_places_autocomplete.dart';
import 'package:flutter/material.dart';

const kGoogleApiKey = "API_KEY";

main() {
  runApp(new MaterialApp(
      title: "My App",
      home: new MyApp(),
      theme: new ThemeData(accentColor: Colors.redAccent)));
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

final scaffoldKey = new GlobalKey();

class _MyAppState extends State<MyApp> {
  Mode _mode = Mode.overlay;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      key: scaffoldKey,
      appBar: new AppBar(
        title: new Text("My App"),
      ),
      body: new Center(
          child: new Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          new DropdownButton(
              value: _mode,
              items: <DropdownMenuItem<Mode>>[
                new DropdownMenuItem<Mode>(
                    child: new Text("Overlay"), value: Mode.overlay),
                new DropdownMenuItem<Mode>(
                    child: new Text("Fullscreen"), value: Mode.fullscreen),
              ],
              onChanged: (m) {
                setState(() {
                  _mode = m;
                });
              }),
          new RaisedButton(
              onPressed: () async {
                // show input autocomplete with selected mode
                // then get the Prediction selected
                Prediction p = await showGooglePlacesAutocomplete(
                    context: context,
                    apiKey: kGoogleApiKey,
                    mode: _mode,
                    language: "fr",
                    components: [new Component(Component.country, "fr")]);

                if (p != null) {
                  (scaffoldKey.currentState as ScaffoldState).showSnackBar(
                      new SnackBar(content: new Text(p.description)));
                }
              },
              child: new Text("Search places"))
        ],
      )),
    );
  }
}
1
likes
0
pub points
67%
popularity

Publisher

unverified uploader

Google places autocomplete widgets for flutter.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, google_maps_webservice

More

Packages that depend on flutter_google_places_autocomplete