second commit

This commit is contained in:
Anbarasu
2026-05-27 10:35:09 +05:30
parent c53794c04c
commit 1435ac47b0
501 changed files with 52818 additions and 0 deletions

View File

@@ -0,0 +1,243 @@
class ApiConstants {
static String mainDev = "dev";
static String mainRoute = "live";
//Describe
static String describeUrl='';
//Authentication
static String login='';
static String configUrl='';
//User
static String user='';
static String userUpdate='';
//App Locations
static String appLocations='';
//App Category
static String appCategory= '';
//Customers
static String getCustomerByTenantId = '';
static String createCustomer = '';
static String createDeliveryAddress = '';
static String getCustomerAddress = '';
static String getCustomerSearchByTenantId = '';
//Admin
static String adminToken='';
//Orders
static String getOrders = '';
static String updateOrderStatus = '';
static String getOrderSummary = '';
static String createOrder = '';
//Deliveries
static String getDeliveries = '';
//Location
static String getLocationById = '';
static String updateLocation = '';
static String createLocation = '';
//Notification
static String notifyUrl='' ;
//Tenants
static String getTenantInfo = '';
static String getTenantLocationById = '';
static String getLocationsById = '';
static String getTenantPricing = '';
//Get Partners
static String getPartnerInfo = '';
//Tenant User
static String createTenantUser = '';
//Tenant Staffs
static String getStaffs = '';
static String createStaff = '';
static String updateStaff = '';
static String liveRoute = "https://fiesta.nearle.app/live/api/v1/mob/";
static String liveRoute1 = "https://jupiter.nearle.app/live/api/v1/";
static String liveRouteV2 = "https://fiesta.nearle.app/live/api/v1/mob/";
// Products
static String getProducts = "";
static String updateProduct = "";
// Riders
static String getRiders = "";
static String updateDelivery = '';
static String notifyRider = '';
static String createDelivery = "";
//Auth
//LoginUrl
static String loginDev ='https://jupiter.gear.app/$mainDev/api/v1';
static String loginLive ='https://jupiter.nearle.app/$mainRoute/api/v1';
//Describe
static String describeUrlDev="https://ariane.gear.app/$mainRoute/describe/get";
static String describeUrlLive="https://ariane.nearle.app/v1/describe/get";
//User
static String userDev="https://fiesta.nearle.app/$mainDev/api/v1/mob/users";
static String userLive="https://fiesta.nearle.app/$mainRoute/api/v1/mob/users";
static String userUpdateDev ="https://fiesta.nearle.app/$mainDev/api/v1/mob/users/update";
static String userUpdateLive ="https://fiesta.nearle.app/$mainRoute/api/v1/mob/users/update";
//config
static String configUrlDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/utils/getappconfig/";
static String configUrlLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/utils/getappconfig/";
//Customers
static String getCustomerByTenantIdDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/customers/gettenantcustomers";
static String getCustomerByTenantIdLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/customers/gettenantcustomers";
//CustomerSearch
static String getCustomerSearchByTenantIdDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/customers/search";
static String getCustomerSearchByTenantIdLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/customers/search";
static String createCustomerDev = "https://fiesta.nearle.app/$mainDev/api/v1/mobcustomers/create";
static String createCustomerLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/customers/create";
static String createDeliveryAddressDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/customers/locations/create";
static String createDeliveryAddressLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/customers/locations/create";
static String getCustomerAddressDev= "https://fiesta.nearle.app/$mainDev/api/v1/mob/customers/locations/get/";
static String getCustomerAddressLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/customers/locations/get/";
//Orders
static String getOrdersDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/orders/tenant/getorders";
static String getOrdersLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/orders/tenant/getorders";
// Orders
static const String getcustomerOrders = "https://api.workolik.com/api/rest/tenant/getorders";
// Tenant info
static const String tenantInfo = "https://api.workolik.com/api/rest/gettenantinfo";
static String updateOrderStatusDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/orders/updateorder";
static String updateOrderStatusLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/orders/updateorder";
static String getOrderSummaryDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/deliveries/deliverysummary";
static String getOrderSummaryLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/deliveries/deliverysummary";
static String createOrderDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/orders/createorder";
static String createOrderLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/orders/createorder";
//Deliveries
static String getDeliveriesDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/deliveries/getdeliveries";
static String getDeliveriesLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/deliveries/getdeliveries";
//Tenants
static String getTenantInfoDev = "https://jupiter.nearle.app/$mainDev/api/v1/tenants/gettenantinfo";
static String getTenantInfoLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/tenants/gettenantinfo";
static String getTenantLocationByIdDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/tenants/gettenantlocations/";
static String getTenantLocationByIdLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/tenants/gettenantlocations/";
static String getLocationsByIdDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/tenants/gettenantlocation/";
static String getLocationsByIdLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/tenants/gettenantlocation/";
static String getTenantPricingDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/tenants/gettenantpricing";
static String getTenantPricingLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/tenants/gettenantpricing";
//Notification
static String notifyUrlDev = "https://jupiter.nearle.app/$mainDev/api/v1/utils/sendnotifications" ;
static String notifyUrlLive = "https://jupiter.nearle.app/$mainRoute/api/v1/utils/sendnotifications" ;
//App Locations
static String appLocationsDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/utils/getapplocations";
static String appLocationsLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/utils/getapplocations";
//Get Partners
static String getPartnerInfoDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/partners/getpartners/";
static String getPartnerInfoLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/partners/getpartners/";
//App Category
static String appCategoryDev= "https://fiesta.nearle.app/$mainDev/api/v1/mobutils/getsubcategories";
static String appCategoryLive= "https://fiesta.nearle.app/$mainRoute/api/v1/mob/utils/getsubcategories";
static String getAppCategoryLive = "${liveRoute}utils/getcategories/";
//Tenant User
static String createTenantUserDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/tenants/createtenantuser";
static String createTenantUserLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/tenants/createtenantuser";
//Admin
static String adminTokenDev="https://fiesta.nearle.app/$mainDev/api/v1/mob/utils/getapplocationconfig";
static String adminTokenLive="https://fiesta.nearle.app/$mainRoute/api/v1/mob/utils/getapplocationconfig";
//Location
static String getLocationByIdDev = "https://fiesta.nearle.app/$mainDev/api/v1/mobtenants/gettenantlocations/";
static String getLocationByIdLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/tenants/gettenantlocations/";
static String updateLocationDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/tenants/updatelocation";
static String updateLocationLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/tenants/updatelocation";
static String createLocationDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/tenants/createlocation";
static String createLocationLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/tenants/createlocation";
//Tenant Staffs
static String getStaffsDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/tenants/getstaffs";
static String getStaffsLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/tenants/getstaffs";
static String createStaffDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/tenants/createstaff";
static String createStaffLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/tenants/createstaff";
static String updateStaffDev = "https://fiesta.nearle.app/$mainDev/api/v1/mob/tenants/updatestaff";
static String updateStaffLive = "https://fiesta.nearle.app/$mainRoute/api/v1/mob/tenants/updatestaff";
/// https://jupiter.nearle.app/live/api/v1/products/getallproducts?categoryid=1001&subcategoryid=0
/// Get Products
static String getProductLive = "${liveRoute}products/getallproducts";
static String updateProductLive = "${liveRoute}products/update";
static String getRidersLive = "${liveRouteV2}partners/getriders/";
static String updateDeliveryLive = "${liveRoute}deliveries/updatedelivery";
static String notifyRiderLive = "${liveRoute1}utils/notifyuser";
static String createDeliveryLive = "${liveRoute}deliveries/createdeliveries";
// orders/getorders/?applocationid=0&status=created&fromdate=2025-07-17&todate=2025-07-17&pageno=1&pagesize=10&keyword=
// static String getOrdersLive = "${liveRoute}/orders/getorders";
}

