File tree Expand file tree Collapse file tree 5 files changed +17
-16
lines changed
Expand file tree Collapse file tree 5 files changed +17
-16
lines changed Original file line number Diff line number Diff line change 3131 dart run build_runner build -d
3232 - run : flutter test
3333 - run : flutter build apk --release
34+ - run : flutter build apk --debug
3435 - name : Push to Releases
3536 uses : ncipollo/release-action@v1
3637 with :
Original file line number Diff line number Diff line change @@ -15,11 +15,11 @@ class WeatherRepository extends ChangeNotifier {
1515
1616 void getWeatherForCurrentLocation () async {
1717 final locationData = await locationRepo.initLocationData ();
18- if ( locationData == null ) return ;
18+ print ( "Calling current whether ${ locationData ?. latitude } ${ locationData ?. longitude } " ) ;
1919 try {
2020 currentWeather = await _apiClient.fetchCurrentWeather (
21- locationData.latitude ?? 0 ,
22- locationData.longitude ?? 0 ,
21+ locationData? .latitude ?? 0 ,
22+ locationData? .longitude ?? 0 ,
2323 useDummyData: true ,
2424 );
2525 } catch (error) {
Original file line number Diff line number Diff line change @@ -19,10 +19,10 @@ class ForecastWeatherRepository extends ChangeNotifier {
1919 void getWeatherForcast () async {
2020 try {
2121 final locationData = await locationRepo.initLocationData ();
22- if (locationData == null ) return ;
22+
2323 forcastWeather = await _apiClient.fetchForcastWeather (
24- locationData.latitude ?? 0.0 ,
25- locationData.longitude ?? 0.0 ,
24+ locationData? .latitude ?? 0.0 ,
25+ locationData? .longitude ?? 0.0 ,
2626 useDummyData: true ,
2727 );
2828 if (forcastWeather == null ) throw WeatherRequestFailure ();
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class LocationRepository extends ChangeNotifier {
1515 // This is terrible! There is a known bug that crashes the app because the android system for location has not been enabled by the time it gets here
1616 // Note: This only happened when running the app in release mode (-_-)
1717 // See: https://stackoverflow.com/questions/67663357/flutter-location-package-generates-platform-exception-on-call-to-serviceenabled
18+
1819 try {
1920 _serviceEnabled = await locationService.serviceEnabled ();
2021 } on PlatformException catch (err) {
@@ -27,7 +28,6 @@ class LocationRepository extends ChangeNotifier {
2728 if (! _serviceEnabled) {
2829 _serviceEnabled = await locationService.requestService ();
2930 if (! _serviceEnabled) {
30- notifyListeners ();
3131 return null ;
3232 }
3333 }
@@ -36,11 +36,10 @@ class LocationRepository extends ChangeNotifier {
3636 if (_permissionGranted == PermissionStatus .denied) {
3737 _permissionGranted = await locationService.requestPermission ();
3838 if (_permissionGranted != PermissionStatus .granted) {
39- notifyListeners ();
4039 return null ;
4140 }
4241 }
43-
42+ hasPermissions = true ;
4443 _locationData = await locationService.getLocation ();
4544 notifyListeners ();
4645 return _locationData;
Original file line number Diff line number Diff line change @@ -16,10 +16,17 @@ void main() async {
1616 runApp (
1717 MultiProvider (
1818 providers: [
19+ ChangeNotifierProvider <LocationRepository >(
20+ create: (context) {
21+ return locationRepository;
22+ },
23+ ),
1924 ChangeNotifierProvider <WeatherRepository >(
2025 create: (context) {
2126 WeatherRepository repository = WeatherRepository (
22- apiClient: apiClient, locationRepo: locationRepository);
27+ apiClient: apiClient,
28+ locationRepo: locationRepository,
29+ );
2330
2431 repository.getWeatherForCurrentLocation ();
2532 return repository;
@@ -29,16 +36,10 @@ void main() async {
2936 create: (context) {
3037 ForecastWeatherRepository repository = ForecastWeatherRepository (
3138 apiClient: apiClient, locationRepo: locationRepository);
32-
3339 repository.getWeatherForcast ();
3440 return repository;
3541 },
3642 ),
37- ChangeNotifierProvider <LocationRepository >(
38- create: (context) {
39- return locationRepository;
40- },
41- )
4243 ],
4344 child: const WeatherApp (),
4445 ),
You can’t perform that action at this time.
0 commit comments