Skip to content

Commit

Permalink
lib: fetch distance and duration properly
Browse files Browse the repository at this point in the history
*change direction API's

Signed-off-by: Ayush Dubey <[email protected]>
  • Loading branch information
Ayushd70 committed Jul 21, 2021
1 parent 72433e0 commit f23d71d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 29 deletions.
33 changes: 7 additions & 26 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,44 +1,25 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.google_maps">
<application
android:label="google_maps"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.google_maps">
<application android:label="google_maps" android:icon="@mipmap/ic_launcher">
<activity android:name=".MainActivity" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" />
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background" />
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyBlefMmsxW3lz0_wlTrCKAFZLsHXtgFufI" />
<meta-data android:name="flutterEmbedding" android:value="2" />
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyBmPdAZ84TD-qNoGXyd9RnarWPR1i6QBi8" />
</application>
</manifest>
2 changes: 1 addition & 1 deletion lib/.env.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const String googleAPIkey = 'AIzaSyBlefMmsxW3lz0_wlTrCKAFZLsHXtgFufI';
const String googleAPIkey = 'AIzaSyBmPdAZ84TD-qNoGXyd9RnarWPR1i6QBi8';
2 changes: 1 addition & 1 deletion lib/direction_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Directions {

String distance = '';
String duration = '';
if (data['legs' as List].isEmpty) {
if ((data['legs'] as List).isNotEmpty) {
final leg = data['legs'][0];
distance = leg['distance']['text'];
duration = leg['duration']['text'];
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class _MapScreenState extends State<MapScreen> {
}
});
final directions = await DirectionsRepository()
.getDirections(origin: pos, destination: pos);
.getDirections(origin: _origin!.position, destination: pos);
setState(() {
_info = directions;
});
Expand Down

0 comments on commit f23d71d

Please sign in to comment.