set kilometer in double
This commit is contained in:
parent
18d5c83181
commit
54c95a230b
@ -3,6 +3,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:io';
|
||||
import '../pages/EditProfile.dart';
|
||||
import '../pages/EditSettings.dart';
|
||||
import '../pages/ListItemMenu.dart';
|
||||
import 'alert.dart';
|
||||
|
||||
@ -105,7 +106,10 @@ class MyDrawer extends StatelessWidget with ShowAlertDialog {
|
||||
leading: Icon(Icons.settings),
|
||||
title: Text('Settings'),
|
||||
onTap: () {
|
||||
Navigator.pop(context); // Close the drawer
|
||||
Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => EditSettings())); // Close the drawer
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
|
@ -38,9 +38,16 @@ class _EditProfileState extends State<EditSettings>
|
||||
|
||||
Future<void> getParameter() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
var kilometer = prefs.getDouble("kilometer")?.toInt() ?? null;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> setParameter() async {
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
if (kilometer != null) {
|
||||
var kilometer = prefs.getInt("kilometer") ?? null;
|
||||
prefs.setDouble("kilometer", kilometer?.toDouble() ?? 50);
|
||||
showAlertDialog(context, "Update", "Mise à jour des paramètres");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,9 +93,11 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
print('No last known position available.');
|
||||
}
|
||||
}
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
if (position != null) {
|
||||
// Calculate the boundaries
|
||||
double radiusInKm = 50;
|
||||
double radiusInKm = prefs.getDouble("kilometer") ?? 50;
|
||||
double latDistance = radiusInKm / 111.0;
|
||||
double lonDistance =
|
||||
radiusInKm / (111.0 * cos(position.latitude * pi / 180));
|
||||
@ -109,7 +111,7 @@ class _MyHomePageState extends State<ListItemMenu> {
|
||||
"?min_lat=$minLat&max_lat=$maxLat"
|
||||
"&min_lon=$minLon&max_lon=$maxLon¤t_datetime=${currentDatetime.toString()}");
|
||||
}
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
var accessToken = prefs.getString("access_token") ?? "";
|
||||
|
||||
if (accessToken.isNotEmpty) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user