Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:wedding_app/models/constants/colors.dart';
- import 'package:wedding_app/models/state/guest_list/guest_widget.dart';
- class GuestPage extends GuestState {
- String name;
- TextEditingController _editingController = TextEditingController();
- // Create a global key that will uniquely identify the Form widget and allow
- // us to validate the form
- //
- // Note: This is a `GlobalKey<FormState>`, not a GlobalKey<MyCustomFormState>!
- final _formKey = GlobalKey<FormState>();
- @override
- void dispose() {
- _editingController.dispose();
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- double textboxSize = MediaQuery.of(context).size.height / 1.6;
- return Form(
- key: _formKey,
- child: Scaffold(
- body: Builder(
- builder: (context) => Container(
- height: textboxSize * 10,
- child: Container(
- padding: EdgeInsets.all(30),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: buildForm(context),
- ),
- ))))); // How do I prevent these??
- }
- List<Widget> buildForm(BuildContext context) {
- return <Widget>[
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Container(
- child: Padding(
- padding: EdgeInsets.only(bottom: 2),
- child: Text(
- "First Name",
- style: TextStyle(fontFamily: "acme", fontSize: 20),
- ))), // How do I prevent these??
- TextFormField(
- textAlign: TextAlign.left,
- maxLength: 40,
- style: TextStyle(height: 2, fontSize: 15, color: Colors.black87),
- controller: _editingController,
- validator: (value) {
- if (value.isEmpty) {
- return "Please enter a first name";
- }
- name = value;
- },
- )
- ],
- ),
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Container(
- child: Text(
- "Last Name",
- style: TextStyle(fontFamily: "acme", fontSize: 20),
- ),
- ),
- TextFormField(
- maxLength: 40,
- textAlign: TextAlign.start,
- style: TextStyle(height: 2, fontSize: 15, color: Colors.black87),
- )
- ],
- ),
- Padding(
- padding: EdgeInsets.only(top: 15.0),
- child: ButtonTheme(
- minWidth: 200,
- height: 50,
- child: new RaisedButton(
- color: ApplicationColors.black,
- textColor: ApplicationColors.ivory,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(30.0)),
- onPressed: () {
- if (_formKey.currentState.validate()) {
- _showToast(context, "valid");
- }
- },
- child: Text("Submit",
- style: new TextStyle(
- color: ApplicationColors.ivory,
- fontFamily: 'Acme',
- fontSize: 20)), // How do I prevent these??
- ))) // How do I prevent these??
- ];
- }
- void _showToast(BuildContext context, String text) {
- final scaffold = Scaffold.of(context);
- scaffold.showSnackBar(
- SnackBar(
- content: Text(text),
- action: SnackBarAction(
- label: 'UNDO', onPressed: scaffold.hideCurrentSnackBar),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment