mirror of
https://github.com/Iconica-Development/flutter_address_form.git
synced 2025-05-19 10:43:45 +02:00
Basic layout
This commit is contained in:
parent
267ad89a94
commit
807a9b80a4
2 changed files with 68 additions and 5 deletions
|
@ -1,7 +1,3 @@
|
||||||
library flutter_address_form;
|
library flutter_address_form;
|
||||||
|
|
||||||
/// A Calculator.
|
export 'src/address_form.dart';
|
||||||
class Calculator {
|
|
||||||
/// Returns [value] plus 1.
|
|
||||||
int addOne(int value) => value + 1;
|
|
||||||
}
|
|
||||||
|
|
67
lib/src/address_form.dart
Normal file
67
lib/src/address_form.dart
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
class AddressForm extends StatefulWidget {
|
||||||
|
AddressForm({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<AddressForm> createState() => _AddressFormState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AddressFormState extends State<AddressForm> {
|
||||||
|
final TextEditingController _zipcodeController = TextEditingController();
|
||||||
|
final RegExp _zipcodeRegExp = RegExp(r'^[1-9][0-9]{3}\s?[a-zA-Z]{2}$');
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Form(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
_createField(
|
||||||
|
label: 'Postcode',
|
||||||
|
controller: _zipcodeController,
|
||||||
|
),
|
||||||
|
Flexible(
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
_createField(
|
||||||
|
label: 'Huisnummer',
|
||||||
|
controller: TextEditingController(),
|
||||||
|
),
|
||||||
|
_createField(
|
||||||
|
label: 'Toevoeging',
|
||||||
|
controller: TextEditingController(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
_createField(
|
||||||
|
label: 'Straatnaam',
|
||||||
|
controller: TextEditingController(),
|
||||||
|
),
|
||||||
|
_createField(
|
||||||
|
label: 'Woonplaats',
|
||||||
|
controller: TextEditingController(),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _createField(
|
||||||
|
{required String label, required TextEditingController controller}) {
|
||||||
|
return Flexible(
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.all(10),
|
||||||
|
child: TextFormField(
|
||||||
|
validator: (value) {
|
||||||
|
print(_zipcodeRegExp.hasMatch(value!));
|
||||||
|
},
|
||||||
|
decoration: InputDecoration(
|
||||||
|
label: Text(label),
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue