warning fixing

This commit is contained in:
Bijoy Ghosh
2024-04-05 09:27:59 +06:00
parent 65e886653e
commit e0fc5e7162

View File

@@ -34,7 +34,7 @@ import '../../map_camera_flutter.dart';
/// print('Latitude: ${data.latitude}'); /// print('Latitude: ${data.latitude}');
/// print('Longitude: ${data.longitude}'); /// print('Longitude: ${data.longitude}');
/// print('Location Name: ${data.locationName}'); /// print('Location Name: ${data.locationName}');
/// print('Sublocation: ${data.subLocation}'); /// print('SubLocation: ${data.subLocation}');
/// } /// }
/// ///
/// @override /// @override
@@ -60,8 +60,7 @@ class MapCameraLocation extends StatefulWidget {
/// The [camera] parameter is required and represents the camera to be used for capturing images. /// The [camera] parameter is required and represents the camera to be used for capturing images.
/// The [onImageCaptured] parameter is an optional callback function that will be triggered when an image and location data are captured. /// The [onImageCaptured] parameter is an optional callback function that will be triggered when an image and location data are captured.
const MapCameraLocation( const MapCameraLocation(
{Key? key, required this.camera, this.onImageCaptured}) {super.key, required this.camera, this.onImageCaptured});
: super(key: key);
@override @override
State<MapCameraLocation> createState() => _MapCameraLocationState(); State<MapCameraLocation> createState() => _MapCameraLocationState();
@@ -76,7 +75,7 @@ class _MapCameraLocationState extends State<MapCameraLocation> {
/// Represents a future that resolves when the camera controller has finished initializing. /// Represents a future that resolves when the camera controller has finished initializing.
late FollowOnLocationUpdate _followOnLocationUpdate; late AlignOnUpdate _followOnLocationUpdate;
/// Enum value indicating when to follow location updates. /// Enum value indicating when to follow location updates.
@@ -118,7 +117,7 @@ class _MapCameraLocationState extends State<MapCameraLocation> {
String? subLocation; String? subLocation;
/// Sublocation of the current location as a string. /// SubLocation of the current location as a string.
/// Callback function to retrieve the image and location data. /// Callback function to retrieve the image and location data.
ImageAndLocationData getImageAndLocationData() { ImageAndLocationData getImageAndLocationData() {
@@ -141,7 +140,7 @@ class _MapCameraLocationState extends State<MapCameraLocation> {
ResolutionPreset.medium, ResolutionPreset.medium,
); );
_initializeControllerFuture = _controller.initialize(); _initializeControllerFuture = _controller.initialize();
_followOnLocationUpdate = FollowOnLocationUpdate.always; _followOnLocationUpdate = AlignOnUpdate.always;
_followCurrentLocationStreamController = StreamController<double?>(); _followCurrentLocationStreamController = StreamController<double?>();
// Get the current date and time in a formatted string // Get the current date and time in a formatted string
@@ -200,15 +199,15 @@ class _MapCameraLocationState extends State<MapCameraLocation> {
CircularProgressIndicator()) CircularProgressIndicator())
: FlutterMap( : FlutterMap(
options: MapOptions( options: MapOptions(
center: const lat.LatLng(0, 0), initialCenter: const lat.LatLng(0, 0),
zoom: 13.0, initialZoom: 13.0,
onPositionChanged: onPositionChanged:
(MapPosition position, (MapPosition position,
bool hasGesture) { bool hasGesture) {
if (hasGesture) { if (hasGesture) {
setState( setState(
() => _followOnLocationUpdate = () => _followOnLocationUpdate =
FollowOnLocationUpdate AlignOnUpdate
.never, .never,
); );
} }
@@ -223,10 +222,10 @@ class _MapCameraLocationState extends State<MapCameraLocation> {
minZoom: 12, minZoom: 12,
), ),
CurrentLocationLayer( CurrentLocationLayer(
followCurrentLocationStream: alignPositionStream:
_followCurrentLocationStreamController _followCurrentLocationStreamController
.stream, .stream,
followOnLocationUpdate: alignPositionOnUpdate:
_followOnLocationUpdate, _followOnLocationUpdate,
), ),
], ],
@@ -395,7 +394,7 @@ class _MapCameraLocationState extends State<MapCameraLocation> {
} }
/// Updates the current position by retrieving the latitude, longitude, location name, /// Updates the current position by retrieving the latitude, longitude, location name,
/// and sublocation based on the user's device location. Updates the corresponding /// and subLocation based on the user's device location. Updates the corresponding
/// state variables with the retrieved data. /// state variables with the retrieved data.
/// Throws an exception if there is an error retrieving the location information. /// Throws an exception if there is an error retrieving the location information.
Future<void> updatePosition(BuildContext context) async { Future<void> updatePosition(BuildContext context) async {
@@ -403,21 +402,21 @@ class _MapCameraLocationState extends State<MapCameraLocation> {
// Determine the current position // Determine the current position
final position = await _determinePosition(); final position = await _determinePosition();
// Retrieve the placemarks for the current position // Retrieve the placeMarks for the current position
final placemarks = final placeMarks =
await placemarkFromCoordinates(position.latitude, position.longitude); await placemarkFromCoordinates(position.latitude, position.longitude);
if (placemarks.isNotEmpty) { if (placeMarks.isNotEmpty) {
final placemark = placemarks.first; final placeMark = placeMarks.first;
// Update the state variables with the retrieved location data // Update the state variables with the retrieved location data
setState(() { setState(() {
latitudeServer = position.latitude.toString(); latitudeServer = position.latitude.toString();
longitudeServer = position.longitude.toString(); longitudeServer = position.longitude.toString();
locationName = locationName =
"${placemark.locality ?? ""}, ${placemark.administrativeArea ?? ""}, ${placemark.country ?? ""}"; "${placeMark.locality ?? ""}, ${placeMark.administrativeArea ?? ""}, ${placeMark.country ?? ""}";
subLocation = subLocation =
"${placemark.street ?? ""}, ${placemark.thoroughfare ?? ""} ${placemark.administrativeArea ?? ""}"; "${placeMark.street ?? ""}, ${placeMark.thoroughfare ?? ""} ${placeMark.administrativeArea ?? ""}";
}); });
if (kDebugMode) { if (kDebugMode) {
@@ -425,7 +424,7 @@ class _MapCameraLocationState extends State<MapCameraLocation> {
"Latitude: $latitudeServer, Longitude: $longitudeServer, Location: $locationName"); "Latitude: $latitudeServer, Longitude: $longitudeServer, Location: $locationName");
} }
} else { } else {
// Handle case when no placemark is available // Handle case when no placeMark is available
setState(() { setState(() {
latitudeServer = null; latitudeServer = null;
longitudeServer = null; longitudeServer = null;
@@ -444,7 +443,7 @@ class _MapCameraLocationState extends State<MapCameraLocation> {
} }
} }
/// Determines the current position using the Geolocator package. /// Determines the current position using the GeoLocator package.
/// Returns the current position as a [Position] object. /// Returns the current position as a [Position] object.
/// Throws an exception if there is an error determining the position or if the necessary permissions are not granted. /// Throws an exception if there is an error determining the position or if the necessary permissions are not granted.
Future<Position> _determinePosition() async { Future<Position> _determinePosition() async {