b24_widgets 0.0.4
b24_widgets: ^0.0.4 copied to clipboard
Flutter Package that include existing sample widgets
example/lib/main.dart
import 'package:b24_widgets/app/languages/generated/l10n.dart';
import 'package:b24_widgets/helpers/ui_utils.dart';
import 'package:b24_widgets/widgets/buttons/ex_button.dart';
import 'package:b24_widgets/widgets/dropdown/ex_dropdown_textfield.dart';
import 'package:b24_widgets/widgets/inputs/ex_text_input.dart';
import 'package:b24_widgets/widgets/texts/text_widget.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
localizationsDelegates: const [
S.delegate, // Ensure this line is present
// other delegates
],
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a blue toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Bill24 Reusable Widgets'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final TextEditingController txtPassword = TextEditingController();
final TextEditingController _textEditingController = TextEditingController();
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Form(
key: _formKey,
child: Container(
padding: const EdgeInsets.all(10.0),
child: Column(
children: [
ExTextInput(
controller: _textEditingController,
label: 'Email',
inputType: ExInputType.email,
),
itemGap,
const ExTextInput(
label: 'Last Name',
),
itemGap,
ExDropdownTextfield(
label: S.current.x_invalid_email,
isRequired: true,
),
itemGap,
// ElevatedButton(
// onPressed: () {
// if (_formKey.currentState!.validate()) {
// // Form is valid, you can submit your data here
// // For example, you can print the values
// debugPrint('Email: ${_textEditingController.text}');
// }
// },
// child: const Text('Submit'),
// ),
ExButton(
paddingVertical: 6.5,
TextWidget(S.current.add),
variant: ButtonVariant.outline,
onTap: () async {
if (_formKey.currentState!.validate()) {
debugPrint('Email: ${_textEditingController.text}');
}
},
),
],
)
),
),
);
}
}