flutter_homebase 1.5.0 flutter_homebase: ^1.5.0 copied to clipboard
Collection of Widgets and helpful Methods that every flutter developer needs.
import 'package:flutter/material.dart';
import 'package:flutter_homebase/flutter_homebase.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Homebase Package Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const HomeScreen()
);
}
}
class HomeScreen extends StatefulWidget {
const HomeScreen({super.key});
@override
State<HomeScreen> createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
final _formKey = GlobalKey<FormState>();
bool checkBoxValue = true ;
int numberValue = 0 ;
String chooseValue = "ITEM 1" ;
String passwordValue = "Password" ;
String textValue = "Text" ;
List<String> multiChooseValue = ["ITEM 1","ITEM 2"] ;
List<String> items = ["ITEM 1","ITEM 2","ITEM 3","ITEM 4"] ;
List<double> minMaxValue = [-30,60];
TimeOfDay timeValue = const TimeOfDay(hour: 12, minute: 30);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Flutter Homebase Package Example",style: TextStyle(fontSize: 15),),
centerTitle: true,
),
body: MCard(
widget: Form(
key: _formKey,
child: Column(
children: [
MTimeFormField(label: "MTimeFormField", onChange: (value) {
setState(() {
timeValue = value ;
});
},value: timeValue),
MTextFormField(label: "MTextFormField", initValue: textValue, onSaved: (value) {
setState(() {
textValue = value ;
});
},),
MRangeSelectorField(label: "MRangeSelectorField", onChange: (min, max) {
setState(() {
minMaxValue[0] = min;
minMaxValue[1] = max;
});
},max: 100,min: -100,start: minMaxValue[0],end: minMaxValue[1]),
MPasswordTextFormField(label: "MPasswordTextFormField", initValue: passwordValue, onSaved: (value) {
setState(() {
passwordValue = value ;
});
},),
MNumberFormField(label: "MNumberFormField", onChange: (value) {
setState(() {
numberValue = value ;
});
},value: numberValue,min: -100,max: 100,),
MMultiChooseFormField(label: "MMultiChooseFormField", items: items,values: multiChooseValue,),
MChooseFormField(label: "MChooseFormField", items: items ,value: chooseValue,),
MCheckBoxFormField(label: "MCheckBoxFormField", onChange: (value) {
setState(() {
checkBoxValue = value ;
});
},initValue: checkBoxValue,),
MButton(onTap: () {
if (_formKey.currentState!.validate()) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Processing Data')),
);
}
}, title: "Submit", icon: Icons.add)
],
)),
),
);
}
}