I am now calling this google map picker from another page. From that page say I call it like this.
Navigator.push(
context,
MaterialPageRoute(builder: (context) => AddressChangePage()),
);
So now here is the codes for my picker page. It call the page all works well. The problem first was on function onPlacePicked I put this function Navigator.of(context).pop(); it didnt as it takes to am empty black page then this work so I put this function ```
Navigator.push(
context,
MaterialPageRoute(builder: (context) => MainSearchPage()),
);
this work but the problem I dont know how to code the back arrow with this same function too?
class AddressChangePage extends StatelessWidget {
// Light Theme
final ThemeData lightTheme = ThemeData.light().copyWith(
// Background color of the FloatingCard
cardColor: Colors.white,
buttonTheme: ButtonThemeData(
// Select here's button color
buttonColor: Color.fromRGBO(0, 116, 226, 1),
textTheme: ButtonTextTheme.primary,
),
);
// Dark Theme
final ThemeData darkTheme = ThemeData.dark().copyWith(
// Background color of the FloatingCard
cardColor: Colors.white,
buttonTheme: ButtonThemeData(
// Select here's button color
buttonColor: Colors.blue,
textTheme: ButtonTextTheme.primary,
),
);
// This widget is the root of your application.
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
title: 'Google Map Place Picker Demo',
theme: lightTheme,
darkTheme: lightTheme,
themeMode: ThemeMode.light,
home: AddressChangeDetails(),
debugShowCheckedModeBanner: false,
);
}
}
class AddressChangeDetails extends StatefulWidget {
final Color cardBackgroundColor = Color(0xFFFFFFFF);
final String logo = Assets.setLocation;
AddressChangeDetails({Key key}) : super(key: key);
static final kInitialPosition = LatLng(5.285153, 100.456238);
@OverRide
_AddressChangeDetailsState createState() => _AddressChangeDetailsState();
}
class _AddressChangeDetailsState extends State {
PickResult selectedPlace;
double _height, _width, _fixedPadding;
String code = "";
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child:
PlacePicker(
apiKey: "**************",
initialPosition: kInitialPosition,
useCurrentLocation: false,
//desiredLocationAccuracy: best,
usePlaceDetailSearch: false,
cameraMoveDebounceInMilliseconds:100,
autoCompleteDebounceInMilliseconds:100,
forceAndroidLocationManager: true,
forceSearchOnZoomChanged : true,
onPlacePicked: (result) {
selectedPlace = result;
Navigator.push(
context,
MaterialPageRoute(builder: (context) => MainSearchPage()),
);
setState(() {});
},
myLocationButtonCooldown : 5,
//autocompleteLanguage: "eng",
region: 'my',
selectInitialPosition: true,
)
)
);
}
}