Skip to content

Instantly share code, notes, and snippets.

@Zambrella
Created September 22, 2019 14:57
Show Gist options
  • Save Zambrella/3fe830ee0db03b105bb5b2a169bfc50d to your computer and use it in GitHub Desktop.
Save Zambrella/3fe830ee0db03b105bb5b2a169bfc50d to your computer and use it in GitHub Desktop.
Body of the input page which is non functional at the moment
class InputPage extends StatefulWidget {
@override
_InputPageState createState() => _InputPageState();
}
class _InputPageState extends State<InputPage> {
// Initialise isError bool variable to false. Used to change style of TextField widget if the user enters a value which isn't allowed.
bool _isError = false;
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(vertical: 16, horizontal: 22),
// Column because the TextField widget and button widget will be displayed vertically
child: Column(
// Want the widgets in the column to be displayed in the center
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// Widget needed to accept Text input from a user
TextField(
// User will only be inputting numbers so we want to make this easier for the user
keyboardType: TextInputType.number,
// No ones MMR is more than 4 digits long
maxLength: 4,
maxLengthEnforced: true,
// How the TextField is styled
decoration: InputDecoration(
labelText: 'What\'s your MMR?',
errorText:
_isError ? 'Enter a number between 0 and 9999' : null,
border: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
)),
),
// Creating space between the TextField widget and RaisedButton widget
SizedBox(
height: 20,
),
// Putting RaisedButton widget inside a SizedBox so that I can change the size of the Raised button
SizedBox(
// Sets the width to as wide as possible. Parent widget has a margin which is why it doesn't go to the edge
width: double.infinity,
// RaisedButton widget. Currently disabled because onPressed property is null
child: RaisedButton(
onPressed: null,
child: Text('SUBMIT'),
),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment