2022-11-29 13:16:44 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_input_library/flutter_input_library.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
runApp(const MyApp());
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
|
|
|
title: 'Flutter Demo',
|
|
|
|
theme: ThemeData(
|
|
|
|
primarySwatch: Colors.blue,
|
|
|
|
),
|
|
|
|
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class MyHomePage extends StatefulWidget {
|
|
|
|
const MyHomePage({super.key, required this.title});
|
|
|
|
|
|
|
|
final String title;
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<MyHomePage> createState() => _MyHomePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MyHomePageState extends State<MyHomePage> {
|
2023-11-01 11:30:31 +01:00
|
|
|
var weekDayDateFormat = DateFormat('EEEE');
|
|
|
|
var monthDateFormat = DateFormat('MMMM');
|
|
|
|
|
2022-11-29 13:16:44 +01:00
|
|
|
var formKey = GlobalKey<FormState>();
|
|
|
|
|
2023-11-01 11:30:31 +01:00
|
|
|
var weekDays = TypeUtils().createWeekDays(WeekDay.monday, WeekDay.sunday);
|
|
|
|
var dates = TypeUtils().createMonthList(Month.january, Month.december, 2023);
|
|
|
|
var years = TypeUtils().createYearList(2000, 2023);
|
2022-11-29 13:16:44 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(widget.title),
|
|
|
|
),
|
|
|
|
body: Center(
|
|
|
|
child: Form(
|
|
|
|
key: formKey,
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2022-12-20 13:46:35 +01:00
|
|
|
Container(height: 10),
|
|
|
|
const Text('FlutterFormInputSwitch'),
|
2022-11-29 13:16:44 +01:00
|
|
|
FlutterFormInputSwitch(
|
|
|
|
initialValue: true,
|
|
|
|
onChanged: (v) {
|
2022-12-20 13:46:35 +01:00
|
|
|
debugPrint('Switch changed to $v');
|
2022-11-29 13:16:44 +01:00
|
|
|
},
|
|
|
|
),
|
2022-12-20 13:46:35 +01:00
|
|
|
Container(height: 50),
|
|
|
|
const Text('FlutterFormInputDateTime'),
|
2022-11-29 13:16:44 +01:00
|
|
|
FlutterFormInputDateTime(
|
2023-03-24 09:49:03 +01:00
|
|
|
timePickerEntryMode: TimePickerEntryMode.dialOnly,
|
2023-01-17 14:56:30 +01:00
|
|
|
style: const TextStyle(color: Colors.red),
|
2023-01-05 11:15:16 +01:00
|
|
|
decoration: const InputDecoration(label: Text('test')),
|
2023-01-17 14:56:30 +01:00
|
|
|
inputType: FlutterFormDateTimeType.time,
|
|
|
|
dateFormat: DateFormat('HH:mm'),
|
2022-11-29 13:16:44 +01:00
|
|
|
onChanged: (v) {
|
2022-12-20 13:46:35 +01:00
|
|
|
debugPrint('Date changed to $v');
|
2022-11-29 13:16:44 +01:00
|
|
|
},
|
|
|
|
),
|
2022-12-20 13:46:35 +01:00
|
|
|
Container(height: 50),
|
|
|
|
const Text('FlutterFormInputNumberPicker'),
|
2022-11-29 13:16:44 +01:00
|
|
|
FlutterFormInputNumberPicker(
|
|
|
|
onChanged: (v) {
|
2022-12-20 13:46:35 +01:00
|
|
|
debugPrint('Number changed to $v');
|
2022-11-29 13:16:44 +01:00
|
|
|
},
|
|
|
|
),
|
2022-12-20 13:46:35 +01:00
|
|
|
Container(height: 50),
|
|
|
|
const Text('FlutterFormInputSlider'),
|
2022-11-29 13:16:44 +01:00
|
|
|
FlutterFormInputSlider(
|
|
|
|
onChanged: (v) {
|
2022-12-20 13:46:35 +01:00
|
|
|
debugPrint('Slider changed to $v');
|
2022-11-29 13:16:44 +01:00
|
|
|
},
|
|
|
|
),
|
2022-12-20 13:46:35 +01:00
|
|
|
Container(height: 50),
|
|
|
|
const Text('FlutterFormInputCarousel'),
|
2022-11-29 13:16:44 +01:00
|
|
|
SizedBox(
|
2022-12-20 13:46:35 +01:00
|
|
|
height: 150,
|
|
|
|
width: 150,
|
2022-11-29 13:16:44 +01:00
|
|
|
child: FlutterFormInputCarousel(
|
|
|
|
onChanged: (v) {
|
2022-12-20 13:46:35 +01:00
|
|
|
debugPrint('Carousel changed to $v');
|
2022-11-29 13:16:44 +01:00
|
|
|
},
|
|
|
|
items: [
|
|
|
|
Container(
|
|
|
|
height: 100,
|
|
|
|
width: 100,
|
|
|
|
color: Colors.red,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: 100,
|
|
|
|
width: 100,
|
|
|
|
color: Colors.green,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: 100,
|
|
|
|
width: 100,
|
|
|
|
color: Colors.blue,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2022-12-20 13:46:35 +01:00
|
|
|
Container(height: 50),
|
|
|
|
const Text('FlutterFormInputPlainText'),
|
2022-11-29 13:16:44 +01:00
|
|
|
FlutterFormInputPlainText(
|
|
|
|
onChanged: (v) {
|
2022-12-20 13:46:35 +01:00
|
|
|
debugPrint('Plain text changed to $v');
|
2022-11-29 13:16:44 +01:00
|
|
|
},
|
|
|
|
),
|
2022-12-20 13:46:35 +01:00
|
|
|
Container(height: 50),
|
|
|
|
const Text('FlutterFormInputMultiLine'),
|
2022-11-29 13:16:44 +01:00
|
|
|
SizedBox(
|
2022-12-20 13:46:35 +01:00
|
|
|
height: 200,
|
|
|
|
width: 300,
|
2022-11-29 13:16:44 +01:00
|
|
|
child: FlutterFormInputMultiLine(
|
|
|
|
onChanged: (v) {
|
2022-12-20 13:46:35 +01:00
|
|
|
debugPrint('Multi line changed to $v');
|
2022-11-29 13:16:44 +01:00
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
2022-12-20 13:46:35 +01:00
|
|
|
Container(height: 50),
|
|
|
|
const Text('FlutterFormInputPassword'),
|
2022-11-29 13:16:44 +01:00
|
|
|
FlutterFormInputPassword(
|
|
|
|
onChanged: (v) {
|
2022-12-20 13:46:35 +01:00
|
|
|
debugPrint('Password changed to $v');
|
2022-11-29 13:16:44 +01:00
|
|
|
},
|
|
|
|
),
|
2022-12-20 13:46:35 +01:00
|
|
|
Container(height: 50),
|
2023-11-01 11:30:31 +01:00
|
|
|
const Text('FlutterFormInputScrollPicker: Weekdays'),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
FlutterFormInputScrollPicker(
|
|
|
|
values: weekDays,
|
|
|
|
onChanged: (value) {},
|
|
|
|
childToString: (s) =>
|
|
|
|
s != null ? weekDayDateFormat.format(s) : '',
|
|
|
|
decoration: ScrollPickerDecoration(),
|
|
|
|
),
|
|
|
|
const Text('FlutterFormInputScrollPicker: Months'),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
FlutterFormInputScrollPicker(
|
|
|
|
values: dates,
|
|
|
|
onChanged: (value) {},
|
|
|
|
childToString: (s) =>
|
|
|
|
s != null ? monthDateFormat.format(s) : '',
|
|
|
|
decoration: ScrollPickerDecoration(),
|
|
|
|
),
|
|
|
|
const Padding(
|
|
|
|
padding: EdgeInsets.all(8.0),
|
|
|
|
child: Divider(),
|
|
|
|
),
|
|
|
|
const Text('FlutterFormInputScrollPicker: Years'),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
FlutterFormInputScrollPicker(
|
|
|
|
values: years,
|
|
|
|
onChanged: (value) {},
|
|
|
|
childToString: (s) => s?.year.toString() ?? '',
|
|
|
|
decoration: ScrollPickerDecoration(),
|
|
|
|
),
|
2022-11-29 13:16:44 +01:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|