RangeSlider Widget

 import "package:flutter/material.dart";


void main() {
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Hello",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.deepOrange,
),
home: const FlutterApp(),
);
}
}

class FlutterApp extends StatefulWidget {
const FlutterApp({super.key});

@override
State<FlutterApp> createState() {
return FlutterAppState();
}
}

class FlutterAppState extends State<FlutterApp> {
RangeValues values = const RangeValues(0, 100);

@override
Widget build(BuildContext context) {
RangeLabels labels =
RangeLabels(values.start.toString(), values.end.toString());

return Scaffold(
drawer: const Drawer(),
appBar: AppBar(
title: const Text(
"Flutter Range Slider",
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: Center(
child: RangeSlider(
values: values,
labels: labels,
divisions: 10,
min: 0,
max: 100,
activeColor: Colors.blue,
inactiveColor: Colors.blue.shade100,
onChanged: (newValue) {
values = newValue;
print("${newValue.start}, ${newValue.end}");
setState(() {});
},
),
),
);
}
}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter