numeric_selector 0.0.3
numeric_selector: ^0.0.3 copied to clipboard
A customizable numeric selector widget for Flutter that supports both vertical and horizontal scrolling.
import 'package:flutter/material.dart';
import 'package:numeric_selector/numeric_selector.dart';
/// The entry point of the application.
void main() {
runApp(const MyApp());
}
/// The root widget of the application.
class MyApp extends StatefulWidget {
/// Creates an instance of [MyApp].
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
/// Builds the main application widget.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const HomePage(),
);
}
}
/// The home page of the application.
class HomePage extends StatefulWidget {
/// Creates an instance of [HomePage].
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
/// Builds the UI for the home page.
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Number picker'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
'Please select your age:',
style: Theme.of(context).textTheme.titleLarge,
),
const SizedBox(height: 20),
HorizontalNumericSelector(
minValue: 0,
maxValue: 100,
step: 1,
initialValue: 50,
onValueChanged: (value) {
print("Selected Value: $value");
},
viewPort: 0.2,
label: 'years',
),
ElevatedButton(
style: ButtonStyle(
minimumSize: WidgetStatePropertyAll(
Size(MediaQuery.of(context).size.width * 0.9, 50),
),
backgroundColor: MaterialStateProperty.all<Color>(
Theme.of(context).colorScheme.primary,
),
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
),
),
onPressed: () {},
child: const Text(
'Submit',
style: TextStyle(color: Colors.white),
),
),
],
),
);
}
}