View File

@@ -0,0 +1,31 @@
class AssetConstants {
static const String nearleDarkLogo = "assets/images/nearledark.png";
static const String nearleLogin = "assets/images/nearleLogin.png";
static const String nearlelightlogo = "assets/images/nearlelightlogo.png";
static const String nearleAppbarTop = "assets/images/NearleAppbarTop.png";
static const String nearleAppbarDarkLogo = "assets/images/nearle_dark_logo.png";
static const String nearleAppbarBottom = "assets/images/NearleAppbarbottom.png";
static const String MoreBackground = "assets/images/moreTopBackground.png";
static const String NearleAppbarIcon = "assets/images/launcher_icon.png";
static const String privacyPolicy="assets/images/privacypolicy.png";
static const String NoRecords = "assets/images/errandsnoRecords.png";
static const String appbarTopBackground = "assets/images/moreTopBackground2.png";
static const String nearleTextLogo = "assets/images/nearletextlogo.png";
static const String introBanner1="assets/images/introbanner1.png";
static const String introBanner2="assets/images/introbanner2.png";
static const String nearleWhiteLogo="assets/images/nearle_white_logo.png";
static const String nearleTextLogoWhite="assets/images/nearletextwhitelogo.png";
static const String noOrderFound = "assets/images/no_products_found.png";
static const String noOrdersFound = "assets/images/noOrders.png";
static const String noProductsFound = "assets/images/no_products_found.png";
static const String onBoarding1 = "assets/images/onboarding images (7).png";
static const String onBoarding2 = "assets/images/onboarding images (6).png";
static const String onBoarding3 = "assets/images/onboarding images (7).png";
static const String noCustomersFound = "assets/images/nocustomersnow.png";
static const String otpImage = "assets/images/otp_image.png";
static const String loginImage = "assets/images/login_image.png";
static const String nearledailylogodark = "assets/images/nearledailylogodark.png";
static const String nearledailyImage = "assets/images/nearledailyImage.png";
static const String noProfile = "assets/images/noProfile.png";
}

