fix(bugs): update mapStyle when change theme

This commit is contained in:
anhtunz
2025-01-22 23:13:55 +07:00
parent 408c92d843
commit bcf205f171
12 changed files with 526 additions and 543 deletions

View File

@@ -91,48 +91,38 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
child: Padding( child: Padding(
padding: context.paddingLow, padding: context.paddingLow,
child: Column( child: Column(
mainAxisAlignment: mainAxisAlignment: MainAxisAlignment.start,
MainAxisAlignment.start,
crossAxisAlignment: crossAxisAlignment:
CrossAxisAlignment.start, CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"${appLocalization(context).input_name_device_device}:", "${appLocalization(context).input_name_device_device}:",
style: context style: context.titleMediumTextStyle),
.titleMediumTextStyle),
Padding( Padding(
padding: padding: context.paddingLowVertical,
context.paddingLowVertical,
child: TextField( child: TextField(
onChanged: (value) { onChanged: (value) {
isChangedListener(); isChangedListener();
}, },
textInputAction: textInputAction: TextInputAction.next,
TextInputAction.next, controller: deviceNameController,
controller:
deviceNameController,
decoration: InputDecoration( decoration: InputDecoration(
hintText: appLocalization( hintText: appLocalization(context)
context)
.input_name_device_hintText, .input_name_device_hintText,
), ),
), ),
), ),
Text( Text(
"${appLocalization(context).device_update_location}:", "${appLocalization(context).device_update_location}:",
style: context style: context.titleMediumTextStyle),
.titleMediumTextStyle),
Padding( Padding(
padding: padding: context.paddingLowVertical,
context.paddingLowVertical,
child: Row( child: Row(
mainAxisAlignment: mainAxisAlignment:
MainAxisAlignment MainAxisAlignment.spaceBetween,
.spaceBetween,
children: [ children: [
SizedBox( SizedBox(
width: context width: context.dynamicWidth(0.6),
.dynamicWidth(0.6),
child: Column( child: Column(
children: [ children: [
SizedBox( SizedBox(
@@ -141,8 +131,7 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
isChangedListener(); isChangedListener();
}, },
textInputAction: textInputAction:
TextInputAction TextInputAction.next,
.next,
controller: controller:
deviceLatitudeController, deviceLatitudeController,
decoration: decoration:
@@ -160,8 +149,7 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
.paddingLowVertical, .paddingLowVertical,
child: SizedBox( child: SizedBox(
child: TextField( child: TextField(
onChanged: onChanged: (value) {
(value) {
isChangedListener(); isChangedListener();
}, },
controller: controller:
@@ -188,8 +176,7 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
style: const ButtonStyle( style: const ButtonStyle(
backgroundColor: backgroundColor:
WidgetStatePropertyAll( WidgetStatePropertyAll(
Colors Colors.lightGreen)),
.lightGreen)),
// iconSize: 24, // iconSize: 24,
onPressed: () async { onPressed: () async {
showMapDialog( showMapDialog(
@@ -203,38 +190,31 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
), ),
), ),
), ),
SizedBox( SizedBox(width: context.lowValue),
width: context.lowValue),
], ],
), ),
), ),
Text( Text(
"${appLocalization(context).device_update_province}:", "${appLocalization(context).device_update_province}:",
style: context style: context.titleMediumTextStyle),
.titleMediumTextStyle),
Padding( Padding(
padding: padding: context.paddingLowVertical,
context.paddingLowVertical,
child: StreamBuilder< child: StreamBuilder<
List< List<DropdownMenuItem<Province>>>(
DropdownMenuItem<
Province>>>(
stream: deviceUpdateBloc stream: deviceUpdateBloc
.streamListProvinces, .streamListProvinces,
builder: (dialogContext, builder:
listProvinces) { (dialogContext, listProvinces) {
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: borderRadius:
const BorderRadius const BorderRadius.all(
.all(
Radius.circular(20), Radius.circular(20),
), ),
border: Border.all(), border: Border.all(),
), ),
child: SearchChoices.single( child: SearchChoices.single(
items: items: listProvinces.data ??
listProvinces.data ??
provincesData, provincesData,
hint: provinceNameSnapshot hint: provinceNameSnapshot
.data != .data !=
@@ -245,8 +225,7 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
'name'] ?? 'name'] ??
"", "",
) )
: appLocalization( : appLocalization(context)
context)
.update_device_dialog_location_province_hintText, .update_device_dialog_location_province_hintText,
searchHint: appLocalization( searchHint: appLocalization(
context) context)
@@ -279,8 +258,7 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
selectedWard = ""; selectedWard = "";
wardData['name'] = wardData['name'] =
selectedWard!; selectedWard!;
deviceUpdateBloc deviceUpdateBloc.sinkWardData
.sinkWardData
.add(wardData); .add(wardData);
}, },
isExpanded: true, isExpanded: true,
@@ -291,31 +269,25 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
), ),
Text( Text(
"${appLocalization(context).device_update_district}:", "${appLocalization(context).device_update_district}:",
style: context style: context.titleMediumTextStyle),
.titleMediumTextStyle),
Padding( Padding(
padding: padding: context.paddingLowVertical,
context.paddingLowVertical,
child: StreamBuilder< child: StreamBuilder<
List< List<DropdownMenuItem<District>>>(
DropdownMenuItem<
District>>>(
stream: deviceUpdateBloc stream: deviceUpdateBloc
.streamListDistricts, .streamListDistricts,
builder: (dialogContext, builder:
listDistricts) { (dialogContext, listDistricts) {
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: borderRadius:
const BorderRadius const BorderRadius.all(
.all(
Radius.circular(20), Radius.circular(20),
), ),
border: Border.all(), border: Border.all(),
), ),
child: SearchChoices.single( child: SearchChoices.single(
items: items: listDistricts.data ??
listDistricts.data ??
districtsData, districtsData,
hint: districtNameSnapshot hint: districtNameSnapshot
.data != .data !=
@@ -326,8 +298,7 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
'name'] ?? 'name'] ??
selectedDistrict!, selectedDistrict!,
) )
: appLocalization( : appLocalization(context)
context)
.update_device_dialog_location_district_hintText, .update_device_dialog_location_district_hintText,
searchHint: appLocalization( searchHint: appLocalization(
context) context)
@@ -347,13 +318,11 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
.sinkDistrictData .sinkDistrictData
.add(districtData); .add(districtData);
deviceUpdateBloc deviceUpdateBloc
.getAllWards( .getAllWards(value.code);
value.code);
selectedWard = ""; selectedWard = "";
wardData['name'] = wardData['name'] =
selectedWard!; selectedWard!;
deviceUpdateBloc deviceUpdateBloc.sinkWardData
.sinkWardData
.add(wardData); .add(wardData);
}, },
isExpanded: true, isExpanded: true,
@@ -364,39 +333,31 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
), ),
Text( Text(
"${appLocalization(context).device_update_ward}:", "${appLocalization(context).device_update_ward}:",
style: context style: context.titleMediumTextStyle),
.titleMediumTextStyle),
Padding( Padding(
padding: padding: context.paddingLowVertical,
context.paddingLowVertical,
child: StreamBuilder< child: StreamBuilder<
List<DropdownMenuItem<Ward>>>( List<DropdownMenuItem<Ward>>>(
stream: deviceUpdateBloc stream:
.streamListWards, deviceUpdateBloc.streamListWards,
builder: builder: (dialogContext, listWards) {
(dialogContext, listWards) {
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: borderRadius:
const BorderRadius const BorderRadius.all(
.all( Radius.circular(20)),
Radius.circular(
20)),
border: Border.all()), border: Border.all()),
child: SearchChoices.single( child: SearchChoices.single(
items: listWards.data ?? items:
wardsData, listWards.data ?? wardsData,
hint: wardNameSnapshot hint: wardNameSnapshot.data !=
.data !=
null null
? Text( ? Text(
wardNameSnapshot wardNameSnapshot.data![
.data![
'name'] ?? 'name'] ??
selectedWard!, selectedWard!,
) )
: appLocalization( : appLocalization(context)
context)
.update_device_dialog_location_ward_hintText, .update_device_dialog_location_ward_hintText,
searchHint: appLocalization( searchHint: appLocalization(
context) context)
@@ -405,14 +366,12 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
onChanged: (value) { onChanged: (value) {
isChangedListener(); isChangedListener();
// wardCode = value.code; // wardCode = value.code;
selectedWard = selectedWard = value.fullName;
value.fullName;
wardData['name'] = wardData['name'] =
value.fullName!; value.fullName!;
wardData['code'] = wardData['code'] =
value.code!; value.code!;
deviceUpdateBloc deviceUpdateBloc.sinkWardData
.sinkWardData
.add(wardData); .add(wardData);
}, },
isExpanded: true, isExpanded: true,
@@ -424,33 +383,28 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
if (isChangedSnapshot.data == true) if (isChangedSnapshot.data == true)
Center( Center(
child: SizedBox( child: SizedBox(
width: width: context.dynamicWidth(0.6),
context.dynamicWidth(0.6),
child: TextButton( child: TextButton(
style: ButtonStyle( style: ButtonStyle(
foregroundColor: foregroundColor:
WidgetStateProperty WidgetStateProperty.all(
.all(Colors Colors.white),
.white),
backgroundColor: backgroundColor:
WidgetStateProperty WidgetStateProperty.all(
.all(Colors Colors.blue),
.blue)), ),
onPressed: () async { onPressed: () async {
String provinceCode = String provinceCode =
provinceNameSnapshot provinceNameSnapshot
.data![ .data!["code"] ??
"code"] ??
""; "";
String districtCode = String districtCode =
districtNameSnapshot districtNameSnapshot
.data![ .data!["code"] ??
"code"] ??
""; "";
String wardCode = String wardCode =
wardNameSnapshot wardNameSnapshot
.data![ .data!["code"] ??
"code"] ??
""; "";
String latitude = String latitude =
deviceLatitudeController deviceLatitudeController
@@ -483,13 +437,15 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
context.lowDuration, context.lowDuration,
() { () {
Navigator.pop( // ignore: use_build_context_synchronously
context); Navigator.pop(context);
});
}, },
child: Text(appLocalization( );
context) },
.update_button_content)), child: Text(
appLocalization(context)
.update_button_content),
),
), ),
), ),
], ],
@@ -502,9 +458,12 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
}, },
), ),
); );
}); },
}); );
}), },
);
},
),
); );
} }

