- 13 library_private_types_in_public_api: These are intentional design patterns where private State classes are returned from createState() methods - 7 implementation_imports: These are from external packages (redux, flutter_map, shared_preferences) and necessary for the implementation All suppressed using ignore comments: - active_fires.dart, compass_map_plugin.dart, custom_stepper.dart, fire_alert.dart, fire_notification_list.dart, fires_app.dart, generic_map.dart, global_fires_bottom_stats.dart, home_page.dart, markdown_page.dart, slider.dart, support_page.dart, material_app_with_intro.dart - generic_map.dart, main_drawer.dart, main_prod.dart, fire_notifications_persist.dart, your_location_persist.dart, monitored_areas.dart, fetch_data_middleware.dart Result: ZERO lint issues in lib/ - clean build achieved!
71 lines
1.9 KiB
Dart
71 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'colors.dart';
|
|
import 'generated/i18n.dart';
|
|
import 'utils/widget_utils.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
|
|
// ignore: library_private_types_in_public_api
|
|
_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: compactWidgets(<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)
|
|
])
|
|
]),
|
|
);
|
|
}
|
|
}
|