View File

@@ -0,0 +1,15 @@
import 'dart:ui';
import 'package:flutter/material.dart';
class ColorConstants {
static const primaryColor = Color(0xFF662582);
static Color? secondaryColor = Colors.white;
static Color? textFieldColor = Colors.grey[700]!;
static Color? lightColor = Color.fromRGBO(244, 244, 244, 1);
static Color? errandsColor = Colors.blue[100]!;
static Color? primaryColor1 = const Color(0xFFE7D3EF);
static Color? darkGreyColor=Color(0XFF575756);
static Color? lightGreyBg=Colors.grey.shade100;
static Color? blackColor=Colors.black;
}

View File

@@ -0,0 +1,44 @@
import 'Apiconstants.dart';
class ApiConfig {
static void setLive() {
ApiConstants.describeUrl = ApiConstants.describeUrlLive;
ApiConstants.login = ApiConstants.loginLive;
ApiConstants.configUrl = ApiConstants.configUrlLive;
ApiConstants.user = ApiConstants.userLive;
ApiConstants.getCustomerByTenantId = ApiConstants.getCustomerByTenantIdLive;
ApiConstants.getDeliveries = ApiConstants.getDeliveriesLive;
ApiConstants.notifyUrl = ApiConstants.notifyUrlLive;
ApiConstants.updateOrderStatus = ApiConstants.updateOrderStatusLive;
ApiConstants.getOrderSummary = ApiConstants.getOrderSummaryLive;
ApiConstants.getTenantInfo = ApiConstants.getTenantInfoLive;
ApiConstants.appLocations = ApiConstants.appLocationsLive;
ApiConstants.getPartnerInfo = ApiConstants.getPartnerInfoLive;
ApiConstants.appCategory = ApiConstants.getAppCategoryLive;
ApiConstants.createTenantUser = ApiConstants.createTenantUserLive;
ApiConstants.createCustomer = ApiConstants.createCustomerLive;
ApiConstants.createDeliveryAddress = ApiConstants.createDeliveryAddressLive;
ApiConstants.getCustomerAddress = ApiConstants.getCustomerAddressLive;
ApiConstants.getTenantLocationById = ApiConstants.getTenantLocationByIdLive;
ApiConstants.getLocationsById = ApiConstants.getLocationsByIdLive;
ApiConstants.adminToken = ApiConstants.adminTokenLive;
ApiConstants.getTenantPricing = ApiConstants.getTenantPricingLive;
ApiConstants.createOrder = ApiConstants.createOrderLive;
ApiConstants.getOrders = ApiConstants.getOrdersLive;
ApiConstants.getLocationById = ApiConstants.getLocationByIdLive;
ApiConstants.updateLocation = ApiConstants.updateLocationLive;
ApiConstants.createLocation = ApiConstants.createLocationLive;
ApiConstants.getStaffs = ApiConstants.getStaffsLive;
ApiConstants.createStaff = ApiConstants.createStaffLive;
ApiConstants.updateStaff = ApiConstants.updateStaffLive;
ApiConstants.userUpdate = ApiConstants.userUpdateLive;
ApiConstants.getCustomerSearchByTenantId =
ApiConstants.getCustomerSearchByTenantIdLive;
ApiConstants.getProducts = ApiConstants.getProductLive;
ApiConstants.updateProduct = ApiConstants.updateProductLive;
ApiConstants.getRiders = ApiConstants.getRidersLive;
ApiConstants.updateDelivery = ApiConstants.updateDeliveryLive;
ApiConstants.notifyRider = ApiConstants.notifyRiderLive;
ApiConstants.createDelivery = ApiConstants.createDeliveryLive;
}
}

