Giter VIP home page Giter VIP logo

erchil66 / awesome_place_search Goto Github PK

View Code? Open in Web Editor NEW

This project forked from loritotiago/awesome_place_search

0.0 0.0 0.0 19.51 MB

The awesome_place_search package is a Flutter library that provides a user interface for searching places using the Google Places API. With this package, you can easily implement a location search bar that shows suggestions as the user types.

License: MIT License

Dart 100.00%

awesome_place_search's Introduction

Awesome Place Search

Description

The awesome_place_search package is a Flutter library that provides a user interface for searching places using the Google Places API. With this package, you can easily implement a location search bar that shows suggestions as the user types.

Installation

Add pubspec.yaml

dependencies:
  awesome_place_search: ^1.0.10

Basic

import 'package:flutter/material.dart';

import 'package:awesome_place_search/awesome_place_search.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {

  PredictionModel? prediction;
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Welcome to Flutter',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Welcome to Flutter'),
        ),
        body: Center(
          child: Text(prediction.description??"Prediction is null")
        ),
        floatingActionButton: FloatingActionButton(
            onPressed: () {
                _searchPlaces();
            },
            child: const Icon(Icons.add,
        ),
      ),
      ),
     
    );
  }



  void _searchPlaces(){
     AwesomePlaceSearch(
        context: context,
        key: "Your Google map key", //Insert Your google Api Key
        onTap: (value) async {
           final result = await value;
           setState(() {
                prediction=result;
            });
        },
     ).show();
  }
}

The constructor has 6 attributes:

  • String apiKey is the required attribute. It is the Google Maps API Key your application is using

  • (Future<PredictionModel>) onTap is a callback function called when the user selects one of the autocomplete options.

  • BuildContext context is a locator that is used to track each widget in a tree and locate them and their position in the tree.

  • String hint is the text that suggests what sort of input the field accepts.

  • Widget onError this widget is for customizing searching widgets.

  • Widget onEmpty this widget is for customizing error widgets.


Maintainer

Demo

Awesome Place Search Demo

awesome_place_search's People

Contributors

loritotiago avatar erchil66 avatar marco4763 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.