forked from eatvio/eatvio_app
fix: black screen
This commit is contained in:
@@ -6,7 +6,6 @@ import 'package:eatvio_app/core/widgets/custom_text_form_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:location/location.dart';
|
||||
|
||||
class CityOfLivingScreen extends StatefulWidget {
|
||||
final UserRegistrationSheet sheet;
|
||||
@@ -33,50 +32,6 @@ class _CityOfLivingScreenState extends State<CityOfLivingScreen> {
|
||||
if (widget.sheet.location.isNotEmpty) {
|
||||
cityController.text = widget.sheet.location;
|
||||
}
|
||||
tryGetLocation();
|
||||
}
|
||||
|
||||
tryGetLocation() async {
|
||||
final LocationData? locationData = await getLocationData();
|
||||
if (locationData != null) {
|
||||
final List<String> locations = await context
|
||||
.read<RegistrationCubit>()
|
||||
.getLocationsByCoordinates(locationData.latitude.toString(), locationData.longitude.toString());
|
||||
final registrationCubit = context.read<RegistrationCubit>();
|
||||
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(location: locations.first));
|
||||
setState(() {
|
||||
cityController.text = locations.first;
|
||||
suggestionsController.suggestions = locations;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<LocationData?> getLocationData() async {
|
||||
Location location = new Location();
|
||||
|
||||
bool _serviceEnabled;
|
||||
PermissionStatus _permissionGranted;
|
||||
LocationData _locationData;
|
||||
|
||||
_serviceEnabled = await location.serviceEnabled();
|
||||
if (!_serviceEnabled) {
|
||||
_serviceEnabled = await location.requestService();
|
||||
if (!_serviceEnabled) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
_permissionGranted = await location.hasPermission();
|
||||
if (_permissionGranted == PermissionStatus.denied) {
|
||||
_permissionGranted = await location.requestPermission();
|
||||
if (_permissionGranted != PermissionStatus.granted) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
_locationData = await location.getLocation();
|
||||
|
||||
return _locationData;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user