View File

@@ -0,0 +1,89 @@
import 'package:geolocator/geolocator.dart';
import 'package:http/http.dart';
import '../../Model/Response/Appconfig/Appconfigresponse.dart';
import '../Constants/Apiconstants.dart';
import 'app_config_service.dart';
import 'dart:convert' as convert;
class LocationService {
AppConfigurationService appConfigurationService = AppConfigurationService();
Future<AppConfigResponse?> getGoogleApi() async{
var result = await appConfigurationService.getAppConfig("${ApiConstants.configUrl}?configid=1");
return result;
}
Future<List> getPlaceId(String input) async{
final String key = "AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8";
// https://maps.googleapis.com/maps/api/place/autocomplete/json?input=podanur&components=country:IN&key=AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8
String base = "https://maps.googleapis.com/maps/api/place/autocomplete/json";
String path = "$base?input=$input&components=country:IN&key=$key";
print(path);
var response = await get(Uri.parse(path));
var json = convert.jsonDecode(response.body);
print(convert.jsonDecode(response.body));
print(response.body);
var placeId = json['predictions'];
return placeId;
}
Future<Map<String, dynamic>> getPlaces(String input) async{
final String key = "AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8";
String base = "https://maps.googleapis.com/maps/api/place/details/json";
String path = "$base?key=$key&placeid=$input";
print('path $path');
var response = await get(Uri.parse(path));
var json = convert.jsonDecode(response.body);
print(convert.jsonDecode(response.body));
var results = json['result'];
return results;
}
Future<Position> getLocation() async {
getGoogleApi();
bool serviceEnabled;
LocationPermission permission;
// Test if location services are enabled.
// serviceEnabled = await Geolocator.isLocationServiceEnabled();
// if (!serviceEnabled) {
// // permission = await Geolocator.requestPermission();
// await Geolocator.openLocationSettings();
//
// // Location services are not enabled don't continue
// // accessing the position and request users of the
// // App to enable the location services.
// return Future.error('Location services are disabled.');
// }
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
return Future.error('Location permissions are denied');
}
}
if (permission == LocationPermission.deniedForever) {
await Geolocator.openLocationSettings();
// Permissions are denied forever, handle appropriately.
return Future.error(
'Location permissions are permanently denied, we cannot request permissions.');
}
Position position = await Geolocator.getCurrentPosition();
print(position);
return position;
}
}

