import 'package:covas_mobile/classes/MyDrawer.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'dart:convert'; import 'dart:io'; import '../classes/MyDrawer.dart'; import '../classes/alert.dart'; import '../classes/eventAdded.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: EditSettings(), ); } } class EditSettings extends StatefulWidget { const EditSettings({super.key}); @override _EditProfileState createState() => _EditProfileState(); } class _EditProfileState extends State with ShowAlertDialog, ShowEventDialog { TextEditingController inputUserName = TextEditingController(); int? kilometer; Future getParameter() async { SharedPreferences prefs = await SharedPreferences.getInstance(); setState(() { var kilometer = prefs.getDouble("kilometer")?.toInt() ?? null; }); } Future setParameter() async { SharedPreferences prefs = await SharedPreferences.getInstance(); if (kilometer != null) { prefs.setDouble("kilometer", kilometer?.toDouble() ?? 50); showAlertDialog(context, "Update", "Mise à jour des paramètres"); } } @override void initState() { super.initState(); getParameter(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, appBar: AppBar( title: Text("Settings"), backgroundColor: Colors.blue, foregroundColor: Colors.white, ), drawer: MyDrawer(), body: Form( child: SingleChildScrollView( child: Column( children: [ Padding( padding: const EdgeInsets.only( left: 15.0, right: 15.0, top: 15.0, bottom: 0.0, ), child: DropdownButtonFormField( decoration: InputDecoration( border: OutlineInputBorder(), labelText: 'Define kilometer', ), value: kilometer, // Set the initial selected value here, or leave as `null` if unselected. items: [ DropdownMenuItem( value: 5, child: Text('5km'), ), DropdownMenuItem( value: 25, child: Text('25km'), ), DropdownMenuItem( value: 50, child: Text('50km'), ), DropdownMenuItem( value: 75, child: Text('75km'), ), DropdownMenuItem( value: 100, child: Text('100km'), ), ], onChanged: (int? newValue) { // Handle selection kilometer = newValue; }, ), ), SizedBox( height: 30, ), Container( height: 50, width: 250, decoration: BoxDecoration( color: Colors.blue, borderRadius: BorderRadius.circular(20)), child: TextButton( onPressed: () {}, child: Text( 'Mettre à jour les paramètres', style: TextStyle(color: Colors.white, fontSize: 25), ), ), ) ], ), ), )); } }