https://github.com/bynicodevelop/flutter_inputs
https://github.com/bynicodevelop/flutter_inputs
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bynicodevelop/flutter_inputs
- Owner: bynicodevelop
- License: other
- Created: 2020-12-15T12:29:34.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-19T10:27:42.000Z (over 5 years ago)
- Last Synced: 2024-05-28T23:38:24.496Z (about 2 years ago)
- Language: Dart
- Size: 66.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# flutter_inputs
Créer des formulaires avec leur propres validateurs.
## Getting Started
```
import 'package:flutter/material.dart';
import 'package:flutter_inputs/MainButton.dart';
import 'package:flutter_inputs/forms/inputs/EmailInput.dart';
import 'package:flutter_inputs/forms/inputs/PasswordInput.dart';
import 'package:flutter_inputs/forms/inputs/TextInput.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State {
TextEditingController _emailController;
TextEditingController _usernameController;
TextEditingController _passwordController;
final GlobalKey _keyForm = GlobalKey();
@override
void initState() {
super.initState();
_emailController = TextEditingController();
_usernameController = TextEditingController();
_passwordController = TextEditingController();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
buttonTheme:
ButtonThemeData(buttonColor: Theme.of(context).primaryColor),
),
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Form(
key: _keyForm,
child: ListView(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: EmailInput(
controller: _emailController,
placeholder: 'Enter your email',
onChanged: (value) => print(value),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextInput(
controller: _usernameController,
placeholder: 'Enter your username',
onChanged: (value) => print(value),
validator: (value) =>
value.isEmpty ? 'Please enter your username' : null,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: PasswordInput(
controller: _passwordController,
placeholder: 'Enter your password',
onChanged: (value) => print(value),
validator: (value) => value.isEmpty
? 'Enter a password (min: 6 chars)'
: null,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: MainButton(
label: 'Main Button',
onPressed: () async {
if (_keyForm.currentState.validate()) {
await Future.delayed(Duration(seconds: 2));
print(_emailController.text);
print(_usernameController.text);
print(_passwordController.text);
}
},
),
)
],
)),
),
);
}
}
```