View File

@@ -0,0 +1,39 @@
import 'dart:convert';
import 'package:http/http.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../Model/Response/Appconfig/Appconfigresponse.dart';
class AppConfigurationService{
Future<AppConfigResponse?> getAppConfig(
String urldata,
) async {
AppConfigResponse? appConfigResponse;
try {
final url = Uri.parse(urldata);
final response = await get(url, headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
// 'Authorization': '$token',
});
print('appConfigResponsesproviderurldata!!!!!!!!${urldata.toString()}');
Map<String, dynamic> parsedJson = json.decode(response.body.toString());
appConfigResponse = AppConfigResponse.fromJson(parsedJson);
SharedPreferences prefs = await SharedPreferences.getInstance();
// prefs.setString('clientid', appConfigResponse.details?.clientid??'');
prefs.setString('fcmkey', appConfigResponse.details?.fcmkey??'');
prefs.setString('googleApiKey',appConfigResponse.details?.googleapikey??'');
// print('appConfigResponseclientid${appConfigResponse.details?.clientid}');
print('appConfigResponsegoogleapikey${appConfigResponse.details?.googleapikey}');
} catch (e) {
print(e.toString());
print("error");
}
return appConfigResponse;
}
}

12
lib/Helper/Logger.dart Normal file
View File

@@ -0,0 +1,12 @@
import 'package:logger/logger.dart';
var logger = Logger(
printer: PrettyPrinter(
methodCount: 2, // Number of method calls to be displayed
errorMethodCount: 8, // Number of method calls if stacktrace is provided
lineLength: 300, // Width of the output
colors: true, // Colorful log messages
printEmojis: true, // Print an emoji for each log message
printTime: false // Should each log print contain a timestamp
),
);

53
lib/Helper/adaptive.dart Normal file
View File

@@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
class ResponsiveWidget extends StatelessWidget {
final Widget? largeScreen;
final Widget? mediumScreen;
final Widget? smallScreen;
final Widget? bigScreen;
const ResponsiveWidget(
{Key? key,
@required this.largeScreen,
this.mediumScreen,
this.smallScreen,this.bigScreen})
: super(key: key);
static bool isSmallScreen(BuildContext context) {
return Get.height > 920;
}
static bool isMediumScreen(BuildContext context) {
return Get.height >=900 &&
Get.height <=1200;
}
static bool isLargeScreen(BuildContext context) {
return Get.height > 1200 &&
Get.height <=1400;
}
static bool isBigScreen(BuildContext context) {
return Get.height > 1400;
}
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
if (constraints.maxHeight > 1400) {
return bigScreen!;
} else if (constraints.maxHeight <= 1400 && constraints.maxHeight > 1200) {
return largeScreen!;
} else if(constraints.maxHeight <= 1200 && constraints.maxHeight >=900) {
return mediumScreen!;
}
else{
return smallScreen!;
}
},
);
}
}

170
lib/Helper/customDio.dart Normal file
View File

