mappls_place_widget 1.0.2 mappls_place_widget: ^1.0.2 copied to clipboard
A Flutter plugin for integrating Mappls Search widget in a Flutter application on Android and iOS platfroms.
import 'package:flutter/material.dart';
import 'package:mappls_place_flutter_example/PickerSettingsWidget.dart';
import 'package:mappls_place_flutter_example/SearchSettingsWidget.dart';
import 'package:mappls_gl/mappls_gl.dart';
import 'package:mappls_place_flutter_example/place_search_widget.dart';
import 'package:mappls_place_flutter_example/place_picker_widget.dart';
void main() {
runApp(MaterialApp(
home: MyApp(),
routes: <String, WidgetBuilder>{
'/PlaceSearchWidget': (BuildContext context) => PlaceSearchWidget(),
'/PlacePickerWidget': (BuildContext context) => PlacePickerWidget(),
'/PickerSettings':(BuildContext context) => PickerSettingsWidget(),
'/SearchSettings':(BuildContext context) => SearchSettingsWidget(),
},
));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
static const String MAP_SDK_KEY = "";
static const String REST_API_KEY = "";
static const String ATLAS_CLIENT_ID = "";
static const String ATLAS_CLIENT_SECRET = "";
@override
void initState() {
super.initState();
MapplsAccountManager.setMapSDKKey(MAP_SDK_KEY);
MapplsAccountManager.setRestAPIKey(REST_API_KEY);
MapplsAccountManager.setAtlasClientId(ATLAS_CLIENT_ID);
MapplsAccountManager.setAtlasClientSecret(ATLAS_CLIENT_SECRET);
}
// Platform messages are asynchronous, so we initialize in an async method.
openPlaceSearch(BuildContext context) {
Navigator.pushNamed(context, '/PlaceSearchWidget');
}
// Platform messages are asynchronous, so we initialize in an async method.
openPlacePicker(BuildContext context) {
Navigator.pushNamed(context, '/PlacePickerWidget');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(children: [
SizedBox(
height: 20,
),
TextButton(
onPressed: () => openPlaceSearch(context),
child: Text("Place Autocomplete")),
SizedBox(
height: 20,
),
TextButton(
onPressed: () => openPlacePicker(context),
child: Text("Place Picker")),
]),
)
);
}
}