diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..50f15ce
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+.dart_tool/
+build/
+pubspec.lock
+.flutter-plugins
+.flutter-plugins-dependencies
+.packages
+android/.gradle
\ No newline at end of file
diff --git a/android/android.iml b/android/android.iml
new file mode 100644
index 0000000..096e667
--- /dev/null
+++ b/android/android.iml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/app/app.iml b/android/app/app.iml
new file mode 100644
index 0000000..a596c67
--- /dev/null
+++ b/android/app/app.iml
@@ -0,0 +1,155 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 22a4d07..25fa1e9 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -15,7 +15,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
- compileSdkVersion 27
+ compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
@@ -25,10 +25,10 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.weather"
minSdkVersion 16
- targetSdkVersion 27
+ targetSdkVersion 28
versionCode 1
versionName "1.0"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -46,6 +46,6 @@ flutter {
dependencies {
testImplementation 'junit:junit:4.12'
- androidTestImplementation 'com.android.support.test:runner:1.0.1'
- androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
+ androidTestImplementation 'androidx.test:runner:1.1.0'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
diff --git a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
index 7e29746..ea1cc21 100644
--- a/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
+++ b/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
@@ -1,7 +1,9 @@
package io.flutter.plugins;
import io.flutter.plugin.common.PluginRegistry;
-import io.intheloup.geolocation.GeolocationPlugin;
+import com.baseflow.geolocator.GeolocatorPlugin;
+import com.baseflow.googleapiavailability.GoogleApiAvailabilityPlugin;
+import com.baseflow.location_permissions.LocationPermissionsPlugin;
/**
* Generated file. Do not edit.
@@ -11,7 +13,9 @@ public static void registerWith(PluginRegistry registry) {
if (alreadyRegisteredWith(registry)) {
return;
}
- GeolocationPlugin.registerWith(registry.registrarFor("io.intheloup.geolocation.GeolocationPlugin"));
+ GeolocatorPlugin.registerWith(registry.registrarFor("com.baseflow.geolocator.GeolocatorPlugin"));
+ GoogleApiAvailabilityPlugin.registerWith(registry.registrarFor("com.baseflow.googleapiavailability.GoogleApiAvailabilityPlugin"));
+ LocationPermissionsPlugin.registerWith(registry.registrarFor("com.baseflow.location_permissions.LocationPermissionsPlugin"));
}
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
diff --git a/android/build.gradle b/android/build.gradle
index b2483d3..8ada0cd 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -5,7 +5,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.1'
+ classpath 'com.android.tools.build:gradle:3.4.0'
}
}
diff --git a/android/gradle.properties b/android/gradle.properties
index b472197..2a7ccd6 100644
--- a/android/gradle.properties
+++ b/android/gradle.properties
@@ -1 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
+android.useAndroidX=true
+android.enableJetifier=true
+android.enableR8=true
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index 651b997..0884226 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Fri Jun 23 08:50:38 CEST 2017
+#Tue May 07 05:57:35 EDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
diff --git a/android/gradlew b/android/gradlew
index 9d82f78..e834973 100644
--- a/android/gradlew
+++ b/android/gradlew
@@ -1,160 +1,160 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/android/local.properties b/android/local.properties
index 163442f..b27cb4d 100644
--- a/android/local.properties
+++ b/android/local.properties
@@ -1,3 +1,5 @@
-sdk.dir=C:\\Users\\jking\\AppData\\Local\\Android\\sdk
-flutter.sdk=C:\\flutter
-flutter.buildMode=debug
\ No newline at end of file
+sdk.dir=C:\\Users\\jking\\AppData\\Local\\Android\\Sdk
+flutter.sdk=c:\\flutter
+flutter.buildMode=debug
+flutter.versionName=1.0.0
+flutter.versionCode=1
\ No newline at end of file
diff --git a/ios/Flutter/Generated.xcconfig b/ios/Flutter/Generated.xcconfig
index bd68c00..b5d7c82 100644
--- a/ios/Flutter/Generated.xcconfig
+++ b/ios/Flutter/Generated.xcconfig
@@ -1,8 +1,9 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=C:\flutter
-FLUTTER_APPLICATION_PATH=c:\Projects\dart\weather
-FLUTTER_TARGET=lib/main.dart
-FLUTTER_BUILD_MODE=debug
+FLUTTER_APPLICATION_PATH=C:\Projects\dart\Weather_Tutorial
+FLUTTER_TARGET=lib\main.dart
FLUTTER_BUILD_DIR=build
SYMROOT=${SOURCE_ROOT}/../build\ios
FLUTTER_FRAMEWORK_DIR=C:\flutter\bin\cache\artifacts\engine\ios
+FLUTTER_BUILD_NAME=1.0.0
+FLUTTER_BUILD_NUMBER=1
diff --git a/ios/Runner/GeneratedPluginRegistrant.h b/ios/Runner/GeneratedPluginRegistrant.h
index 3b700eb..ed9a5c6 100644
--- a/ios/Runner/GeneratedPluginRegistrant.h
+++ b/ios/Runner/GeneratedPluginRegistrant.h
@@ -7,8 +7,11 @@
#import
+NS_ASSUME_NONNULL_BEGIN
+
@interface GeneratedPluginRegistrant : NSObject
+ (void)registerWithRegistry:(NSObject*)registry;
@end
+NS_ASSUME_NONNULL_END
#endif /* GeneratedPluginRegistrant_h */
diff --git a/ios/Runner/GeneratedPluginRegistrant.m b/ios/Runner/GeneratedPluginRegistrant.m
index f1cc452..c20fe77 100644
--- a/ios/Runner/GeneratedPluginRegistrant.m
+++ b/ios/Runner/GeneratedPluginRegistrant.m
@@ -3,12 +3,31 @@
//
#import "GeneratedPluginRegistrant.h"
-#import
+
+#if __has_include()
+#import
+#else
+@import geolocator;
+#endif
+
+#if __has_include()
+#import
+#else
+@import google_api_availability;
+#endif
+
+#if __has_include()
+#import
+#else
+@import location_permissions;
+#endif
@implementation GeneratedPluginRegistrant
+ (void)registerWithRegistry:(NSObject*)registry {
- [GeolocationPlugin registerWithRegistrar:[registry registrarForPlugin:@"GeolocationPlugin"]];
+ [GeolocatorPlugin registerWithRegistrar:[registry registrarForPlugin:@"GeolocatorPlugin"]];
+ [GoogleApiAvailabilityPlugin registerWithRegistrar:[registry registrarForPlugin:@"GoogleApiAvailabilityPlugin"]];
+ [LocationPermissionsPlugin registerWithRegistrar:[registry registrarForPlugin:@"LocationPermissionsPlugin"]];
}
@end
diff --git a/lib/const.dart b/lib/const.dart
index b6e19dc..13c4cc9 100644
--- a/lib/const.dart
+++ b/lib/const.dart
@@ -1 +1 @@
-const API_KEY = '[Your API KEY]';
+const API_KEY = 'a36c098a4a27c22e4afeae0f05b26a67';
diff --git a/lib/json/response.dart b/lib/json/response.dart
index b35d6e5..28a75e0 100644
--- a/lib/json/response.dart
+++ b/lib/json/response.dart
@@ -3,7 +3,7 @@ import 'package:json_annotation/json_annotation.dart';
part 'response.g.dart';
@JsonSerializable()
-class BaseResponse extends Object with _$BaseResponseSerializerMixin {
+class BaseResponse {
final String message;
final String cod;
final int count;
@@ -20,10 +20,12 @@ class BaseResponse extends Object with _$BaseResponseSerializerMixin {
factory BaseResponse.fromJson(Map json) =>
_$BaseResponseFromJson(json);
+
+ Map toJson() => _$BaseResponseToJson(this);
}
@JsonSerializable()
-class City extends Object with _$CitySerializerMixin {
+class City {
final int id;
final String name;
final Coord coord;
@@ -49,10 +51,11 @@ class City extends Object with _$CitySerializerMixin {
this.weather,
);
factory City.fromJson(Map json) => _$CityFromJson(json);
+ Map toJson() => _$CityToJson(this);
}
@JsonSerializable()
-class Coord extends Object with _$CoordSerializerMixin {
+class Coord {
final double lat;
final double lon;
Coord(this.lat, this.lon);
@@ -61,7 +64,7 @@ class Coord extends Object with _$CoordSerializerMixin {
}
@JsonSerializable()
-class Main extends Object with _$MainSerializerMixin {
+class Main {
final double temp;
final double pressure;
final int humidity;
@@ -83,7 +86,7 @@ class Main extends Object with _$MainSerializerMixin {
}
@JsonSerializable()
-class Wind extends Object with _$WindSerializerMixin {
+class Wind {
final double speed;
final double deg;
@@ -99,7 +102,7 @@ class Wind extends Object with _$WindSerializerMixin {
}
@JsonSerializable()
-class Rain extends Object with _$RainSerializerMixin {
+class Rain {
@JsonKey(name: "3h")
final double threeHour;
Rain(this.threeHour);
@@ -108,7 +111,7 @@ class Rain extends Object with _$RainSerializerMixin {
}
@JsonSerializable()
-class Clouds extends Object with _$CloudsSerializerMixin {
+class Clouds {
Clouds({this.all});
final int all;
@@ -116,7 +119,7 @@ class Clouds extends Object with _$CloudsSerializerMixin {
}
@JsonSerializable()
-class Weather extends Object with _$WeatherSerializerMixin {
+class Weather {
Weather({
this.id,
this.main,
diff --git a/lib/json/response.g.dart b/lib/json/response.g.dart
index fa4b331..614e033 100644
--- a/lib/json/response.g.dart
+++ b/lib/json/response.g.dart
@@ -3,154 +3,127 @@
part of 'response.dart';
// **************************************************************************
-// Generator: JsonSerializableGenerator
+// JsonSerializableGenerator
// **************************************************************************
-BaseResponse _$BaseResponseFromJson(Map json) =>
- new BaseResponse(
- json['message'] as String,
- json['cod'] as String,
- json['count'] as int,
- (json['list'] as List)
- ?.map((e) =>
- e == null ? null : new City.fromJson(e as Map))
- ?.toList());
-
-abstract class _$BaseResponseSerializerMixin {
- String get message;
- String get cod;
- int get count;
- List get cities;
- Map toJson() => {
- 'message': message,
- 'cod': cod,
- 'count': count,
- 'list': cities
- };
+BaseResponse _$BaseResponseFromJson(Map json) {
+ return BaseResponse(
+ json['message'] as String,
+ json['cod'] as String,
+ json['count'] as int,
+ (json['list'] as List)
+ ?.map((e) =>
+ e == null ? null : City.fromJson(e as Map))
+ ?.toList());
}
-City _$CityFromJson(Map json) => new City(
- json['id'] as int,
- json['name'] as String,
- json['coord'] == null
- ? null
- : new Coord.fromJson(json['coord'] as Map),
- json['main'] == null
- ? null
- : new Main.fromJson(json['main'] as Map),
- json['dt'] as int,
- json['wind'] == null
- ? null
- : new Wind.fromJson(json['wind'] as Map),
- json['rain'] == null
- ? null
- : new Rain.fromJson(json['rain'] as Map),
- json['clouds'] == null
- ? null
- : new Clouds.fromJson(json['clouds'] as Map),
- (json['weather'] as List)
- ?.map((e) =>
- e == null ? null : new Weather.fromJson(e as Map))
- ?.toList());
-
-abstract class _$CitySerializerMixin {
- int get id;
- String get name;
- Coord get coord;
- Main get main;
- int get dt;
- Wind get wind;
- Rain get rain;
- Clouds get clouds;
- List get weather;
- Map toJson() => {
- 'id': id,
- 'name': name,
- 'coord': coord,
- 'main': main,
- 'dt': dt,
- 'wind': wind,
- 'rain': rain,
- 'clouds': clouds,
- 'weather': weather
- };
+Map _$BaseResponseToJson(BaseResponse instance) =>
+ {
+ 'message': instance.message,
+ 'cod': instance.cod,
+ 'count': instance.count,
+ 'list': instance.cities
+ };
+
+City _$CityFromJson(Map json) {
+ return City(
+ json['id'] as int,
+ json['name'] as String,
+ json['coord'] == null
+ ? null
+ : Coord.fromJson(json['coord'] as Map),
+ json['main'] == null
+ ? null
+ : Main.fromJson(json['main'] as Map),
+ json['dt'] as int,
+ json['wind'] == null
+ ? null
+ : Wind.fromJson(json['wind'] as Map),
+ json['rain'] == null
+ ? null
+ : Rain.fromJson(json['rain'] as Map),
+ json['clouds'] == null
+ ? null
+ : Clouds.fromJson(json['clouds'] as Map),
+ (json['weather'] as List)
+ ?.map((e) =>
+ e == null ? null : Weather.fromJson(e as Map))
+ ?.toList());
}
-Coord _$CoordFromJson(Map json) => new Coord(
- (json['lat'] as num)?.toDouble(), (json['lon'] as num)?.toDouble());
-
-abstract class _$CoordSerializerMixin {
- double get lat;
- double get lon;
- Map toJson() => {'lat': lat, 'lon': lon};
+Map _$CityToJson(City instance) => {
+ 'id': instance.id,
+ 'name': instance.name,
+ 'coord': instance.coord,
+ 'main': instance.main,
+ 'dt': instance.dt,
+ 'wind': instance.wind,
+ 'rain': instance.rain,
+ 'clouds': instance.clouds,
+ 'weather': instance.weather
+ };
+
+Coord _$CoordFromJson(Map json) {
+ return Coord(
+ (json['lat'] as num)?.toDouble(), (json['lon'] as num)?.toDouble());
}
-Main _$MainFromJson(Map json) => new Main(
- (json['temp'] as num)?.toDouble(),
- (json['pressure'] as num)?.toDouble(),
- json['humidity'] as int,
- (json['temp_max'] as num)?.toDouble(),
- (json['temp_min'] as num)?.toDouble());
-
-abstract class _$MainSerializerMixin {
- double get temp;
- double get pressure;
- int get humidity;
- double get tempMax;
- double get tempMin;
- Map toJson() => {
- 'temp': temp,
- 'pressure': pressure,
- 'humidity': humidity,
- 'temp_max': tempMax,
- 'temp_min': tempMin
- };
+Map _$CoordToJson(Coord instance) =>
+ {'lat': instance.lat, 'lon': instance.lon};
+
+Main _$MainFromJson(Map json) {
+ return Main(
+ (json['temp'] as num)?.toDouble(),
+ (json['pressure'] as num)?.toDouble(),
+ json['humidity'] as int,
+ (json['temp_max'] as num)?.toDouble(),
+ (json['temp_min'] as num)?.toDouble());
}
-Wind _$WindFromJson(Map json) => new Wind(
- (json['speed'] as num)?.toDouble(),
- (json['deg'] as num)?.toDouble(),
- (json['gust'] as num)?.toDouble());
-
-abstract class _$WindSerializerMixin {
- double get speed;
- double get deg;
- double get gust;
- Map toJson() =>
- {'speed': speed, 'deg': deg, 'gust': gust};
+Map _$MainToJson(Main instance) => {
+ 'temp': instance.temp,
+ 'pressure': instance.pressure,
+ 'humidity': instance.humidity,
+ 'temp_max': instance.tempMax,
+ 'temp_min': instance.tempMin
+ };
+
+Wind _$WindFromJson(Map json) {
+ return Wind((json['speed'] as num)?.toDouble(),
+ (json['deg'] as num)?.toDouble(), (json['gust'] as num)?.toDouble());
}
-Rain _$RainFromJson(Map json) =>
- new Rain((json['3h'] as num)?.toDouble());
+Map _$WindToJson(Wind instance) => {
+ 'speed': instance.speed,
+ 'deg': instance.deg,
+ 'gust': instance.gust
+ };
-abstract class _$RainSerializerMixin {
- double get threeHour;
- Map toJson() => {'3h': threeHour};
+Rain _$RainFromJson(Map json) {
+ return Rain((json['3h'] as num)?.toDouble());
}
-Clouds _$CloudsFromJson(Map json) =>
- new Clouds(all: json['all'] as int);
+Map _$RainToJson(Rain instance) =>
+ {'3h': instance.threeHour};
-abstract class _$CloudsSerializerMixin {
- int get all;
- Map toJson() => {'all': all};
+Clouds _$CloudsFromJson(Map json) {
+ return Clouds(all: json['all'] as int);
}
-Weather _$WeatherFromJson(Map json) => new Weather(
- id: json['id'] as int,
- main: json['main'] as String,
- description: json['description'] as String,
- icon: json['icon'] as String);
-
-abstract class _$WeatherSerializerMixin {
- int get id;
- String get main;
- String get description;
- String get icon;
- Map toJson() => {
- 'id': id,
- 'main': main,
- 'description': description,
- 'icon': icon
- };
+Map _$CloudsToJson(Clouds instance) =>
+ {'all': instance.all};
+
+Weather _$WeatherFromJson(Map json) {
+ return Weather(
+ id: json['id'] as int,
+ main: json['main'] as String,
+ description: json['description'] as String,
+ icon: json['icon'] as String);
}
+
+Map _$WeatherToJson(Weather instance) => {
+ 'id': instance.id,
+ 'main': instance.main,
+ 'description': instance.description,
+ 'icon': instance.icon
+ };
diff --git a/lib/l10n/intl_messages.arb b/lib/l10n/intl_messages.arb
index 6758b8f..7095d1e 100644
--- a/lib/l10n/intl_messages.arb
+++ b/lib/l10n/intl_messages.arb
@@ -1,15 +1,15 @@
-{
- "@@last_modified": "2018-04-27T17:16:00.180810",
- "title": "Weather Application",
- "@title": {
- "description": "Title for the Weather Application",
- "type": "text",
- "placeholders": {}
- },
- "button": "Get the Weather",
- "@button": {
- "description": "get weather button",
- "type": "text",
- "placeholders": {}
- }
+{
+ "@@last_modified": "2018-04-27T17:16:00.180810",
+ "title": "Weather Application",
+ "@title": {
+ "description": "Title for the Weather Application",
+ "type": "text",
+ "placeholders": {}
+ },
+ "button": "Get the Weather",
+ "@button": {
+ "description": "get weather button",
+ "type": "text",
+ "placeholders": {}
+ }
}
\ No newline at end of file
diff --git a/lib/l10n/messages_all.dart b/lib/l10n/messages_all.dart
index ec21e4c..16eac54 100644
--- a/lib/l10n/messages_all.dart
+++ b/lib/l10n/messages_all.dart
@@ -1,69 +1,69 @@
-// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
-// This is a library that looks up messages for specific locales by
-// delegating to the appropriate library.
-
-import 'dart:async';
-
-import 'package:intl/intl.dart';
-import 'package:intl/message_lookup_by_library.dart';
-// ignore: implementation_imports
-import 'package:intl/src/intl_helpers.dart';
-
-import 'messages_es.dart' as messages_es;
-import 'messages_en.dart' as messages_en;
-import 'messages_messages.dart' as messages_messages;
-import 'messages_ja.dart' as messages_ja;
-
-typedef Future LibraryLoader();
-Map _deferredLibraries = {
- 'es': () => new Future.value(null),
- 'en': () => new Future.value(null),
- 'messages': () => new Future.value(null),
- 'ja': () => new Future.value(null),
-};
-
-MessageLookupByLibrary _findExact(localeName) {
- switch (localeName) {
- case 'es':
- return messages_es.messages;
- case 'en':
- return messages_en.messages;
- case 'messages':
- return messages_messages.messages;
- case 'ja':
- return messages_ja.messages;
- default:
- return null;
- }
-}
-
-/// User programs should call this before using [localeName] for messages.
-Future initializeMessages(String localeName) async {
- var availableLocale = Intl.verifiedLocale(
- localeName,
- (locale) => _deferredLibraries[locale] != null,
- onFailure: (_) => null);
- if (availableLocale == null) {
- return new Future.value(false);
- }
- var lib = _deferredLibraries[availableLocale];
- await (lib == null ? new Future.value(false) : lib());
- initializeInternalMessageLookup(() => new CompositeMessageLookup());
- messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
- return new Future.value(true);
-}
-
-bool _messagesExistFor(String locale) {
- try {
- return _findExact(locale) != null;
- } catch (e) {
- return false;
- }
-}
-
-MessageLookupByLibrary _findGeneratedMessagesFor(locale) {
- var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor,
- onFailure: (_) => null);
- if (actualLocale == null) return null;
- return _findExact(actualLocale);
-}
+// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
+// This is a library that looks up messages for specific locales by
+// delegating to the appropriate library.
+
+import 'dart:async';
+
+import 'package:intl/intl.dart';
+import 'package:intl/message_lookup_by_library.dart';
+// ignore: implementation_imports
+import 'package:intl/src/intl_helpers.dart';
+
+import 'messages_es.dart' as messages_es;
+import 'messages_en.dart' as messages_en;
+import 'messages_messages.dart' as messages_messages;
+import 'messages_ja.dart' as messages_ja;
+
+typedef Future LibraryLoader();
+Map _deferredLibraries = {
+ 'es': () => new Future.value(null),
+ 'en': () => new Future.value(null),
+ 'messages': () => new Future.value(null),
+ 'ja': () => new Future.value(null),
+};
+
+MessageLookupByLibrary _findExact(localeName) {
+ switch (localeName) {
+ case 'es':
+ return messages_es.messages;
+ case 'en':
+ return messages_en.messages;
+ case 'messages':
+ return messages_messages.messages;
+ case 'ja':
+ return messages_ja.messages;
+ default:
+ return null;
+ }
+}
+
+/// User programs should call this before using [localeName] for messages.
+Future initializeMessages(String localeName) async {
+ var availableLocale = Intl.verifiedLocale(
+ localeName,
+ (locale) => _deferredLibraries[locale] != null,
+ onFailure: (_) => null);
+ if (availableLocale == null) {
+ return new Future.value(false);
+ }
+ var lib = _deferredLibraries[availableLocale];
+ await (lib == null ? new Future.value(false) : lib());
+ initializeInternalMessageLookup(() => new CompositeMessageLookup());
+ messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor);
+ return new Future.value(true);
+}
+
+bool _messagesExistFor(String locale) {
+ try {
+ return _findExact(locale) != null;
+ } catch (e) {
+ return false;
+ }
+}
+
+MessageLookupByLibrary _findGeneratedMessagesFor(locale) {
+ var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor,
+ onFailure: (_) => null);
+ if (actualLocale == null) return null;
+ return _findExact(actualLocale);
+}
diff --git a/lib/l10n/messages_en.dart b/lib/l10n/messages_en.dart
index f2e37c3..52e03f1 100644
--- a/lib/l10n/messages_en.dart
+++ b/lib/l10n/messages_en.dart
@@ -1,25 +1,25 @@
-// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
-// This is a library that provides messages for a en locale. All the
-// messages from the main program should be duplicated here with the same
-// function name.
-
-import 'package:intl/intl.dart';
-import 'package:intl/message_lookup_by_library.dart';
-
-final messages = new MessageLookup();
-
-// ignore: unused_element
-final _keepAnalysisHappy = Intl.defaultLocale;
-
-// ignore: non_constant_identifier_names
-typedef MessageIfAbsent(String message_str, List args);
-
-class MessageLookup extends MessageLookupByLibrary {
- get localeName => 'en';
-
- final messages = _notInlinedMessages(_notInlinedMessages);
- static _notInlinedMessages(_) => {
- "title": MessageLookupByLibrary.simpleMessage("Weather Application"),
- "button": MessageLookupByLibrary.simpleMessage("Get the Weather")
- };
-}
+// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
+// This is a library that provides messages for a en locale. All the
+// messages from the main program should be duplicated here with the same
+// function name.
+
+import 'package:intl/intl.dart';
+import 'package:intl/message_lookup_by_library.dart';
+
+final messages = new MessageLookup();
+
+// ignore: unused_element
+final _keepAnalysisHappy = Intl.defaultLocale;
+
+// ignore: non_constant_identifier_names
+typedef MessageIfAbsent(String message_str, List args);
+
+class MessageLookup extends MessageLookupByLibrary {
+ get localeName => 'en';
+
+ final messages = _notInlinedMessages(_notInlinedMessages);
+ static _notInlinedMessages(_) => {
+ "title": MessageLookupByLibrary.simpleMessage("Weather Application"),
+ "button": MessageLookupByLibrary.simpleMessage("Get the Weather")
+ };
+}
diff --git a/lib/l10n/messages_es.dart b/lib/l10n/messages_es.dart
index 69404c1..0810db9 100644
--- a/lib/l10n/messages_es.dart
+++ b/lib/l10n/messages_es.dart
@@ -1,26 +1,26 @@
-// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
-// This is a library that provides messages for a es locale. All the
-// messages from the main program should be duplicated here with the same
-// function name.
-
-import 'package:intl/intl.dart';
-import 'package:intl/message_lookup_by_library.dart';
-
-final messages = new MessageLookup();
-
-// ignore: unused_element
-final _keepAnalysisHappy = Intl.defaultLocale;
-
-// ignore: non_constant_identifier_names
-typedef MessageIfAbsent(String message_str, List args);
-
-class MessageLookup extends MessageLookupByLibrary {
- get localeName => 'es';
-
- final messages = _notInlinedMessages(_notInlinedMessages);
- static _notInlinedMessages(_) => {
- "title":
- MessageLookupByLibrary.simpleMessage("Aplicación Meteorológica"),
- "button": MessageLookupByLibrary.simpleMessage("Obtener el Clima")
- };
-}
+// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
+// This is a library that provides messages for a es locale. All the
+// messages from the main program should be duplicated here with the same
+// function name.
+
+import 'package:intl/intl.dart';
+import 'package:intl/message_lookup_by_library.dart';
+
+final messages = new MessageLookup();
+
+// ignore: unused_element
+final _keepAnalysisHappy = Intl.defaultLocale;
+
+// ignore: non_constant_identifier_names
+typedef MessageIfAbsent(String message_str, List args);
+
+class MessageLookup extends MessageLookupByLibrary {
+ get localeName => 'es';
+
+ final messages = _notInlinedMessages(_notInlinedMessages);
+ static _notInlinedMessages(_) => {
+ "title":
+ MessageLookupByLibrary.simpleMessage("Aplicación Meteorológica"),
+ "button": MessageLookupByLibrary.simpleMessage("Obtener el Clima")
+ };
+}
diff --git a/lib/l10n/messages_ja.dart b/lib/l10n/messages_ja.dart
index 9f2a089..f976165 100644
--- a/lib/l10n/messages_ja.dart
+++ b/lib/l10n/messages_ja.dart
@@ -1,25 +1,25 @@
-// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
-// This is a library that provides messages for a ja locale. All the
-// messages from the main program should be duplicated here with the same
-// function name.
-
-import 'package:intl/intl.dart';
-import 'package:intl/message_lookup_by_library.dart';
-
-final messages = new MessageLookup();
-
-// ignore: unused_element
-final _keepAnalysisHappy = Intl.defaultLocale;
-
-// ignore: non_constant_identifier_names
-typedef MessageIfAbsent(String message_str, List args);
-
-class MessageLookup extends MessageLookupByLibrary {
- get localeName => 'ja';
-
- final messages = _notInlinedMessages(_notInlinedMessages);
- static _notInlinedMessages(_) => {
- "title": MessageLookupByLibrary.simpleMessage("天気アプリケーション"),
- "button": MessageLookupByLibrary.simpleMessage("天気を取る")
- };
-}
+// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
+// This is a library that provides messages for a ja locale. All the
+// messages from the main program should be duplicated here with the same
+// function name.
+
+import 'package:intl/intl.dart';
+import 'package:intl/message_lookup_by_library.dart';
+
+final messages = new MessageLookup();
+
+// ignore: unused_element
+final _keepAnalysisHappy = Intl.defaultLocale;
+
+// ignore: non_constant_identifier_names
+typedef MessageIfAbsent(String message_str, List args);
+
+class MessageLookup extends MessageLookupByLibrary {
+ get localeName => 'ja';
+
+ final messages = _notInlinedMessages(_notInlinedMessages);
+ static _notInlinedMessages(_) => {
+ "title": MessageLookupByLibrary.simpleMessage("天気アプリケーション"),
+ "button": MessageLookupByLibrary.simpleMessage("天気を取る")
+ };
+}
diff --git a/lib/l10n/messages_messages.dart b/lib/l10n/messages_messages.dart
index 5c425a7..afa05a2 100644
--- a/lib/l10n/messages_messages.dart
+++ b/lib/l10n/messages_messages.dart
@@ -1,25 +1,25 @@
-// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
-// This is a library that provides messages for a messages locale. All the
-// messages from the main program should be duplicated here with the same
-// function name.
-
-import 'package:intl/intl.dart';
-import 'package:intl/message_lookup_by_library.dart';
-
-final messages = new MessageLookup();
-
-// ignore: unused_element
-final _keepAnalysisHappy = Intl.defaultLocale;
-
-// ignore: non_constant_identifier_names
-typedef MessageIfAbsent(String message_str, List args);
-
-class MessageLookup extends MessageLookupByLibrary {
- get localeName => 'messages';
-
- final messages = _notInlinedMessages(_notInlinedMessages);
- static _notInlinedMessages(_) => {
- "title": MessageLookupByLibrary.simpleMessage("Weather Application"),
- "button": MessageLookupByLibrary.simpleMessage("Get the Weather")
- };
-}
+// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart
+// This is a library that provides messages for a messages locale. All the
+// messages from the main program should be duplicated here with the same
+// function name.
+
+import 'package:intl/intl.dart';
+import 'package:intl/message_lookup_by_library.dart';
+
+final messages = new MessageLookup();
+
+// ignore: unused_element
+final _keepAnalysisHappy = Intl.defaultLocale;
+
+// ignore: non_constant_identifier_names
+typedef MessageIfAbsent(String message_str, List args);
+
+class MessageLookup extends MessageLookupByLibrary {
+ get localeName => 'messages';
+
+ final messages = _notInlinedMessages(_notInlinedMessages);
+ static _notInlinedMessages(_) => {
+ "title": MessageLookupByLibrary.simpleMessage("Weather Application"),
+ "button": MessageLookupByLibrary.simpleMessage("Get the Weather")
+ };
+}
diff --git a/lib/main.dart b/lib/main.dart
index cb00d2f..65c63a8 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -7,9 +7,6 @@ import 'package:weather/model/model.dart';
import 'package:weather/model/model_provider.dart';
import 'package:weather/localization/localizations.dart';
-//unimport if you need the initState function stuff.
-
-import 'package:geolocation/geolocation.dart';
import 'package:rx_widgets/rx_widgets.dart';
@@ -48,33 +45,15 @@ class MyApp extends StatelessWidget {
}
}
-class MyHomePage extends StatefulWidget {
- @override
- _MyHomePageState createState() => _MyHomePageState();
-}
-
-class _MyHomePageState extends State {
- @override
- void initState() {
- super.initState();
-
- // If Geolocation is unable to get location in emulator, uncomment this and then restart the program.
- // This tends to fix the error and you can see if the GPS is actually getting the location.
- var x = Geolocation.locationUpdates(
- accuracy: LocationAccuracy.best, inBackground: false);
- x.listen((d) => print(d.isSuccessful));
- }
-
+class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
Locale myLocale = Localizations.localeOf(context);
+ ModelCommand command = ModelProvider.of(context);
//call to getGpsCommand handler on build. If GPS is active comes back with true, else false.
- ModelProvider
- .of(context)
- .changeLocaleCommand
- .call(myLocale.languageCode.toString());
- ModelProvider.of(context).getGpsCommand.call();
+ command.changeLocaleCommand.call(myLocale.languageCode.toString());
+ command.getGpsCommand.call();
return Scaffold(
appBar: AppBar(
@@ -92,18 +71,17 @@ class _MyHomePageState extends State {
child: Center(
child: RxLoader(
radius: 20.0,
- commandResults: ModelProvider.of(context).getGpsCommand,
+ commandResults: command.getGpsCommand.results,
dataBuilder: (context, data) => Row(
- children: [
- Text(data ? "GPS is Active" : "GPS is Inactive"),
- // Added logic to change the Icon when GPS is inactive.
- IconButton(
- icon: Icon(
- data ? Icons.gps_fixed : Icons.gps_not_fixed),
- onPressed: ModelProvider.of(context).getGpsCommand,
- ),
- ],
+ children: [
+ Text(data ? "GPS is Active" : "GPS is Inactive"),
+ // Added logic to change the Icon when GPS is inactive.
+ IconButton(
+ icon: Icon(data ? Icons.gps_fixed : Icons.gps_not_fixed),
+ onPressed: command.getGpsCommand,
),
+ ],
+ ),
placeHolderBuilder: (context) => Text("Push the Button"),
errorBuilder: (context, exception) => Text("$exception"),
),
@@ -134,7 +112,7 @@ class _MyHomePageState extends State {
Expanded(
child: RxLoader>(
radius: 30.0,
- commandResults: ModelProvider.of(context).updateWeatherCommand,
+ commandResults: command.updateWeatherCommand.results,
dataBuilder: (context, data) => WeatherList(data),
placeHolderBuilder: (context) => Center(child: Text("No Data")),
errorBuilder: (context, exception) =>
@@ -148,18 +126,12 @@ class _MyHomePageState extends State {
//changed to expanded for more consistency.
Expanded(
child: WidgetSelector(
- buildEvents: ModelProvider
- .of(context)
- .updateWeatherCommand
- .canExecute,
+ buildEvents: command.updateWeatherCommand.canExecute,
onTrue: MaterialButton(
elevation: 5.0,
color: Colors.blueGrey,
child: Text(AppLocalizations.of(context).button),
- onPressed: ModelProvider
- .of(context)
- .updateLocationStreamCommand
- .call,
+ onPressed: command.updateLocationCommand.call,
),
onFalse: MaterialButton(
elevation: 0.0,
@@ -175,7 +147,7 @@ class _MyHomePageState extends State {
children: [
SliderItem(
sliderState: true,
- command: ModelProvider.of(context).radioCheckedCommand,
+ command: command.radioCheckedCommand,
),
Container(
padding: EdgeInsets.all(10.0),
@@ -202,39 +174,37 @@ class WeatherList extends StatelessWidget {
return ListView.builder(
itemCount: list.length,
itemBuilder: (context, index) => ListTile(
- leading: Image.network("http://openweathermap.org/img/w/" +
- list[index].icon.toString() +
- '.png'),
- title: Container(
- padding: EdgeInsets.all(10.0),
- child: Text(list[index].city.toString()),
- ),
- subtitle: Container(
- padding: EdgeInsets.all(10.0),
- child: Text(list[index].temperature.toStringAsFixed(2)),
- ),
- trailing: Container(
- child: Column(
- children: [
- Text(list[index].description),
- Container(
- padding: EdgeInsets.only(top: 5.0),
- child: Text(
- 'Latitude: ${list[index].lat}',
- style: TextStyle(
- fontSize: 12.0, fontStyle: FontStyle.italic),
- ),
- ),
- Container(
- child: Text(
- 'Longitude: ${list[index].long}',
- style:
- TextStyle(fontSize: 12.0, fontStyle: FontStyle.italic),
- ))
- ],
+ leading: Image.network("http://openweathermap.org/img/w/" +
+ list[index].icon.toString() +
+ '.png'),
+ title: Container(
+ padding: EdgeInsets.all(10.0),
+ child: Text(list[index].city.toString()),
+ ),
+ subtitle: Container(
+ padding: EdgeInsets.all(10.0),
+ child: Text(list[index].temperature.toStringAsFixed(2)),
+ ),
+ trailing: Container(
+ child: Column(
+ children: [
+ Text(list[index].description),
+ Container(
+ padding: EdgeInsets.only(top: 5.0),
+ child: Text(
+ 'Latitude: ${list[index].lat}',
+ style: TextStyle(fontSize: 12.0, fontStyle: FontStyle.italic),
+ ),
),
- ),
+ Container(
+ child: Text(
+ 'Longitude: ${list[index].long}',
+ style: TextStyle(fontSize: 12.0, fontStyle: FontStyle.italic),
+ ))
+ ],
),
+ ),
+ ),
);
}
}
diff --git a/lib/model/model_command.dart b/lib/model/model_command.dart
index a2b43e0..ef63950 100644
--- a/lib/model/model_command.dart
+++ b/lib/model/model_command.dart
@@ -1,5 +1,5 @@
import 'package:rx_command/rx_command.dart';
-import 'package:geolocation/geolocation.dart';
+import 'package:geolocator/geolocator.dart';
import 'package:rxdart/rxdart.dart';
// import 'package:rxdart/streams.dart';
@@ -9,76 +9,58 @@ import 'package:weather/model/weather_repo.dart';
class ModelCommand {
final WeatherRepo weatherRepo;
- // final RxCommand updateLocationCommand;
- final RxCommand> updateWeatherCommand;
- final RxCommand getGpsCommand;
+ final RxCommand> updateWeatherCommand;
+ final RxCommand getGpsCommand;
final RxCommand radioCheckedCommand;
- final RxCommand addCitiesCommand;
- final RxCommand changeLocaleCommand;
- final RxCommand updateLocationStreamCommand;
+ final RxCommand addCitiesCommand;
+ final RxCommand changeLocaleCommand;
+ final RxCommand updateLocationCommand;
ModelCommand._(
this.weatherRepo,
- // this.updateLocationCommand,
this.updateWeatherCommand,
this.getGpsCommand,
this.radioCheckedCommand,
this.addCitiesCommand,
- this.updateLocationStreamCommand,
+ this.updateLocationCommand,
this.changeLocaleCommand,
);
factory ModelCommand(WeatherRepo repo) {
- final _getGpsCommand = RxCommand.createAsync2(repo.getGps);
+ final _getGpsCommand = RxCommand.createAsyncNoParam(repo.getGps);
- final _radioCheckedCommand = RxCommand.createSync3((b) => b);
+ final _radioCheckedCommand = RxCommand.createSync((b) => b);
final _changeLocaleCommand =
- RxCommand.createSync1(repo.setLanguage);
-
- //A combined Observable of the GPS and Radio observables using And logic. If one is false then false will be returned.
- //This allows us to have a more dynamic set of circumstances for shutting down the buttons.
- // final Observable _boolCombine = Observable
- // .combineLatest2(_getGpsCommand.results, _radioCheckedCommand.results,
- // (gps, radio) => gps && radio)
- // .distinctUnique();
+ RxCommand.createSyncNoResult(repo.setLanguage);
//Two Observables needed because they are only cold observables (single subscription).
final _boolCombineA =
- CombineObs(_getGpsCommand.results, _radioCheckedCommand.results)
- .combinedObservable;
+ CombineObs(_getGpsCommand, _radioCheckedCommand).combinedObservable;
final _boolCombineB =
- CombineObs(_getGpsCommand.results, _radioCheckedCommand.results)
- .combinedObservable;
-
- // final _updateLocationCommand =
- // RxCommand.createAsync2(repo.updateLocation);
+ CombineObs(_getGpsCommand, _radioCheckedCommand).combinedObservable;
- final _updateWeatherCommand = RxCommand
- .createAsync3>(repo.updateWeather,
+ final _updateWeatherCommand =
+ RxCommand.createAsync>(repo.updateWeather,
canExecute: _boolCombineA);
- final _addCitiesCommand = RxCommand.createSync1(repo.addCities);
+ final _addCitiesCommand = RxCommand.createSyncNoResult(repo.addCities);
- final _updateLocationStreamCommand = RxCommand
- .createFromStream(repo.updateLocationStream,
- canExecute: _boolCombineB);
+ final _updateLocationCommand = RxCommand.createAsync(
+ repo.updateLocation,
+ canExecute: _boolCombineB);
- // _updateLocationCommand.results.listen(_updateWeatherCommand);
- //using a stream based command now because lastKnownLocation is not as consistent as [currentLocation]
- _updateLocationStreamCommand.results
- .listen((data) => _updateWeatherCommand(data));
+ _updateLocationCommand.listen((data) => _updateWeatherCommand(data));
- _updateWeatherCommand(null);
+ // _updateWeatherCommand(null);
return ModelCommand._(
repo,
- // _updateLocationCommand,
_updateWeatherCommand,
_getGpsCommand,
_radioCheckedCommand,
_addCitiesCommand,
- _updateLocationStreamCommand,
+ _updateLocationCommand,
_changeLocaleCommand,
);
}
diff --git a/lib/model/model_provider.dart b/lib/model/model_provider.dart
index 147f45b..51bcd36 100644
--- a/lib/model/model_provider.dart
+++ b/lib/model/model_provider.dart
@@ -16,9 +16,9 @@ class ModelProvider extends InheritedWidget {
}
static ModelCommand of(BuildContext context) {
- ModelProvider modelProvider =
- context.inheritFromWidgetOfExactType(ModelProvider) as ModelProvider;
+ final ModelProvider inherited =
+ context.dependOnInheritedWidgetOfExactType();
- return modelProvider.modelCommand;
+ return inherited?.modelCommand;
}
}
diff --git a/lib/model/weather_repo.dart b/lib/model/weather_repo.dart
index 0c30fc6..f168f2b 100644
--- a/lib/model/weather_repo.dart
+++ b/lib/model/weather_repo.dart
@@ -3,7 +3,8 @@ import 'dart:convert';
import 'package:http/http.dart' as http;
-import 'package:geolocation/geolocation.dart';
+// import 'package:geolocation/geolocation.dart';
+import 'package:geolocator/geolocator.dart';
import 'package:weather/json/response.dart';
@@ -26,19 +27,19 @@ class WeatherRepo {
lang = code;
}
- Future> updateWeather(LocationResult result) async {
+ Future> updateWeather(Position result) async {
String url;
if (result != null) {
url =
- 'http://api.openweathermap.org/data/2.5/find?lat=${result.location.latitude}&lon=${result.location.longitude}&cnt=$cnt&appid=$API_KEY&lang=$lang';
+ 'http://api.openweathermap.org/data/2.5/find?lat=${result.latitude}&lon=${result.longitude}&cnt=$cnt&appid=$API_KEY&lang=$lang';
} else {
url =
'http://api.openweathermap.org/data/2.5/find?lat=43&lon=-79&cnt=10&appid=$API_KEY';
}
final response = await client.get(url);
- List req = BaseResponse
- .fromJson(json.decode(response.body) as Map)
+ List req = BaseResponse.fromJson(
+ json.decode(response.body) as Map)
.cities
.map((city) => WeatherModel.fromResponse(city))
.toList();
@@ -46,23 +47,16 @@ class WeatherRepo {
return req;
}
- // Future updateLocation() async {
- // Future result = Geolocation.lastKnownLocation();
- // return result;
- // }
-
- //uses Stream instead of future. Mainly done because lastKnownLocation isn't as reliable as locationUpdates.
- //when geolocation plugin is fixed or better plugin is released, will update code.
-
- Stream updateLocationStream(dynamic item) {
- Stream stream = Geolocation.currentLocation(
- accuracy: LocationAccuracy.best, inBackground: false);
- return stream;
+ Future updateLocation(dynamic data) async {
+ Future result =
+ Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.best);
+ return result;
}
Future getGps() async {
- final GeolocationResult result = await Geolocation.isLocationOperational();
- if (result.isSuccessful)
+ final GeolocationStatus result =
+ await Geolocator().checkGeolocationPermissionStatus();
+ if (result == GeolocationStatus.granted)
return true;
else
return false;
diff --git a/pubspec.yaml b/pubspec.yaml
index 63931f9..9a2dc6b 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,11 @@
name: weather
description: A new Flutter project.
+version: 1.0.0+1
+
+environment:
+ sdk: ">=2.3.0 <3.0.0"
+
dependencies:
flutter:
sdk: flutter
@@ -10,22 +15,22 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
- cupertino_icons: ^0.1.0
+ cupertino_icons: ^0.1.2
- json_annotation: ^0.2.3
- rx_command: "^1.0.7"
- rx_widgets: "^1.0.2"
- geolocation: "^0.2.1"
- rxdart: "^0.16.6"
-
+ json_annotation: ^3.0.0
+ rx_command: ^4.3.3
+ rx_widgets: ^2.5.0
+ geolocator: ^5.1.5
+ # geolocation: "^0.2.1"
+ rxdart: ^0.22.6
dev_dependencies:
- build_runner: ^0.8.0
- json_serializable: ^0.5.0
- intl_translation: "^0.16.6"
+ build_runner: ^1.6.1
+ json_serializable: ^3.0.0
+ intl_translation: ^0.17.5
flutter_test: