Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KDShanika committed Aug 2, 2020
1 parent d676a45 commit 6227a2b
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ public final class GeneratedPluginRegistrant {
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin.registerWith(shimPluginRegistry.registrarFor("io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin"));
flutterEngine.getPlugins().add(new com.baseflow.geolocator.GeolocatorPlugin());
flutterEngine.getPlugins().add(new com.baseflow.googleapiavailability.GoogleApiAvailabilityPlugin());
flutterEngine.getPlugins().add(new io.flutter.plugins.googlemaps.GoogleMapsPlugin());
flutterEngine.getPlugins().add(new io.flutter.plugins.imagepicker.ImagePickerPlugin());
flutterEngine.getPlugins().add(new com.baseflow.location_permissions.LocationPermissionsPlugin());
flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
com.ly.permission.PermissionPlugin.registerWith(shimPluginRegistry.registrarFor("com.ly.permission.PermissionPlugin"));
flutterEngine.getPlugins().add(new io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin());
flutterEngine.getPlugins().add(new com.tekartik.sqflite.SqflitePlugin());
}
}
28 changes: 28 additions & 0 deletions ios/Runner/GeneratedPluginRegistrant.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

#import "GeneratedPluginRegistrant.h"

#if __has_include(<geolocator/GeolocatorPlugin.h>)
#import <geolocator/GeolocatorPlugin.h>
#else
@import geolocator;
#endif

#if __has_include(<google_maps_flutter/FLTGoogleMapsPlugin.h>)
#import <google_maps_flutter/FLTGoogleMapsPlugin.h>
#else
Expand All @@ -16,12 +22,30 @@
@import image_picker;
#endif

#if __has_include(<location_permissions/LocationPermissionsPlugin.h>)
#import <location_permissions/LocationPermissionsPlugin.h>
#else
@import location_permissions;
#endif

#if __has_include(<path_provider/FLTPathProviderPlugin.h>)
#import <path_provider/FLTPathProviderPlugin.h>
#else
@import path_provider;
#endif

#if __has_include(<permission/PermissionPlugin.h>)
#import <permission/PermissionPlugin.h>
#else
@import permission;
#endif

#if __has_include(<shared_preferences/FLTSharedPreferencesPlugin.h>)
#import <shared_preferences/FLTSharedPreferencesPlugin.h>
#else
@import shared_preferences;
#endif

#if __has_include(<sqflite/SqflitePlugin.h>)
#import <sqflite/SqflitePlugin.h>
#else
Expand All @@ -31,9 +55,13 @@
@implementation GeneratedPluginRegistrant

+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
[GeolocatorPlugin registerWithRegistrar:[registry registrarForPlugin:@"GeolocatorPlugin"]];
[FLTGoogleMapsPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTGoogleMapsPlugin"]];
[FLTImagePickerPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTImagePickerPlugin"]];
[LocationPermissionsPlugin registerWithRegistrar:[registry registrarForPlugin:@"LocationPermissionsPlugin"]];
[FLTPathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTPathProviderPlugin"]];
[PermissionPlugin registerWithRegistrar:[registry registrarForPlugin:@"PermissionPlugin"]];
[FLTSharedPreferencesPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTSharedPreferencesPlugin"]];
[SqflitePlugin registerWithRegistrar:[registry registrarForPlugin:@"SqflitePlugin"]];
}

Expand Down
70 changes: 70 additions & 0 deletions lib/services/driverdata_service.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
import 'package:epharma/services/pref_service.dart';
import 'package:logger/logger.dart';
import 'package:dio/dio.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'dart:async';
import 'dart:io';


class Driver {
String user_name;
String email;
String phone;
String address;
String _id;

Driver(this.user_name, this.email, this.phone, this.address, this._id);
}

class DriverProfService {
final baseUrl = 'https://e-pharma-server.herokuapp.com';

Future<Driver> getDetails() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String token = prefs.getString("token");
Driver driver;
Logger().i("push $token");

return Dio()
.get(
'$baseUrl/me?token=$token',
)
.then((res) async {
Logger().i("$res");

if (res.statusCode == 200) {
Logger().i("prof: ${res.data["data"]}");
var f = res.data["data"];
Logger().i("f: ${f["avatar_url"]}");

driver = Driver (
f["user_name"],
f["email"],
f["phone"],
f["address"],
f["_id"]
);

Logger().i("d: ${driver}");
Logger().i("prof");
return driver;
}
Logger().i("returned false");
return driver;

}).catchError((err) => driver);
}

Future<bool> _saveToken(String token) {
return SharedPreferences.getInstance().then((instance) {
return instance.setString("token", token);
});
}
Future<String> _getToken() {
return SharedPreferences.getInstance().then((instance) {
return instance.getString("token");
});
}

}

0 comments on commit 6227a2b

Please sign in to comment.