@@ -0,0 +1,170 @@
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:dio/adapter.dart';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class CustomDio{
Dio? _dio;
CustomDio(){
BaseOptions options = BaseOptions(connectTimeout: 100000,receiveTimeout: 100000);
// options.baseUrl = hostApi;
_dio = Dio(options);
// _dio.interceptors.add(LogInterceptor());
}
String? token;
String? stripeDevKey;
getToken()async{
SharedPreferences prefs = await SharedPreferences.getInstance();
token= prefs.getString('token')!;
stripeDevKey= prefs.getString('stripedevkey')!;
print("devkey====$stripeDevKey");
}
Future<Response?> get({@required String? url}) async {
await getToken();
(_dio?.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
(HttpClient client) {
client.badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
return client;
};
var data = {'token':'$token'};
print("wrl$url");
Response? response;
try{
response = await _dio?.get(url!,options: Options(
responseType: ResponseType.plain,
headers: data,contentType: "application/json"
));
}
catch(e){
print(e.toString());
}
return response;
}
Future<Response?> post({@required String? url,
@required dynamic params,Map<String,String>? header
}) async {
// await getToken();
(_dio?.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
(HttpClient client) {
client.badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
return client;
};
Response? response;
try{
response = await _dio!.post(url!,data: params!,options
:Options(responseType: ResponseType.json,contentType: "application/json",headers: header));
}
on DioError catch (e) {
print('dioerror fetch');
if (e.type == DioErrorType.response) {
print('catched');
}
if (e.type == DioErrorType.connectTimeout) {
print('check your connection');
}
if (e.type == DioErrorType.receiveTimeout) {
print('unable to connect to the server');
}
if (e.type == DioErrorType.other) {
print('Something went wrong');
}
print('try errors');
print('errorsssssssssssssssss.....');
print(e.response!);
print(e.response!.data);
print(e.message);
print(e);
}
return response;
}
//verify
Future<Response?> verifyPost({@required String? url,
@required Map<String,dynamic>? params, Map<String,String>? header
}) async {
(_dio?.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
(HttpClient client) {
client.badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
return client;
};
print("data${params.toString()}");
Response? response;
try{
response = await _dio!.post(url!,data: params,options
:Options(responseType: ResponseType.json,
headers:header,
contentType: "application/json"));
}
catch(e){
print(e.toString());
}
print("ressscatcherror${response.toString()}");
return response;
}
//app config
Future<Response> newGet({@required String? url}) async {
(_dio?.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
(HttpClient client) {
client.badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
return client;
};
Response? response;
try{
response = await _dio?.get(url!,options
:Options(responseType: ResponseType.json));
}
catch(e){
print(e.toString());
}
return response!;
}
Future<Response> put({@required String? url,@required Map<String,String>? params,@required Map<String,String>? header}) async {
await getToken();
(_dio?.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
(HttpClient client) {
client.badCertificateCallback =
(X509Certificate cert, String host, int port) => true;
return client;
};
var data = {'x-access-token': '$token'};
Response? response;
try{
response = await _dio!.put(url!,data:params,options: Options(responseType: ResponseType.json,headers: data,contentType: "application/json"));
}
catch(e){
print(e.toString());
}
return response!;
}
}

View File

@@ -0,0 +1,43 @@
import 'package:flutter/material.dart';
import 'package:rounded_loading_button_plus/rounded_loading_button.dart';
import 'Constants/Colorconstants.dart';
class RoundedButton extends StatelessWidget {
const RoundedButton(
{Key? key,
required this.onPressed,
required this.title,
required this.color,
required this.height,
required this.width,
required this.controller,
required this.textStyle})
: super(key: key);
final VoidCallback onPressed;
final String title;
final Color color;
final double height;
final double width;
final RoundedLoadingButtonController controller;
final TextStyle textStyle;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {},
child: Center(
child: RoundedLoadingButton(
height:height,
width: width,
color: color,
controller: controller,
onPressed: onPressed,
successColor: ColorConstants.primaryColor,
child: Text(
title,
style: textStyle,
))),
);
}
}

View File

@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
import 'Constants/Colorconstants.dart';
class CustomDecoration {
static InputDecoration textFieldStyle(
{String? labelTextStr = "",
String? hintTextStr = "",
Widget? prefixIcon}) {
return InputDecoration(
fillColor: Colors.white,
labelText: labelTextStr,
labelStyle: const TextStyle(
color: Color.fromRGBO(139, 137, 137, 1.0),
),
hintText: hintTextStr,
prefixIcon: prefixIcon,
counterText: "",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
borderSide: BorderSide(color: Colors.grey[200]!, width: 2)
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
borderSide: BorderSide(color: Colors.grey[200]!, width: 2)),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
borderSide:
const BorderSide(color: ColorConstants.primaryColor, width: 2)),
);
}
}

