blob: 31301e3aa313b90c16202e4b3ab9cc452b59e309 [file] [log] [blame]
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
/// Flutter code sample for [RangeSlider].
void main() => runApp(const RangeSliderExampleApp());
class RangeSliderExampleApp extends StatelessWidget {
const RangeSliderExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('RangeSlider Sample')),
body: const RangeSliderExample(),
),
);
}
}
class RangeSliderExample extends StatefulWidget {
const RangeSliderExample({super.key});
@override
State<RangeSliderExample> createState() => _RangeSliderExampleState();
}
class _RangeSliderExampleState extends State<RangeSliderExample> {
RangeValues _currentRangeValues = const RangeValues(40, 80);
@override
Widget build(BuildContext context) {
return RangeSlider(
values: _currentRangeValues,
max: 100,
divisions: 5,
labels: RangeLabels(
_currentRangeValues.start.round().toString(),
_currentRangeValues.end.round().toString(),
),
onChanged: (RangeValues values) {
setState(() {
_currentRangeValues = values;
});
},
);
}
}