[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: NoSuchMethodError: The getter 'latitude' was called on null. E/flutter ( 8159): Receiver: null E/flutter ( 8159): Tried calling: latitude
Here's My Code Snippet:
class CustomAppBar extends StatelessWidget {
const CustomAppBar({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
FirebaseService _service = FirebaseService();
return FutureBuilder<DocumentSnapshot>(
future: _service.users.doc(_service.user.uid).get(),
builder:
(BuildContext context, AsyncSnapshot<DocumentSnapshot> snapshot) {
if (snapshot.hasError) {
return Text("Something went wrong");
}
if (snapshot.hasData && !snapshot.data.exists) {
return Text("Address not selected");
}
if (snapshot.connectionState == ConnectionState.done) {
Map<String, dynamic> data = snapshot.data.data() as Map<String, dynamic>;
if(data['address']==null){
if(data['state']==null){
GeoPoint latLong = data['location'];
_service.getAddress(latLong.latitude, latLong.longitude).then((adres) {
appBar(adres, context);
});
}
}else{
return appBar(data['address'], context);
}
}
return Text("Fetching Location");
},
);
}