45 lines
1.1 KiB
Dart
45 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:wetter/services/user_preferences.dart';
|
|
|
|
class SettingsForm extends StatefulWidget {
|
|
const SettingsForm({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
SettingsFormState createState() => SettingsFormState();
|
|
}
|
|
|
|
class SettingsFormState extends State<SettingsForm> {
|
|
int _daysToLoad = 7;
|
|
final _formKey = GlobalKey<FormState>();
|
|
|
|
@override
|
|
void initState() {
|
|
_daysToLoad = UserPreferences.preferences!.getInt("daysToLoad") ?? 7;
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Form(
|
|
key: _formKey,
|
|
child: Column(
|
|
children: [
|
|
Slider(
|
|
value: _daysToLoad.toDouble(),
|
|
min: 1.0,
|
|
max: 14.0,
|
|
divisions: 13,
|
|
label: _daysToLoad.round().toString(),
|
|
onChanged: (double value) {
|
|
setState(() {
|
|
_daysToLoad = value.round();
|
|
UserPreferences.preferences!
|
|
.setInt("daysToLoad", _daysToLoad);
|
|
});
|
|
},
|
|
)
|
|
],
|
|
));
|
|
}
|
|
}
|