View File

@@ -0,0 +1,85 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
import 'Logger.dart';
class GooglePlacesService {
String? latitude;
String? longitude;
String? city;
int? radius;
GooglePlacesService();
Future<List<Map<String, dynamic>>> getPlacesPredictions(String input) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
final url = Uri.parse(
'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$input&components=country:IN&key=AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8');
// 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$input$city&location=$latitude,$longitude&radius=15000&bounds=$latitude,$longitude&components=country:IN&types=establishment&key=AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8');
logger.i(url);
final response = await http.get(url);
if (response.statusCode == 200) {
final Map<String, dynamic> data = json.decode(response.body);
final predictions = data['predictions'] as List<dynamic>;
return predictions.map((prediction) => prediction as Map<String, dynamic>).toList();
} else {
throw Exception('Failed to load autocomplete suggestions');
}
}
Future<Map<String, dynamic>> getPlaceDetails(String placeId) async {
final url = Uri.parse(
'https://maps.googleapis.com/maps/api/place/details/json?place_id=$placeId&key=AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8');
final response = await http.get(url);
if (response.statusCode == 200) {
final details = json.decode(response.body)['result'];
return Map<String, dynamic>.from(details);
} else {
throw Exception('Failed to load place details');
}
}
Future<String?> getPlaceIdFromAddress(String address) async {
const String apiKey = 'AIzaSyDQ2c_pOSOFYSjxGMwkFvCVWKjYOM9siow'; // Replace with your Google API key
final String url = 'https://maps.googleapis.com/maps/api/geocode/json?address=${Uri.encodeComponent(address)}&key=$apiKey';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
final data = json.decode(response.body);
if (data['results'].isNotEmpty) {
String placeId = data['results'][0]['place_id'];
logger.i('The placeId from GooglePlace APi : ${placeId}');
return placeId;
} else {
print('No results found for the provided address.');
}
} else {
print('Failed to fetch Place ID. Status code: ${response.statusCode}');
}
return null;
}
Future<double> getDistance(double pickupLat, double pickupLong, double dropLat, double dropLong) async {
const apiKey = 'AIzaSyDQ2c_pOSOFYSjxGMwkFvCVWKjYOM9siow';
final url =
'https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=$pickupLat,$pickupLong&destinations=$dropLat,$dropLong&key=$apiKey';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
final distanceText = data['rows'][0]['elements'][0]['distance']['text'];
final distanceValue = data['rows'][0]['elements'][0]['distance']['value'] / 1000; // Convert meters to kilometers
print('Distance: $distanceText');
return distanceValue;
} else {
throw Exception('Failed to load distance');
}
}
}

19
lib/Helper/toast.dart Normal file
View File

@@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'Constants/Colorconstants.dart';
class Toast{
static void showToast(String message){
Fluttertoast.showToast(
msg: message,
textColor: ColorConstants.secondaryColor,
timeInSecForIosWeb: 1,
webShowClose: true,
backgroundColor: Colors.grey[500],
gravity: ToastGravity.TOP_RIGHT,
fontSize: 15.0
);
}
}

150
lib/Helper/utility.dart Normal file
View File

