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

@@ -58,453 +58,412 @@ class _DeviceUpdateScreenState extends State<DeviceUpdateScreen> {
title: Text(appLocalization(context).device_update_title),
),
body: StreamBuilder<Map<String, String>>(
stream: deviceUpdateBloc.streamProvinceData,
builder: (context, provinceNameSnapshot) {
return StreamBuilder<Map<String, String>>(
stream: deviceUpdateBloc.streamDistrictData,
builder: (context, districtNameSnapshot) {
return StreamBuilder<Map<String, String>>(
stream: deviceUpdateBloc.streamWardData,
builder: (context, wardNameSnapshot) {
return SafeArea(
child: StreamBuilder<Device>(
stream: deviceUpdateBloc.streamDeviceInfo,
initialData: device,
builder: (context, deviceInfoSnapshot) {
if (deviceInfoSnapshot.data!.thingId == null) {
deviceUpdateBloc.getDeviceInfomation(
widget.thingID,
districtsData,
wardsData,
deviceNameController,
deviceLatitudeController,
deviceLongitudeController);
return const Center(
child: CircularProgressIndicator(),
);
} else {
return StreamBuilder<bool>(
stream: deviceUpdateBloc.streamIsChanged,
initialData: isChanged,
builder: (context, isChangedSnapshot) {
return SingleChildScrollView(
child: Padding(
padding: context.paddingLow,
child: Column(
stream: deviceUpdateBloc.streamProvinceData,
builder: (context, provinceNameSnapshot) {
return StreamBuilder<Map<String, String>>(
stream: deviceUpdateBloc.streamDistrictData,
builder: (context, districtNameSnapshot) {
return StreamBuilder<Map<String, String>>(
stream: deviceUpdateBloc.streamWardData,
builder: (context, wardNameSnapshot) {
return SafeArea(
child: StreamBuilder<Device>(
stream: deviceUpdateBloc.streamDeviceInfo,
initialData: device,
builder: (context, deviceInfoSnapshot) {
if (deviceInfoSnapshot.data!.thingId == null) {
deviceUpdateBloc.getDeviceInfomation(
widget.thingID,
districtsData,
wardsData,
deviceNameController,
deviceLatitudeController,
deviceLongitudeController);
return const Center(
child: CircularProgressIndicator(),
);
} else {
return StreamBuilder<bool>(
stream: deviceUpdateBloc.streamIsChanged,
initialData: isChanged,
builder: (context, isChangedSnapshot) {
return SingleChildScrollView(
child: Padding(
padding: context.paddingLow,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
"${appLocalization(context).input_name_device_device}:",
style: context.titleMediumTextStyle),
Padding(
padding: context.paddingLowVertical,
child: TextField(
onChanged: (value) {
isChangedListener();
},
textInputAction: TextInputAction.next,
controller: deviceNameController,
decoration: InputDecoration(
hintText: appLocalization(context)
.input_name_device_hintText,
),
),
),
Text(
"${appLocalization(context).device_update_location}:",
style: context.titleMediumTextStyle),
Padding(
padding: context.paddingLowVertical,
child: Row(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
MainAxisAlignment.spaceBetween,
children: [
Text(
"${appLocalization(context).input_name_device_device}:",
style: context
.titleMediumTextStyle),
Padding(
padding:
context.paddingLowVertical,
child: TextField(
onChanged: (value) {
isChangedListener();
},
textInputAction:
TextInputAction.next,
controller:
deviceNameController,
decoration: InputDecoration(
hintText: appLocalization(
context)
.input_name_device_hintText,
),
),
),
Text(
"${appLocalization(context).device_update_location}:",
style: context
.titleMediumTextStyle),
Padding(
padding:
context.paddingLowVertical,
child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
SizedBox(
width: context.dynamicWidth(0.6),
child: Column(
children: [
SizedBox(
width: context
.dynamicWidth(0.6),
child: Column(
children: [
SizedBox(
child: TextField(
onChanged: (value) {
isChangedListener();
},
textInputAction:
TextInputAction
.next,
controller:
deviceLatitudeController,
decoration:
InputDecoration(
label: Text(
"${appLocalization(context).update_device_dialog_location_longitude}:"),
hintText: appLocalization(
context)
.update_device_dialog_location_longitude_hintText,
),
),
),
Padding(
padding: context
.paddingLowVertical,
child: SizedBox(
child: TextField(
onChanged:
(value) {
isChangedListener();
},
controller:
deviceLongitudeController,
textInputAction:
TextInputAction
.next,
decoration:
InputDecoration(
label: Text(
"${appLocalization(context).update_device_dialog_location_latitude}:"),
hintText: appLocalization(
context)
.update_device_dialog_location_latitude_hintText,
),
),
),
),
],
),
),
Center(
child: IconButton.filled(
style: const ButtonStyle(
backgroundColor:
WidgetStatePropertyAll(
Colors
.lightGreen)),
// iconSize: 24,
onPressed: () async {
showMapDialog(
context,
deviceUpdateBloc,
deviceLatitudeController,
deviceLongitudeController);
child: TextField(
onChanged: (value) {
isChangedListener();
},
icon: const Icon(
Icons.map_outlined,
textInputAction:
TextInputAction.next,
controller:
deviceLatitudeController,
decoration:
InputDecoration(
label: Text(
"${appLocalization(context).update_device_dialog_location_longitude}:"),
hintText: appLocalization(
context)
.update_device_dialog_location_longitude_hintText,
),
),
),
Padding(
padding: context
.paddingLowVertical,
child: SizedBox(
child: TextField(
onChanged: (value) {
isChangedListener();
},
controller:
deviceLongitudeController,
textInputAction:
TextInputAction
.next,
decoration:
InputDecoration(
label: Text(
"${appLocalization(context).update_device_dialog_location_latitude}:"),
hintText: appLocalization(
context)
.update_device_dialog_location_latitude_hintText,
),
),
),
),
SizedBox(
width: context.lowValue),
],
),
),
Text(
"${appLocalization(context).device_update_province}:",
style: context
.titleMediumTextStyle),
Padding(
padding:
context.paddingLowVertical,
child: StreamBuilder<
List<
DropdownMenuItem<
Province>>>(
stream: deviceUpdateBloc
.streamListProvinces,
builder: (dialogContext,
listProvinces) {
return Container(
decoration: BoxDecoration(
borderRadius:
const BorderRadius
.all(
Radius.circular(20),
),
border: Border.all(),
),
child: SearchChoices.single(
items:
listProvinces.data ??
provincesData,
hint: provinceNameSnapshot
.data !=
null
? Text(
provinceNameSnapshot
.data![
'name'] ??
"",
)
: appLocalization(
context)
.update_device_dialog_location_province_hintText,
searchHint: appLocalization(
context)
.update_device_dialog_location_province_searchHint,
displayClearIcon: false,
onChanged: (value) {
isChangedListener();
// provinceCode =
// value.code;
selectedProvince =
value.fullName;
provinceData['name'] =
value.fullName;
provinceData['code'] =
value.code;
deviceUpdateBloc
.sinkProvinceData
.add(provinceData);
deviceUpdateBloc
.getAllDistricts(
value.code);
selectedDistrict = "";
districtData['name'] =
selectedDistrict!;
// deviceUpdateBloc.sinkDistrictName
// .add(selectedDistrict);
deviceUpdateBloc
.sinkDistrictData
.add(districtData);
selectedWard = "";
wardData['name'] =
selectedWard!;
deviceUpdateBloc
.sinkWardData
.add(wardData);
},
isExpanded: true,
),
);
Center(
child: IconButton.filled(
style: const ButtonStyle(
backgroundColor:
WidgetStatePropertyAll(
Colors.lightGreen)),
// iconSize: 24,
onPressed: () async {
showMapDialog(
context,
deviceUpdateBloc,
deviceLatitudeController,
deviceLongitudeController);
},
),
),
Text(
"${appLocalization(context).device_update_district}:",
style: context
.titleMediumTextStyle),
Padding(
padding:
context.paddingLowVertical,
child: StreamBuilder<
List<
DropdownMenuItem<
District>>>(
stream: deviceUpdateBloc
.streamListDistricts,
builder: (dialogContext,
listDistricts) {
return Container(
decoration: BoxDecoration(
borderRadius:
const BorderRadius
.all(
Radius.circular(20),
),
border: Border.all(),
),
child: SearchChoices.single(
items:
listDistricts.data ??
districtsData,
hint: districtNameSnapshot
.data !=
null
? Text(
districtNameSnapshot
.data![
'name'] ??
selectedDistrict!,
)
: appLocalization(
context)
.update_device_dialog_location_district_hintText,
searchHint: appLocalization(
context)
.update_device_dialog_location_district_searchHint,
displayClearIcon: false,
onChanged: (value) {
isChangedListener();
// districtCode =
// value.code;
selectedDistrict =
value.fullName;
districtData['name'] =
value.fullName!;
districtData['code'] =
value.code;
deviceUpdateBloc
.sinkDistrictData
.add(districtData);
deviceUpdateBloc
.getAllWards(
value.code);
selectedWard = "";
wardData['name'] =
selectedWard!;
deviceUpdateBloc
.sinkWardData
.add(wardData);
},
isExpanded: true,
),
);
},
),
),
Text(
"${appLocalization(context).device_update_ward}:",
style: context
.titleMediumTextStyle),
Padding(
padding:
context.paddingLowVertical,
child: StreamBuilder<
List<DropdownMenuItem<Ward>>>(
stream: deviceUpdateBloc
.streamListWards,
builder:
(dialogContext, listWards) {
return Container(
decoration: BoxDecoration(
borderRadius:
const BorderRadius
.all(
Radius.circular(
20)),
border: Border.all()),
child: SearchChoices.single(
items: listWards.data ??
wardsData,
hint: wardNameSnapshot
.data !=
null
? Text(
wardNameSnapshot
.data![
'name'] ??
selectedWard!,
)
: appLocalization(
context)
.update_device_dialog_location_ward_hintText,
searchHint: appLocalization(
context)
.update_device_dialog_location_ward_searchHint,
displayClearIcon: false,
onChanged: (value) {
isChangedListener();
// wardCode = value.code;
selectedWard =
value.fullName;
wardData['name'] =
value.fullName!;
wardData['code'] =
value.code!;
deviceUpdateBloc
.sinkWardData
.add(wardData);
},
isExpanded: true,
),
);
},
),
),
if (isChangedSnapshot.data == true)
Center(
child: SizedBox(
width:
context.dynamicWidth(0.6),
child: TextButton(
style: ButtonStyle(
foregroundColor:
WidgetStateProperty
.all(Colors
.white),
backgroundColor:
WidgetStateProperty
.all(Colors
.blue)),
onPressed: () async {
String provinceCode =
provinceNameSnapshot
.data![
"code"] ??
"";
String districtCode =
districtNameSnapshot
.data![
"code"] ??
"";
String wardCode =
wardNameSnapshot
.data![
"code"] ??
"";
String latitude =
deviceLatitudeController
.value.text;
String longitude =
deviceLongitudeController
.value.text;
String deviceName =
deviceNameController
.value.text;
// log("ProvinceCode: $provinceCode");
// log("DistrictCode: $districtCode");
// log("WardCode: $wardCode");
// log("Latitude: $latitude");
// log("Longitude: $longitude");
// log("Device Name: $deviceName");
await deviceUpdateBloc
.updateDevice(
context,
deviceInfoSnapshot
.data!.thingId!,
deviceName,
latitude,
longitude,
provinceCode,
districtCode,
wardCode,
);
Future.delayed(
// ignore: use_build_context_synchronously
context.lowDuration,
() {
Navigator.pop(
context);
});
},
child: Text(appLocalization(
context)
.update_button_content)),
icon: const Icon(
Icons.map_outlined,
),
),
),
SizedBox(width: context.lowValue),
],
),
),
);
},
);
}
Text(
"${appLocalization(context).device_update_province}:",
style: context.titleMediumTextStyle),
Padding(
padding: context.paddingLowVertical,
child: StreamBuilder<
List<DropdownMenuItem<Province>>>(
stream: deviceUpdateBloc
.streamListProvinces,
builder:
(dialogContext, listProvinces) {
return Container(
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(
Radius.circular(20),
),
border: Border.all(),
),
child: SearchChoices.single(
items: listProvinces.data ??
provincesData,
hint: provinceNameSnapshot
.data !=
null
? Text(
provinceNameSnapshot
.data![
'name'] ??
"",
)
: appLocalization(context)
.update_device_dialog_location_province_hintText,
searchHint: appLocalization(
context)
.update_device_dialog_location_province_searchHint,
displayClearIcon: false,
onChanged: (value) {
isChangedListener();
// provinceCode =
// value.code;
selectedProvince =
value.fullName;
provinceData['name'] =
value.fullName;
provinceData['code'] =
value.code;
deviceUpdateBloc
.sinkProvinceData
.add(provinceData);
deviceUpdateBloc
.getAllDistricts(
value.code);
selectedDistrict = "";
districtData['name'] =
selectedDistrict!;
// deviceUpdateBloc.sinkDistrictName
// .add(selectedDistrict);
deviceUpdateBloc
.sinkDistrictData
.add(districtData);
selectedWard = "";
wardData['name'] =
selectedWard!;
deviceUpdateBloc.sinkWardData
.add(wardData);
},
isExpanded: true,
),
);
},
),
),
Text(
"${appLocalization(context).device_update_district}:",
style: context.titleMediumTextStyle),
Padding(
padding: context.paddingLowVertical,
child: StreamBuilder<
List<DropdownMenuItem<District>>>(
stream: deviceUpdateBloc
.streamListDistricts,
builder:
(dialogContext, listDistricts) {
return Container(
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(
Radius.circular(20),
),
border: Border.all(),
),
child: SearchChoices.single(
items: listDistricts.data ??
districtsData,
hint: districtNameSnapshot
.data !=
null
? Text(
districtNameSnapshot
.data![
'name'] ??
selectedDistrict!,
)
: appLocalization(context)
.update_device_dialog_location_district_hintText,
searchHint: appLocalization(
context)
.update_device_dialog_location_district_searchHint,
displayClearIcon: false,
onChanged: (value) {
isChangedListener();
// districtCode =
// value.code;
selectedDistrict =
value.fullName;
districtData['name'] =
value.fullName!;
districtData['code'] =
value.code;
deviceUpdateBloc
.sinkDistrictData
.add(districtData);
deviceUpdateBloc
.getAllWards(value.code);
selectedWard = "";
wardData['name'] =
selectedWard!;
deviceUpdateBloc.sinkWardData
.add(wardData);
},
isExpanded: true,
),
);
},
),
),
Text(
"${appLocalization(context).device_update_ward}:",
style: context.titleMediumTextStyle),
Padding(
padding: context.paddingLowVertical,
child: StreamBuilder<
List<DropdownMenuItem<Ward>>>(
stream:
deviceUpdateBloc.streamListWards,
builder: (dialogContext, listWards) {
return Container(
decoration: BoxDecoration(
borderRadius:
const BorderRadius.all(
Radius.circular(20)),
border: Border.all()),
child: SearchChoices.single(
items:
listWards.data ?? wardsData,
hint: wardNameSnapshot.data !=
null
? Text(
wardNameSnapshot.data![
'name'] ??
selectedWard!,
)
: appLocalization(context)
.update_device_dialog_location_ward_hintText,
searchHint: appLocalization(
context)
.update_device_dialog_location_ward_searchHint,
displayClearIcon: false,
onChanged: (value) {
isChangedListener();
// wardCode = value.code;
selectedWard = value.fullName;
wardData['name'] =
value.fullName!;
wardData['code'] =
value.code!;
deviceUpdateBloc.sinkWardData
.add(wardData);
},
isExpanded: true,
),
);
},
),
),
if (isChangedSnapshot.data == true)
Center(
child: SizedBox(
width: context.dynamicWidth(0.6),
child: TextButton(
style: ButtonStyle(
foregroundColor:
WidgetStateProperty.all(
Colors.white),
backgroundColor:
WidgetStateProperty.all(
Colors.blue),
),
onPressed: () async {
String provinceCode =
provinceNameSnapshot
.data!["code"] ??
"";
String districtCode =
districtNameSnapshot
.data!["code"] ??
"";
String wardCode =
wardNameSnapshot
.data!["code"] ??
"";
String latitude =
deviceLatitudeController
.value.text;
String longitude =
deviceLongitudeController
.value.text;
String deviceName =
deviceNameController
.value.text;
// log("ProvinceCode: $provinceCode");
// log("DistrictCode: $districtCode");
// log("WardCode: $wardCode");
// log("Latitude: $latitude");
// log("Longitude: $longitude");
// log("Device Name: $deviceName");
await deviceUpdateBloc
.updateDevice(
context,
deviceInfoSnapshot
.data!.thingId!,
deviceName,
latitude,
longitude,
provinceCode,
districtCode,
wardCode,
);
Future.delayed(
// ignore: use_build_context_synchronously
context.lowDuration,
() {
// ignore: use_build_context_synchronously
Navigator.pop(context);
},
);
},
child: Text(
appLocalization(context)
.update_button_content),
),
),
),
],
),
),
);
},
),
);
});
});
}),
);
}
},
),
);
},
);
},
);
},
),
);
}

View File

@@ -4,7 +4,7 @@ import 'dart:developer';
import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart' ;
import '../../../bloc/device_update_bloc.dart';
import '../../../product/constant/app/app_constants.dart';
import '../../../product/extention/context_extention.dart';
@@ -29,6 +29,7 @@ showMapDialog(
TextEditingController mapDialogLongitudeController = TextEditingController();
Completer<GoogleMapController> ggmapController = Completer();
final streamController = StreamController<GoogleMapController>.broadcast();
showGeneralDialog(
barrierDismissible: false,
transitionDuration: context.normalDuration,

View File

@@ -2,10 +2,10 @@ import 'dart:async';
import 'package:flutter/material.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 'delete_device_widget.dart';
import 'device_model.dart';
import '../../product/shared/shared_pie_chart.dart';
import '../../bloc/devices_manager_bloc.dart';
import '../../product/base/bloc/base_bloc.dart';
import '../../product/constant/enums/app_route_enums.dart';

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,6 @@
import 'dart:developer';
import 'package:dio/dio.dart';
import 'error_response_model.dart';
@@ -87,7 +89,7 @@ class DioErrorHandler {
// }
getMas(dynamic error) {
print("myError ${error.runtimeType}");
log("myError ${error.runtimeType}");
if (error.runtimeType != String) {
errorResponse.message =
error['message'].toString(); //?? S.of(Get.context).something_wrong;
@@ -128,7 +130,7 @@ class ErrorHandler {
// return error.toString();
errorResponse.message = "The Provided API key is invalid";
return errorResponse;
} else if (error is DioError) {
} else if (error is DioException) {
return DioErrorHandler().handleDioError(error);
}
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';
@@ -54,12 +54,10 @@ class NearBySearchSFM extends StatefulWidget {
this.textInputAction});
@override
_NearBySearchSFMState createState() =>
_NearBySearchSFMState();
_NearBySearchSFMState createState() => _NearBySearchSFMState();
}
class _NearBySearchSFMState
extends State<NearBySearchSFM> {
class _NearBySearchSFMState extends State<NearBySearchSFM> {
final subject = PublishSubject<String>();
OverlayEntry? _overlayEntry;
List<Prediction> alPredictions = [];
@@ -127,9 +125,9 @@ class _NearBySearchSFMState
String country = widget.countries![i];
if (i == 0) {
url = url + "&components=country:$country";
url = "$url&components=country:$country";
} else {
url = url + "|" + "country:" + country;
url = "$url|country:$country";
}
}
}
@@ -184,8 +182,8 @@ class _NearBySearchSFMState
}
textChanged(String text) async {
getLocation(text, widget.locationLatitude, widget.locationLongitude,
widget.radius);
getLocation(
text, widget.locationLatitude, widget.locationLongitude, widget.radius);
}
OverlayEntry? _createOverlayEntry() {
@@ -278,7 +276,9 @@ class _NearBySearchSFMState
if (this._overlayEntry != null) {
try {
this._overlayEntry?.remove();
} catch (e) {}
} catch (e) {
log("Error: $e");
}
}
}
@@ -289,7 +289,7 @@ class _NearBySearchSFMState
_showSnackBar(String errorData) {
if (widget.showError) {
final snackBar = SnackBar(
content: Text("$errorData"),
content: Text(errorData),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}

View File

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

View File

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

View File

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