Driver location update on order deliver in progress...

ZohaibIqbalKambrani
Zohaib Iqbal Kambrani 5 years ago
parent 0522cb4dcb
commit 9d10eda89c

@ -24,8 +24,7 @@
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/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

@ -2,26 +2,23 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// End points
const BASE_URL = 'https://hmgwebservices.com/Services';
const isUAT = true;
const BASE_URL = 'https://${isUAT ? "uat." : ""}hmgwebservices.com/Services';
const PING_SERVICE = '/Services/Weather.svc/REST/CheckConnectivity';
const GET_PROJECT = '/Lists.svc/REST/GetProject';
const LOGIN = "/Authentication.svc/REST/CheckDriverAuthentication";
const GET_OPT =
"/Patients.svc/REST/PatientER_Delivery_SendSMSForForgetPassword";
const CHECK_ACTIVATION_CODE =
"/Patients.svc/REST/PatientER_Delivery_CheckActivationCodeForForgetPassword";
const CHANGE_FORGOT_PASSWORD =
"/Patients.svc/REST/PatientER_Delivery_ChangeForgetedPasswordForDriver";
const GET_OPT = "/Patients.svc/REST/PatientER_Delivery_SendSMSForForgetPassword";
const CHECK_ACTIVATION_CODE = "/Patients.svc/REST/PatientER_Delivery_CheckActivationCodeForForgetPassword";
const CHANGE_FORGOT_PASSWORD = "/Patients.svc/REST/PatientER_Delivery_ChangeForgetedPasswordForDriver";
const GET_ALL_ORDERS = '/Patients.svc/REST/PatientER_Delivery_GetAllOrder';
const SCAN_QR = '/Patients.svc/REST/PatientER_Delivery_OrderInsert';
const UPDATE_ORDER_STATUS =
'/Patients.svc/REST/PatientER_Delivery_UpdateOrderStatus';
const UPDATE_ORDER_STATUS = '/Patients.svc/REST/PatientER_Delivery_UpdateOrderStatus';
const NEXT_ORDER = "/Patients.svc/REST/PatientER_Delivery_NextOrder";
const UPDATE_DRIVER_LOCATION = "/Patients.svc/REST/PatientER_DriverLocation_Insert";
const GET_ALL_DELIVERD_ORDER =
'/Patients.svc/REST/PatientER_Delivery_GetAllDeliverdOrder';
const GET_ALL_ORDERS_STATUS =
'/Patients.svc/REST/PatientER_Delivery_GetAllOrderstatus';
const GET_ALL_DELIVERD_ORDER = '/Patients.svc/REST/PatientER_Delivery_GetAllDeliverdOrder';
const GET_ALL_ORDERS_STATUS = '/Patients.svc/REST/PatientER_Delivery_GetAllOrderstatus';
/// Body Constant
const CHANNEL = 9;

@ -82,4 +82,8 @@ const Map<String, Map<String, String>> localizedValues = {
'en': 'Please Enter your OPT code sent to your phone',
'ar': 'الرجاء إدخال رمز OPT الخاص بك المرسل إلى هاتفك'
},
'startDelivery': {
'en': 'Start Delivery',
'ar': 'Start Delivery'
},
};

@ -0,0 +1,10 @@
class RequestInitiateOrderDelivery{
int orderID = 0;
RequestInitiateOrderDelivery({this.orderID});
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['OrderID'] = this.orderID;
return data;
}
}

@ -0,0 +1,15 @@
import 'package:location/location.dart';
class RequestUpdateDriverLocation{
int orderID = 0;
LocationData location;
RequestUpdateDriverLocation({this.orderID,this.location});
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['OrderID'] = this.orderID;
data['Latitude'] = "${this.location.latitude}";
data['Longitude'] = "${this.location.longitude}";
return data;
}
}

@ -0,0 +1,100 @@
import 'dart:collection';
import 'package:driverapp/config/config.dart';
import 'package:driverapp/core/model/initiate_order_delivey/request_initiate_order_delivery.dart';
import 'package:driverapp/core/model/orders/deliverd_order_res_model.dart';
import 'package:driverapp/core/model/orders/next_order_request_model.dart';
import 'package:driverapp/core/model/orders/pending_orders_req_model.dart';
import 'package:driverapp/core/model/orders/pending_orders_res_model.dart';
import 'package:driverapp/core/model/orders/update_order_status_request_model.dart';
import 'package:driverapp/core/model/scan_qr/scan_qr_request_model.dart';
import 'package:driverapp/core/model/update_driver_location/request_update_driver_location.dart';
import 'package:driverapp/core/service/base_service.dart';
import 'package:driverapp/uitl/utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:latlong/latlong.dart';
import 'package:location/location.dart';
class DeliveryTrackingServices extends BaseService {
var _distanceFilter = 5; // [Meters] (Call update API if distance covered from last location is greater then 'value' )
var initiateOrderDeliveryResponse = null;
Future<Object> initiateOrderDelivery(int orderID) async {
hasError = false;
var order = RequestInitiateOrderDelivery(orderID: orderID);
try {
await baseAppClient.post(PING_SERVICE,
onSuccess: (dynamic response, int statusCode) {
initiateOrderDeliveryResponse = response;
}, onFailure: (String error, int statusCode) {
super.hasError = true;
super.error = error;
}, body: order.toJson());
} catch (e) {
hasError = true;
super.error = error;
throw e;
}
return initiateOrderDeliveryResponse;
}
_updateDriverLocation(int orderID, LocationData location) async {
if(location != null){
debugPrint("Updating driver location");
var order = RequestUpdateDriverLocation(orderID: orderID, location: location);
await baseAppClient.post(UPDATE_DRIVER_LOCATION,
onSuccess: (dynamic response, int statusCode) {
}, onFailure: (String errorMessage, int statusCode) {
if(statusCode == 200){
// Server responded but check failed (stop updating location)
// stopLocationUpdate(orderID);
// Show error message that you received in response
}
}, body: order.toJson());
}
}
List _currentRunnings = List<int>();
Future<Object> startLocationUpdate(int orderID, {int frequencyInSeconds = 3}) async {
_currentRunnings.remove(orderID); // remove existing if its already running
_currentRunnings.add(orderID);
while(_currentRunnings.contains(orderID)){
await Future.delayed(Duration(seconds: frequencyInSeconds));
Utils.possibleToGetLocation((value) async{
if(value){
var location = await Utils.getLocation();
if (_haveEnoughLocationUpdate(location))
await _updateDriverLocation(orderID, location);
}
});
}
}
stopLocationUpdate(int orderID){
_currentRunnings.remove(orderID);
}
LocationData _lastLocation;
bool _haveEnoughLocationUpdate(LocationData location){
if(_lastLocation == null) {
_lastLocation = location;
return true;
}else{
var distanceCovered = Utils.distanceBetween(_lastLocation, location, LengthUnit.Meter);
return (distanceCovered > _distanceFilter);
}
}
}

@ -1,3 +1,4 @@
import 'package:driverapp/core/service/delivery_tracking_services.dart';
import 'package:get_it/get_it.dart';
import 'core/service/authentication_service.dart';
@ -15,6 +16,7 @@ void setupLocator() {
locator.registerLazySingleton(() => HospitalService());
locator.registerLazySingleton(() => AuthenticationService());
locator.registerLazySingleton(() => OrdersService());
locator.registerLazySingleton(() => DeliveryTrackingServices());
/// View Model
locator.registerFactory(() => HospitalViewModel());

@ -90,7 +90,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
_authenticationViewModel.user.userName,
style: TextStyle(
fontSize: 22.0,
color: Hexcolor("#343333"),
color: HexColor("#343333"),
fontWeight: FontWeight.bold),
),
),
@ -482,7 +482,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
Text(TranslationBase.of(context).nearestDropOffs,
style: TextStyle(
fontSize: 18.0,
color: Hexcolor("#343333"),
color: HexColor("#343333"),
fontWeight: FontWeight.bold)),
],
),

@ -1,10 +1,18 @@
import 'dart:convert';
import 'dart:io';
import 'package:android_intent/android_intent.dart';
import 'package:driverapp/app-icons/driver_app_icons.dart';
import 'package:driverapp/config/config.dart';
import 'package:driverapp/core/enum/viewstate.dart';
import 'package:driverapp/core/model/orders/pending_orders_req_model.dart';
import 'package:driverapp/core/model/orders/pending_orders_res_model.dart';
import 'package:driverapp/core/model/orders/update_order_status_request_model.dart';
import 'package:driverapp/core/service/delivery_tracking_services.dart';
import 'package:driverapp/core/viewModels/orders_view_model.dart';
import 'package:driverapp/locator.dart';
import 'package:driverapp/pages/base/base_view.dart';
import 'package:driverapp/uitl/app_shared_preferences.dart';
import 'package:driverapp/uitl/translations_delegate_base.dart';
import 'package:driverapp/uitl/utils.dart';
import 'package:driverapp/widgets/bottom_sheet/action_sheet_button.dart';
@ -19,136 +27,31 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:maps_launcher/maps_launcher.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';
import 'delivery_confirmed_page.dart';
// ignore: must_be_immutable
class InformationPage extends StatelessWidget {
class InformationPage extends StatefulWidget {
final PendingOrdersRes item;
InformationPage({this.item});
@override
State<StatefulWidget> createState() => _InformationPageState();
}
// ignore: must_be_immutable
class _InformationPageState extends State<InformationPage> {
int _orderStatus;
PendingOrdersRes _item;
bool _isDeliveryStarted = false;
InformationPage({this.item});
@override
Widget build(BuildContext context) {
showDeliveryOptions(OrdersViewModel model) {
showModalBottomSheet(
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
isScrollControlled: true,
context: context,
builder: (BuildContext bc) {
return FractionallySizedBox(
heightFactor: 0.35,
child: ListView(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 10,
),
Center(
child: Texts(
TranslationBase.of(context).selectAction,
color: Colors.black,
fontSize: 22,
),
),
SizedBox(
height: 10,
),
FractionallySizedBox(
widthFactor: MediaQuery.of(context).orientation ==
Orientation.portrait
? 0.9
: 0.98,
child: Container(
height: MediaQuery.of(context).size.height * 0.45,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
width: double.infinity,
child: ListView(
children: <Widget>[
Column(
children: <Widget>[
SizedBox(
height: 3,
child: Container(
color: Hexcolor("#D5D5D5"),
),
),
SizedBox(
height: 15,
),
ActionSheetButton(
label:
TranslationBase.of(context).delivered,
icon: DriverApp.deliverd_icon,
onTap: () {
selectAction(context, 2, model);
},
),
SizedBox(height: 15),
// ActionSheetButton(
// label: TranslationBase.of(context)
// .deliveredAccepted,
// icon: DriverApp.not_available,
// onTap: () {
// selectAction(context, 4, model);
// },
// ),
// SizedBox(height: 15),
ActionSheetButton(
label: TranslationBase.of(context)
.deliveredRejected,
icon: DriverApp.rejected_icon,
onTap: () {
selectAction(context, 3, model);
},
),
SizedBox(height: 15),
// ActionSheetButton(
// label: TranslationBase.of(context).canceled,
// icon: DriverApp.not_reachable_icon,
// onTap: () {
// selectAction(context, 6, model);
// },
// ),
// SizedBox(height: 15),
],
),
],
),
),
)
],
),
),
],
),
);
});
}
_item = widget.item;
return BaseView<OrdersViewModel>(
builder: (_, model, w) => AppScaffold(
@ -175,12 +78,12 @@ class InformationPage extends StatelessWidget {
child: Container(
width: MediaQuery.of(context).size.width * 1.0,
height: MediaQuery.of(context).orientation ==
Orientation.portrait
Orientation.portrait
? MediaQuery.of(context).size.height * 0.70
: MediaQuery.of(context).size.height * 1.7,
margin: EdgeInsets.only(
top: MediaQuery.of(context).orientation ==
Orientation.portrait
Orientation.portrait
? MediaQuery.of(context).size.width * 0.23
: MediaQuery.of(context).size.width * 0.13),
decoration: BoxDecoration(
@ -192,88 +95,53 @@ class InformationPage extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).orientation ==
Orientation.portrait
? MediaQuery.of(context).size.height * 0.10
: MediaQuery.of(context).size.height * 0.29,
//MediaQuery.of(context).size.width * 0.005,
),
Padding(
padding: MediaQuery.of(context).orientation ==
Orientation.portrait
? EdgeInsets.only(top: 60.0)
: EdgeInsets.only(top: 15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
DeliveryInfoButton(
btnColor: Colors.white, //Color(0xffED1C24),
btnIcon: Icon(DriverApp.location_1,
size: MediaQuery.of(context)
.orientation ==
Orientation.portrait
? 50
: 90,
color: Color(0xffED1C24)),
btnName:
TranslationBase.of(context).location,
btnFunction: () {
MapsLauncher.launchCoordinates(
item.latitude, item.longitude);
},
),
//TODO: return it back when it needed
// DeliveryInfoButton(
// btnColor: Colors.white, //Color(0xFF61B260),
// btnIcon: Icon(
// DriverApp.whatsapp,
// size:
// MediaQuery.of(context).orientation ==
// Orientation.portrait
// ? 50
// : 90,
// color: Color(0xFF5EA34A),
// ),
// btnName: 'Whatsapp',
// btnFunction: () {},
// ),
// DeliveryInfoButton(
// btnColor: Colors.white, //Color(0xFFFCB657),
// btnIcon: Icon(
// DriverApp.message,
// size:
// MediaQuery.of(context).orientation ==
// Orientation.portrait
// ? 50
// : 90,
// color: Color(0xffFFA540),
// ),
// btnName: TranslationBase.of(context).sms,
// btnFunction: () {},
// ),
DeliveryInfoButton(
btnColor: Colors.white,
//Theme.of(context).primaryColor,
btnIcon: Icon(
DriverApp.call,
size:
MediaQuery.of(context).orientation ==
Orientation.portrait
Visibility(
visible: _isDeliveryStarted,
child: Padding(
padding: MediaQuery.of(context).orientation ==
Orientation.portrait
? EdgeInsets.only(top: 60.0)
: EdgeInsets.only(top: 15.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
DeliveryInfoButton(
btnColor: Colors.white, //Color(0xffED1C24),
btnIcon: Icon(DriverApp.location_1,
size: MediaQuery.of(context)
.orientation ==
Orientation.portrait
? 50
: 90,
color: Theme.of(context).primaryColor,
color: Color(0xffED1C24)),
btnName:
TranslationBase.of(context).location,
btnFunction: () {
openMapIntent(_item);
// MapsLauncher.launchCoordinates(
// _item.latitude, _item.longitude);
},
),
btnName: TranslationBase.of(context).call,
btnFunction: () =>
launch("tel://" + item.mobileNumber),
),
],
DeliveryInfoButton(
btnColor: Colors.white,
//Theme.of(context).primaryColor,
btnIcon: Icon(
DriverApp.call,
size:
MediaQuery.of(context).orientation ==
Orientation.portrait
? 50
: 90,
color: Theme.of(context).primaryColor,
),
btnName: TranslationBase.of(context).call,
btnFunction: () =>
launch("tel://" + _item.mobileNumber),
),
],
),
),
),
SizedBox(
height: MediaQuery.of(context).size.width * 0.08,
),
Container(
margin: EdgeInsets.only(
left: MediaQuery.of(context).size.width * 0.05,
@ -300,15 +168,15 @@ class InformationPage extends StatelessWidget {
padding: const EdgeInsets.only(left: 10),
child: Column(
children: List.generate(
item.itemsQuantitiesList != null
? item.itemsQuantitiesList.length
_item.itemsQuantitiesList != null
? _item.itemsQuantitiesList.length
: 0, (index) {
return packageContent(
packageName: item
packageName: _item
.itemsQuantitiesList[index]
.itemName
.toString(),
packageCount: item
packageCount: _item
.itemsQuantitiesList[index]
.quantity
.toString(),
@ -324,14 +192,19 @@ class InformationPage extends StatelessWidget {
),
Container(
margin: MediaQuery.of(context).orientation ==
Orientation.portrait
Orientation.portrait
? EdgeInsets.all(8.0)
: EdgeInsets.symmetric(horizontal: 12.0),
child: SecondaryButton(
label:
TranslationBase.of(context).clientReached,
TranslationBase.of(context).clientReached,
onTap: () {
showDeliveryOptions(model);
locator<DeliveryTrackingServices>()
.initiateOrderDelivery(_item.orderID)
.then((results){
setState(() => _isDeliveryStarted = true);
// showDeliveryOptions(model);
});
},
),
),
@ -340,16 +213,16 @@ class InformationPage extends StatelessWidget {
),
),
CustomerBriefCard(
customerOrderId: item.orderID,
pharmacyOrderId: item.ePharmacyOrderNo,
customerFirstName: item.firstName,
customerLastName: item.lastName,
mobileNo: item.mobileNumber,
totalPayment: item.amount,
deliveryTime: item.orderCreatedOn,
longitude: item.longitude,
latitude: item.latitude,
distanceInKilometers: item.distanceInKilometers,
customerOrderId: _item.orderID,
pharmacyOrderId: _item.ePharmacyOrderNo,
customerFirstName: _item.firstName,
customerLastName: _item.lastName,
mobileNo: _item.mobileNumber,
totalPayment: _item.amount,
deliveryTime: _item.orderCreatedOn,
longitude: _item.longitude,
latitude: _item.latitude,
distanceInKilometers: _item.distanceInKilometers,
),
],
),
@ -361,6 +234,128 @@ class InformationPage extends StatelessWidget {
);
}
showDeliveryOptions(OrdersViewModel model) {
showModalBottomSheet(
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
isScrollControlled: true,
context: context,
builder: (BuildContext bc) {
return FractionallySizedBox(
heightFactor: 0.35,
child: ListView(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 10,
),
Center(
child: Texts(
TranslationBase.of(context).selectAction,
color: Colors.black,
fontSize: 22,
),
),
SizedBox(
height: 10,
),
FractionallySizedBox(
widthFactor: MediaQuery.of(context).orientation ==
Orientation.portrait
? 0.9
: 0.98,
child: Container(
height: MediaQuery.of(context).size.height * 0.45,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
width: double.infinity,
child: ListView(
children: <Widget>[
Column(
children: <Widget>[
SizedBox(
height: 3,
child: Container(
color: HexColor("#D5D5D5"),
),
),
SizedBox(
height: 15,
),
ActionSheetButton(
label:
TranslationBase.of(context).delivered,
icon: DriverApp.deliverd_icon,
onTap: () {
selectAction(context, 2, model);
},
),
SizedBox(height: 15),
// ActionSheetButton(
// label: TranslationBase.of(context)
// .deliveredAccepted,
// icon: DriverApp.not_available,
// onTap: () {
// selectAction(context, 4, model);
// },
// ),
// SizedBox(height: 15),
ActionSheetButton(
label: TranslationBase.of(context)
.deliveredRejected,
icon: DriverApp.rejected_icon,
onTap: () {
selectAction(context, 3, model);
},
),
SizedBox(height: 15),
// ActionSheetButton(
// label: TranslationBase.of(context).canceled,
// icon: DriverApp.not_reachable_icon,
// onTap: () {
// selectAction(context, 6, model);
// },
// ),
// SizedBox(height: 15),
],
),
],
),
),
)
],
),
),
],
),
);
});
}
selectAction(BuildContext context, orderStatus, OrdersViewModel model) {
String orderStatusText;
this._orderStatus = orderStatus;
@ -397,11 +392,11 @@ class InformationPage extends StatelessWidget {
updateOrderStatus(BuildContext context, OrdersViewModel model) async {
UpdateOrderStatusRequestModel updateOrderStatusRequestModel =
UpdateOrderStatusRequestModel(
deliveryOrderID: item.orderID,
deliveryOrderStatus: _orderStatus,
rejectionReason: "NO Reason",
cancleReason: "");
UpdateOrderStatusRequestModel(
deliveryOrderID: _item.orderID,
deliveryOrderStatus: _orderStatus,
rejectionReason: "NO Reason",
cancleReason: "");
await model.updateOrderStatus(updateOrderStatusRequestModel);
if (model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(model.error);
@ -420,9 +415,28 @@ class InformationPage extends StatelessWidget {
context,
MaterialPageRoute(
builder: (context) =>
DeliveryConfirmedPage(item),
DeliveryConfirmedPage(_item),
),
);
}
}
openMapIntent(PendingOrdersRes order) async{
Utils.getLocation().then((locationData){
if(locationData != null){
var url = "https://www.google.com/maps/dir/?api=1&destination=24.701833,46.697642&travelmode=driving&dir_action=navigate";
if (Platform.isAndroid) {
var intent = AndroidIntent(action: 'action_view',data: url,package: 'com.google.android.apps.maps');
intent.launch();
}else {
print(url);
}
// Start updating server wit your current location
locator<DeliveryTrackingServices>().startLocationUpdate(order.orderID);
}
});
}
}

@ -0,0 +1,14 @@
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
class Logs{
static save(String log){
SharedPreferences.getInstance().then((_prefs) async{
var jsonString = _prefs.getString("LOG") ?? "[]";
var list = json.decode(jsonString) as List;
list.add("Running... ${DateTime.now()}");
_prefs.setString("LOG", json.encode(list));
});
}
}

@ -108,6 +108,9 @@ class TranslationBase {
String get clientReached =>
localizedValues['clientReached'][locale.languageCode];
String get startDelivery =>
localizedValues['startDelivery'][locale.languageCode];
String get addNoteBtn => localizedValues['addNoteBtn'][locale.languageCode];
String get nextDelivery =>

@ -5,6 +5,7 @@ import 'package:driverapp/pages/setting/request_permission_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:latlong/latlong.dart';
import 'package:location/location.dart';
import 'app_shared_preferences.dart';
@ -48,8 +49,25 @@ class Utils {
static hideKeyboard(BuildContext context) {
FocusScope.of(context).unfocus();
}
static double distanceBetween(LocationData point1, LocationData point2, LengthUnit unit){
var distance = Distance();
num dist = distance.as(
unit,
LatLng(point1.latitude,point1.longitude),
LatLng(point2.latitude,point2.longitude)
);
return dist;
}
static possibleToGetLocation(Function(bool) completion) async{
Location location = new Location();
var serviceEnabled = await location.serviceEnabled();
var hasPermission = await location.hasPermission() == PermissionStatus.granted;
completion(serviceEnabled && hasPermission);
}
static getLocation() async {
static Future<LocationData> getLocation() async {
Location location = new Location();
LocationData currentLocation;
bool _serviceEnabled;
@ -104,8 +122,8 @@ class Utils {
// open setting page
} else {
currentLocation = await location.getLocation();
return currentLocation;
}
return currentLocation;
}
static formatStringToPascalCase(String name) {

@ -19,7 +19,7 @@ class ActionSheetButton extends StatelessWidget {
: MediaQuery.of(context).size.height * 0.14,
decoration: BoxDecoration(boxShadow: [
BoxShadow(
color: Hexcolor("#DBE5E6"),
color: HexColor("#DBE5E6"),
spreadRadius: 15,
blurRadius: 15,
offset: Offset(0, 7),
@ -66,7 +66,7 @@ class ActionSheetButton extends StatelessWidget {
style: TextStyle(
fontSize: 22.0,
fontFamily: "Metropolis-Bold",
color: Hexcolor("##1A1818")),
color: HexColor("##1A1818")),
),
)
],

@ -25,7 +25,7 @@ class CustomBottomSheet extends StatelessWidget {
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Hexcolor("#D5D5D5"),
color: HexColor("#D5D5D5"),
borderRadius: BorderRadius.circular(3.0)),
width: 200,
height: 7.0,

@ -103,7 +103,7 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
: 19),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
color: Hexcolor('#515b5d'),
color: HexColor('#515b5d'),
boxShadow: [
BoxShadow(
color: Color.fromRGBO(

@ -194,7 +194,7 @@ class _SecondaryButtonState extends State<SecondaryButton>
widget.color != null ? null : LINEAR_GRADIENT,
color: widget.color != null
? widget.color
: Hexcolor("#000000"),
: HexColor("#000000"),
),
),
),

@ -25,7 +25,7 @@ class CircleContainer extends StatelessWidget {
shape: BoxShape.circle,
color: color,
border: Border.all(
color: borderColor ?? Hexcolor("#707070"), width: borderWidth)),
color: borderColor ?? HexColor("#707070"), width: borderWidth)),
height: 80,
width: 80,
),

@ -61,7 +61,7 @@ class CustomerBriefCard extends StatelessWidget {
],
),
child: Container(
padding: EdgeInsets.only(left: 30, top: 20, right: 30),
padding: EdgeInsets.only(left: 20, top: 20, right: 20),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,

@ -77,7 +77,7 @@ class OrderInfoCard extends StatelessWidget {
order.lastName),
style: TextStyle(
fontSize: 18.0,
color: Hexcolor("#343333"),
color: HexColor("#343333"),
fontWeight: FontWeight.bold),
),
),

@ -67,7 +67,7 @@ class _RoundedContainerState extends State<RoundedContainer> {
boxShadow: widget.showShadow ? [
BoxShadow(
color: Hexcolor("#DBE5E6"),
color: HexColor("#DBE5E6"),
spreadRadius: 15,
blurRadius: 15,
offset: Offset(0, 7), // changes position of shadow

@ -56,7 +56,7 @@ dependencies:
# UI Reqs
dotted_border: 1.0.5
expandable: ^4.1.4
hexcolor: ^1.0.1
hexcolor: ^1.0.6
# Notification Banner
dropdown_banner: ^1.4.0
@ -72,6 +72,10 @@ dependencies:
# location
location: ^3.0.2
# latlong tools
latlong: any
#gradient
gradient_app_bar: ^0.1.3
@ -79,6 +83,9 @@ dependencies:
#Barcode Scanner
flutter_barcode_scanner: ^1.0.1
#android_intent
android_intent: any

Loading…
Cancel
Save