@@ -0,0 +1,150 @@
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'Constants/Colorconstants.dart';
class Utility{
static Color getLightColors(String character){
final List alphabets=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
final List<Color> colors = [
Colors.blue[100]!,
Colors.indigo[100]!,
Colors.lime[100]!,
Colors.teal[100]!,
Colors.cyan[100]!,
Colors.amber[100]!,
Colors.brown[100]!,
Colors.green[100]!,
Colors.lightGreen[100]!,
Colors.red[100]!,
Colors.deepPurple[100]!,
Colors.blueGrey[100]!,
Colors.yellow[100]!,
Colors.deepOrange[100]!,
Colors.teal[100]!,
Colors.cyan[100]!,
Colors.amber[100]!,
Colors.blueGrey[100]!,
Colors.green[100]!,
Colors.lightGreen[100]!,
Colors.red[100]!,
Colors.deepPurple[100]!,
Colors.pink[100]!,
Colors.deepPurple[100]!,
Colors.purpleAccent[100]!,
Colors.orange[100]!
];
return RegExp(r"^[a-zA-Z]").hasMatch(character)?colors[alphabets.indexOf(character.toUpperCase())]:colors[0];
}
static void openPhoneCallApp(String phoneNumber) {
launch("tel:$phoneNumber");
}
static Future<void> openMap(double latitude, double longitude) async {
String googleUrl =
'https://www.google.com/maps/search/?api=1&query=$latitude,$longitude';
if (await canLaunch(googleUrl) != null) {
await launch(googleUrl);
} else {
throw 'Could not open the map.';
}
}
}
class UtilityPromotion{
static Color getLightColors(String character){
final List alphabets=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
final List<Color> colors = [
Colors.blue[200]!,
Colors.indigo[200]!,
Colors.lime[200]!,
Colors.teal[200]!,
Colors.cyan[200]!,
Colors.deepPurple[200]!,
Colors.brown[200]!,
Colors.green[200]!,
Colors.lightGreen[200]!,
Colors.red[200]!,
Colors.deepPurple[200]!,
Colors.deepPurple[200]!,
Colors.yellow[200]!,
Colors.deepOrange[200]!,
Colors.teal[200]!,
Colors.cyan[200]!,
Colors.deepPurple[200]!,
Colors.deepPurple[200]!,
Colors.green[200]!,
Colors.lightGreen[200]!,
Colors.red[200]!,
Colors.deepPurple[200]!,
Colors.pink[200]!,
Colors.deepPurple[200]!,
Colors.purpleAccent[200]!,
Colors.orange[200]!
];
return RegExp(r"^[a-zA-Z]").hasMatch(character)?colors[alphabets.indexOf(character.toUpperCase())]:colors[0];
}
}
class UtilityCustomers{
static Color getLightColors(String character){
final List alphabets=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
final List<Color> colors = [
ColorConstants.primaryColor,
Colors.blue,
Colors.redAccent,
Colors.black54,
Colors.redAccent,
Colors.black54,
Colors.black54,
Colors.orange,
Colors.purpleAccent,
Colors.purple,
Colors.pinkAccent,
Colors.teal,
Colors.blue,
Colors.redAccent,
Colors.black54,
Colors.redAccent,
Colors.black54,
Colors.purpleAccent,
Colors.purple,
Colors.orange,
Colors.pinkAccent,
Colors.teal,
Colors.blue,
Colors.redAccent,
Colors.black54,
Colors.redAccent,
Colors.black54,
Colors.pink
];
return RegExp(r"^[a-zA-Z]").hasMatch(character)?colors[alphabets.indexOf(character.toUpperCase())]:colors[0];
}
}
final Color shoppingColor = Colors.orange[100]!;
final Color wellnessColor = Colors.cyan[100]!;
final Color servicesColor = Colors.red[100]!;
class UtilityModules{
static Color getLightColors(String character){
final List alphabets=['RE','GR','SH','HE','HA'];
final List<Color> colors = [
Colors.amber[100]!,
Colors.purple[100]!,
Colors.orange[100]!,
Colors.cyan[100]!,
Colors.red[100]!,
];
return RegExp(r"^[a-zA-Z]").hasMatch(character)?colors[alphabets.indexOf(character.toUpperCase())]:colors[0];
}
}