- Fix deprecated @ignore in json_serializable models (appState, yourLocation) - Fix empty catch blocks in compassMapPlugin, globalFiresBottomStats, locationUtils - Fix no_logic_in_create_state in firesApp, markdownPage, slider - Fix use_build_context_synchronously in fireAlert - Fix only_throw_errors in firesApi (8 instances) - Exclude generated .g.dart files from analysis - Update deprecated nullable: false to @JsonSerializable() Build: APK generated successfully, 0 errors, 0 warnings
70 lines
1.9 KiB
Dart
70 lines
1.9 KiB
Dart
import 'package:comunes_flutter/comunes_flutter.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'colors.dart';
|
|
import 'generated/i18n.dart';
|
|
|
|
typedef SlideCallback = void Function(int distance);
|
|
|
|
class FireDistanceSlider extends StatefulWidget {
|
|
const FireDistanceSlider(
|
|
{super.key, required this.initialValue, required this.onSlide});
|
|
final int initialValue;
|
|
final SlideCallback onSlide;
|
|
|
|
@override
|
|
_FireDistanceSliderState createState() => _FireDistanceSliderState();
|
|
}
|
|
|
|
class _FireDistanceSliderState extends State<FireDistanceSlider> {
|
|
_FireDistanceSliderState();
|
|
late int _sliderValue;
|
|
late final SlideCallback onSlide;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_sliderValue = widget.initialValue;
|
|
onSlide = widget.onSlide;
|
|
}
|
|
|
|
Widget sizeText(int sliderValue) =>
|
|
Text(S.of(context).subscribeToValueAroundThisArea(sliderValue.toString()),
|
|
style: const TextStyle(color: Colors.black87));
|
|
|
|
Widget warningText(int sliderValue) => _sliderValue >= 50
|
|
? Text(S.of(context).warningThisIsAVeryLargeArea,
|
|
style: const TextStyle(color: fires900))
|
|
: const Text('');
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final Slider slider = Slider(
|
|
value: _sliderValue + 0.0,
|
|
activeColor: fires900,
|
|
inactiveColor: Colors.black45,
|
|
min: 1.0,
|
|
max: 100.0,
|
|
divisions: 99,
|
|
label: '$_sliderValue',
|
|
onChanged: (double value) {
|
|
_sliderValue = value.round();
|
|
onSlide(_sliderValue);
|
|
setState(() {});
|
|
},
|
|
);
|
|
return Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: listWithoutNulls(<Widget>[
|
|
const SizedBox(height: 50.0),
|
|
Row(children: <Widget>[slider]),
|
|
// new SizedBox(height: 5.0),
|
|
Column(children: <Widget>[
|
|
sizeText(_sliderValue),
|
|
const SizedBox(height: 5.0),
|
|
warningText(_sliderValue)
|
|
])
|
|
]),
|
|
);
|
|
}
|
|
}
|