View File

@@ -29,6 +29,7 @@ showMapDialog(
TextEditingController mapDialogLongitudeController = TextEditingController(); TextEditingController mapDialogLongitudeController = TextEditingController();
Completer<GoogleMapController> ggmapController = Completer(); Completer<GoogleMapController> ggmapController = Completer();
final streamController = StreamController<GoogleMapController>.broadcast(); final streamController = StreamController<GoogleMapController>.broadcast();
showGeneralDialog( showGeneralDialog(
barrierDismissible: false, barrierDismissible: false,
transitionDuration: context.normalDuration, transitionDuration: context.normalDuration,

View File

@@ -2,10 +2,10 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:sfm_app/product/shared/shared_pie_chart.dart';
import 'add_new_device_widget.dart'; import 'add_new_device_widget.dart';
import 'delete_device_widget.dart'; import 'delete_device_widget.dart';
import 'device_model.dart'; import 'device_model.dart';
import '../../product/shared/shared_pie_chart.dart';
import '../../bloc/devices_manager_bloc.dart'; import '../../bloc/devices_manager_bloc.dart';
import '../../product/base/bloc/base_bloc.dart'; import '../../product/base/bloc/base_bloc.dart';
import '../../product/constant/enums/app_route_enums.dart'; import '../../product/constant/enums/app_route_enums.dart';

View File

@@ -2,10 +2,12 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:developer'; import 'dart:developer';
import 'package:flutter/services.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart'; import 'package:geolocator/geolocator.dart';
import 'package:google_maps_cluster_manager_2/google_maps_cluster_manager_2.dart'; import 'package:google_maps_cluster_manager_2/google_maps_cluster_manager_2.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'
hide ClusterManager, Cluster;
import 'package:sfm_app/feature/devices/device_model.dart'; import 'package:sfm_app/feature/devices/device_model.dart';
import 'package:sfm_app/bloc/map_bloc.dart'; import 'package:sfm_app/bloc/map_bloc.dart';
import 'package:sfm_app/feature/map/widget/on_tap_marker_widget.dart'; import 'package:sfm_app/feature/map/widget/on_tap_marker_widget.dart';
@@ -13,7 +15,6 @@ import 'package:sfm_app/product/base/bloc/base_bloc.dart';
import 'package:sfm_app/product/constant/icon/icon_constants.dart'; import 'package:sfm_app/product/constant/icon/icon_constants.dart';
import 'package:sfm_app/product/permission/location_permission.dart'; import 'package:sfm_app/product/permission/location_permission.dart';
import 'package:sfm_app/product/services/api_services.dart'; import 'package:sfm_app/product/services/api_services.dart';
import '../../product/constant/enums/app_theme_enums.dart'; import '../../product/constant/enums/app_theme_enums.dart';
class MapScreen extends StatefulWidget { class MapScreen extends StatefulWidget {
@@ -32,7 +33,7 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
late BitmapDescriptor fireStationIcon; late BitmapDescriptor fireStationIcon;
late MapBloc mapBloc; late MapBloc mapBloc;
late ClusterManager clusterManager; late ClusterManager clusterManager;
MapType mapType = MapType.terrain; // MapType mapType = MapType.terrain;
APIServices apiServices = APIServices(); APIServices apiServices = APIServices();
final streamController = StreamController<GoogleMapController>.broadcast(); final streamController = StreamController<GoogleMapController>.broadcast();
List<Device> devices = []; List<Device> devices = [];
@@ -50,30 +51,31 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
); );
Set<Marker> markersAll = {}; Set<Marker> markersAll = {};
List<Marker> markers = []; List<Marker> markers = [];
LatLng myLocation = const LatLng(213761, 123123); // LatLng myLocation = const LatLng(213761, 123123);
Position? position; // Position? position;
bool isAllowLocationPermission = false; // bool isAllowLocationPermission = false;
String themeMode = ""; String themeMode = '';
@override @override
void initState() { void initState() {
super.initState(); super.initState();
mapBloc = BlocProvider.of(context); mapBloc = BlocProvider.of(context);
checkTheme();
_loadIcons(); _loadIcons();
getAllMarkers(); getAllMarkers();
clusterManager = _initClusterManager(); clusterManager = _initClusterManager();
DefaultAssetBundle.of(context)
.loadString("assets/map_themes/maps_dark_theme.json")
.then(
(value) => {themeMode = value},
);
} }
@override @override
void dispose() { void dispose() {
streamController.close();
_controller = Completer();
super.dispose(); super.dispose();
_controller = Completer();
streamController.close();
}
void onMapCreated(GoogleMapController controller) {
_controller.complete(controller);
streamController.add(controller);
clusterManager.setMapId(controller.mapId);
checkTheme();
} }
@override @override
@@ -92,18 +94,11 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
builder: (context, mapThemeSnapshot) { builder: (context, mapThemeSnapshot) {
return GoogleMap( return GoogleMap(
initialCameraPosition: _myPosition, initialCameraPosition: _myPosition,
mapType: mapType, // mapType: mapType,
onMapCreated: (GoogleMapController controller) { onMapCreated: onMapCreated,
controller.setMapStyle(themeMode);
if (!_controller.isCompleted) {
_controller.complete(controller);
}
streamController.sink.add(controller);
clusterManager.setMapId(controller.mapId);
},
markers: markerSnapshot.data ?? markersAll markers: markerSnapshot.data ?? markersAll
..addAll(markers), ..addAll(markers),
zoomControlsEnabled: true, zoomControlsEnabled: false,
myLocationEnabled: true, myLocationEnabled: true,
mapToolbarEnabled: false, mapToolbarEnabled: false,
onCameraMove: (position) { onCameraMove: (position) {
@@ -120,8 +115,10 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
width: 8, width: 8,
), ),
}, },
style: mapThemeSnapshot.data,
);
},
); );
});
}, },
); );
}, },
@@ -134,22 +131,22 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
void checkTheme() async { void checkTheme() async {
String theme = await apiServices.checkTheme(); String theme = await apiServices.checkTheme();
if (theme == AppThemes.LIGHT.name) { if (theme == AppThemes.LIGHT.name) {
getThemeMode('assets/map_themes/maps_light_theme.json'); themeMode = '';
} else { } else {
getThemeMode('assets/map_themes/maps_dark_theme.json'); themeMode = await _getFileData('assets/map_themes/maps_dark_theme.json');
} }
}
void getThemeMode(String path) {
DefaultAssetBundle.of(context)
.loadString(path)
.then((value) => {themeMode = value});
mapBloc.sinkMapTheme.add(themeMode); mapBloc.sinkMapTheme.add(themeMode);
} }
Future<String> _getFileData(String path) async {
return rootBundle.loadString(path);
}
Future<void> _loadIcons() async { Future<void> _loadIcons() async {
List<Future<BitmapDescriptor>> iconFutures = imageAssets.map((asset) { List<Future<BitmapDescriptor>> iconFutures = imageAssets.map((asset) {
return BitmapDescriptor.fromAssetImage(const ImageConfiguration(), asset); return BitmapDescriptor.asset(
const ImageConfiguration(size: Size(50, 50)), asset);
}).toList(); }).toList();
List<BitmapDescriptor> icons = await Future.wait(iconFutures); List<BitmapDescriptor> icons = await Future.wait(iconFutures);
@@ -180,8 +177,8 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
bool check = await checkLocationPermission(context); bool check = await checkLocationPermission(context);
if (check == true) { if (check == true) {
Position position = await Geolocator.getCurrentPosition(); Position position = await Geolocator.getCurrentPosition();
// ignore: use_build_context_synchronously
onTapMarker( onTapMarker(
// ignore: use_build_context_synchronously
context, context,
_controller, _controller,
mapBloc, mapBloc,
@@ -262,6 +259,7 @@ class _MapScreenState extends State<MapScreen> with WidgetsBindingObserver {
void _updateMarkers(Set<Marker> marker) { void _updateMarkers(Set<Marker> marker) {
log("Update Marker"); log("Update Marker");
checkTheme();
markersAll = marker; markersAll = marker;
mapBloc.sinkAllMarker.add(marker); mapBloc.sinkAllMarker.add(marker);
} }

View File

@@ -93,9 +93,13 @@ onTapMarker(
double.parse(device.settings!.longitude!), double.parse(device.settings!.longitude!),
); );
}, },
style: const ButtonStyle( style: ButtonStyle(
backgroundColor: WidgetStatePropertyAll(Colors.blue), backgroundColor: WidgetStatePropertyAll(
foregroundColor: WidgetStatePropertyAll(Colors.white), Theme.of(context).toggleButtonsTheme.fillColor),
foregroundColor: WidgetStatePropertyAll(
Theme.of(context).canvasColor),
iconColor: WidgetStatePropertyAll(
Theme.of(context).canvasColor),
), ),
child: Row( child: Row(
children: [ children: [
@@ -129,6 +133,7 @@ onTapMarker(
style: const ButtonStyle( style: const ButtonStyle(
backgroundColor: WidgetStatePropertyAll(Colors.pink), backgroundColor: WidgetStatePropertyAll(Colors.pink),
foregroundColor: WidgetStatePropertyAll(Colors.white), foregroundColor: WidgetStatePropertyAll(Colors.white),
iconColor: WidgetStatePropertyAll(Colors.white),
), ),
icon: IconConstants.instance icon: IconConstants.instance
.getMaterialIcon(Icons.local_hospital), .getMaterialIcon(Icons.local_hospital),
@@ -249,7 +254,7 @@ onTapMarker(
), ),
], ],
source: deviceSource, source: deviceSource,
rowsPerPage: 5, rowsPerPage: devices.length > 4 ? 5 : devices.length,
), ),
], ],
), ),
@@ -279,13 +284,18 @@ class DeviceSource extends DataTableSource {
String deviceState = String deviceState =
DeviceUtils.instance.checkStateDevice(context, device.state!); DeviceUtils.instance.checkStateDevice(context, device.state!);
return DataRow.byIndex( return DataRow.byIndex(
color: WidgetStatePropertyAll( // color: WidgetStatePropertyAll(
DeviceUtils.instance.getTableRowColor(device.state ?? -1), // DeviceUtils.instance.getTableRowColor(device.state ?? -1),
), // ),
index: index, index: index,
cells: [ cells: [
DataCell( DataCell(
Text(device.name!), Text(
device.name!,
style: TextStyle(
color:
DeviceUtils.instance.getTableRowColor(device.state ?? -1)),
),
onTap: () { onTap: () {
mapBloc.updateCameraPosition( mapBloc.updateCameraPosition(
controller, controller,
@@ -297,7 +307,12 @@ class DeviceSource extends DataTableSource {
}, },
), ),
DataCell( DataCell(
Text(deviceState), Text(
deviceState,
style: TextStyle(
color:
DeviceUtils.instance.getTableRowColor(device.state ?? -1)),
),
onTap: () { onTap: () {
mapBloc.updateCameraPosition( mapBloc.updateCameraPosition(
controller, controller,
@@ -308,7 +323,12 @@ class DeviceSource extends DataTableSource {
}, },
), ),
DataCell( DataCell(
Text(sensorMap['sensorBattery'] + "%"), Text(
sensorMap['sensorBattery'] + "%",
style: TextStyle(
color:
DeviceUtils.instance.getTableRowColor(device.state ?? -1)),
),
onTap: () { onTap: () {
mapBloc.updateCameraPosition( mapBloc.updateCameraPosition(
controller, controller,
@@ -319,7 +339,12 @@ class DeviceSource extends DataTableSource {
}, },
), ),
DataCell( DataCell(
Text(sensorMap['sensorCsq']), Text(
sensorMap['sensorCsq'],
style: TextStyle(
color:
DeviceUtils.instance.getTableRowColor(device.state ?? -1)),
),
onTap: () { onTap: () {
mapBloc.updateCameraPosition( mapBloc.updateCameraPosition(
controller, controller,

View File

@@ -1,3 +1,5 @@
// ignore_for_file: use_build_context_synchronously
import 'dart:developer' as dev; import 'dart:developer' as dev;
import 'dart:math' as math; import 'dart:math' as math;
import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_messaging/firebase_messaging.dart';
@@ -90,8 +92,7 @@ class NotificationServices {
RemoteMessage? initialMessage = RemoteMessage? initialMessage =
await FirebaseMessaging.instance.getInitialMessage(); await FirebaseMessaging.instance.getInitialMessage();
if (initialMessage != null) { if (initialMessage != null) {
// showNotification(initialMessage); // showNotification(initialMessage)
// ignore: use_build_context_synchronously
handleMessage(context, initialMessage); handleMessage(context, initialMessage);
} }

View File

@@ -1,4 +1,6 @@
import 'dart:developer';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'error_response_model.dart'; import 'error_response_model.dart';
@@ -87,7 +89,7 @@ class DioErrorHandler {
// } // }
getMas(dynamic error) { getMas(dynamic error) {
print("myError ${error.runtimeType}"); log("myError ${error.runtimeType}");
if (error.runtimeType != String) { if (error.runtimeType != String) {
errorResponse.message = errorResponse.message =
error['message'].toString(); //?? S.of(Get.context).something_wrong; error['message'].toString(); //?? S.of(Get.context).something_wrong;
@@ -128,7 +130,7 @@ class ErrorHandler {
// return error.toString(); // return error.toString();
errorResponse.message = "The Provided API key is invalid"; errorResponse.message = "The Provided API key is invalid";
return errorResponse; return errorResponse;
} else if (error is DioError) { } else if (error is DioException) {
return DioErrorHandler().handleDioError(error); return DioErrorHandler().handleDioError(error);
} }
errorResponse.message = "The Provided API key is invalid"; errorResponse.message = "The Provided API key is invalid";

View File

@@ -1,4 +1,4 @@
// ignore_for_file: unnecessary_this, use_build_context_synchronously, prefer_typing_uninitialized_variables, library_private_types_in_public_api // ignore_for_file: unnecessary_this, use_build_context_synchronously, prefer_typing_uninitialized_variables, library_private_types_in_public_api, prefer_const_constructors
import 'dart:developer'; import 'dart:developer';
@@ -54,12 +54,10 @@ class NearBySearchSFM extends StatefulWidget {
this.textInputAction}); this.textInputAction});
@override @override
_NearBySearchSFMState createState() => _NearBySearchSFMState createState() => _NearBySearchSFMState();
_NearBySearchSFMState();
} }
class _NearBySearchSFMState class _NearBySearchSFMState extends State<NearBySearchSFM> {
extends State<NearBySearchSFM> {
final subject = PublishSubject<String>(); final subject = PublishSubject<String>();
OverlayEntry? _overlayEntry; OverlayEntry? _overlayEntry;
List<Prediction> alPredictions = []; List<Prediction> alPredictions = [];
@@ -127,9 +125,9 @@ class _NearBySearchSFMState
String country = widget.countries![i]; String country = widget.countries![i];
if (i == 0) { if (i == 0) {
url = url + "&components=country:$country"; url = "$url&components=country:$country";
} else { } else {
url = url + "|" + "country:" + country; url = "$url|country:$country";
} }
} }
} }
@@ -184,8 +182,8 @@ class _NearBySearchSFMState
} }
textChanged(String text) async { textChanged(String text) async {
getLocation(text, widget.locationLatitude, widget.locationLongitude, getLocation(
widget.radius); text, widget.locationLatitude, widget.locationLongitude, widget.radius);
} }
OverlayEntry? _createOverlayEntry() { OverlayEntry? _createOverlayEntry() {
@@ -278,7 +276,9 @@ class _NearBySearchSFMState
if (this._overlayEntry != null) { if (this._overlayEntry != null) {
try { try {
this._overlayEntry?.remove(); this._overlayEntry?.remove();
} catch (e) {} } catch (e) {
log("Error: $e");
}
} }
} }
@@ -289,7 +289,7 @@ class _NearBySearchSFMState
_showSnackBar(String errorData) { _showSnackBar(String errorData) {
if (widget.showError) { if (widget.showError) {
final snackBar = SnackBar( final snackBar = SnackBar(
content: Text("$errorData"), content: Text(errorData),
); );
ScaffoldMessenger.of(context).showSnackBar(snackBar); ScaffoldMessenger.of(context).showSnackBar(snackBar);
} }

View File

@@ -26,8 +26,6 @@ class _SharedPieChartState extends State<SharedPieChart> {
int lastTouchedIndex = -1; int lastTouchedIndex = -1;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
int touchedIndex = -1;
TextStyle titleStyle = const TextStyle( TextStyle titleStyle = const TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 20, fontSize: 20,
@@ -61,7 +59,6 @@ class _SharedPieChartState extends State<SharedPieChart> {
if (!event.isInterestedForInteractions || if (!event.isInterestedForInteractions ||
pieTouchResponse == null || pieTouchResponse == null ||
pieTouchResponse.touchedSection == null) { pieTouchResponse.touchedSection == null) {
touchedIndex = -1;
return; return;
} }
int newTouchedIndex = int newTouchedIndex =

View File

@@ -85,10 +85,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: csslib name: csslib
sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb" sha256: "09bad715f418841f976c77db72d5398dc1253c21fb9c0c7f0b0b985860b2d58e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.0" version: "1.0.2"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -369,10 +369,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: google_maps name: google_maps
sha256: "555d5d736339b0478e821167ac521c810d7b51c3b2734e6802a9f046b64ea37a" sha256: "4d6e199c561ca06792c964fa24b2bac7197bf4b401c2e1d23e345e5f9939f531"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.3.0" version: "8.1.1"
google_maps_cluster_manager_2: google_maps_cluster_manager_2:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -385,26 +385,26 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: google_maps_flutter name: google_maps_flutter
sha256: ae66fef3e71261d7df2eff29b2a119e190b2884325ecaa55321b1e17b5504066 sha256: "209856c8e5571626afba7182cf634b2910069dc567954e76ec3e3fb37f5e9db3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.5.3" version: "2.10.0"
google_maps_flutter_android: google_maps_flutter_android:
dependency: transitive dependency: transitive
description: description:
name: google_maps_flutter_android name: google_maps_flutter_android
sha256: "714530f865f13bb3b9505c58821c3baed5d247a871724acf5d2ea5808fbed02c" sha256: "1b69fbb3ab76e7a7dfcf25e60f32f81ae5d9b88285343eecb5479116d54be869"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.6.2" version: "2.14.12"
google_maps_flutter_ios: google_maps_flutter_ios:
dependency: transitive dependency: transitive
description: description:
name: google_maps_flutter_ios name: google_maps_flutter_ios
sha256: c89556ed0338fcb4b843c9fcdafac7ad2df601c8b41286d82f0727f7f66434e4 sha256: "6f798adb0aa1db5adf551f2e39e24bd06c8c0fbe4de912fb2d9b5b3f48147b02"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.6" version: "2.13.2"
google_maps_flutter_platform_interface: google_maps_flutter_platform_interface:
dependency: transitive dependency: transitive
description: description:
@@ -417,18 +417,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: google_maps_flutter_web name: google_maps_flutter_web
sha256: "05067c5aa762ebee44b7ef4902a311ed8cf891ef655e2798bae063aa3050c8d9" sha256: ff39211bd25d7fad125d19f757eba85bd154460907cd4d135e07e3d0f98a4130
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.4+1" version: "0.5.10"
html: html:
dependency: transitive dependency: transitive
description: description:
name: html name: html
sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" sha256: "1fc58edeaec4307368c60d59b7e15b9d658b57d7f3125098b6294153c75337ec"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.15.4" version: "0.15.5"
http: http:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -461,14 +461,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.7" version: "0.6.7"
js_wrapping:
dependency: transitive
description:
name: js_wrapping
sha256: e385980f7c76a8c1c9a560dfb623b890975841542471eade630b2871d243851c
url: "https://pub.dev"
source: hosted
version: "0.7.4"
leak_tracker: leak_tracker:
dependency: transitive dependency: transitive
description: description:
@@ -930,6 +922,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "14.3.0" version: "14.3.0"
web:
dependency: transitive
description:
name: web
sha256: cd3543bd5798f6ad290ea73d210f423502e71900302dde696f8bff84bf89a1cb
url: "https://pub.dev"
source: hosted
version: "1.1.0"
win32: win32:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@@ -50,7 +50,6 @@ dependencies:
badges: ^3.1.2 badges: ^3.1.2
# google_maps_cluster_manager: ^3.1.0 # google_maps_cluster_manager: ^3.1.0
google_maps_cluster_manager_2: ^3.2.0 google_maps_cluster_manager_2: ^3.2.0
google_maps_flutter: ^2.5.0
dropdown_button2: ^2.3.9 dropdown_button2: ^2.3.9
maps_launcher: ^2.2.1 maps_launcher: ^2.2.1
flutter_barcode_scanner: ^2.0.0 flutter_barcode_scanner: ^2.0.0
@@ -65,6 +64,7 @@ dependencies:
# persistent_bottom_nav_bar_v2: ^4.2.8 # persistent_bottom_nav_bar_v2: ^4.2.8
persistent_bottom_nav_bar: ^6.2.1 persistent_bottom_nav_bar: ^6.2.1
win32: ^5.10.0 win32: ^5.10.0
google_maps_flutter: ^2.10.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test: