UI
Code
import 'package:flutter/material.dart';
import 'package:ui/controllers/home_controller.dart';
import 'package:get/get.dart';
class HomePage extends StatefulWidget {
@override
_FeedbackFormScreenState createState() => _FeedbackFormScreenState();
}
class _FeedbackFormScreenState extends State {
final TextEditingController _messageController = TextEditingController();
final TextEditingController _emailController = TextEditingController();
final TextEditingController _firstNameController = TextEditingController();
final TextEditingController _lastNameController = TextEditingController();
final double _minValue = 8.0;
bool isLoading = false;
bool hasError = false;
String message = "";
String _feedbackType = 'COMMENT';
final GlobalKey _formKey = GlobalKey();
final TextStyle _errorStyle = TextStyle(
color: Colors.red,
fontSize: 16.6,
);
@override
void didChangeDependencies() {
super.didChangeDependencies();
}
Future _onBackTap() async {
Navigator.of(context).pop();
return true;
}
Widget _buildFirstName() {
return TextFormField(
controller: _firstNameController,
//validator: usernameValidator,
keyboardType: TextInputType.text,
decoration: InputDecoration(
errorStyle: _errorStyle,
border: OutlineInputBorder(),
contentPadding:
EdgeInsets.symmetric(vertical: _minValue, horizontal: _minValue),
labelText: 'First Name',
hintText: 'First Name',
labelStyle: TextStyle(fontSize: 16.0, color: Colors.black87)),
);
}
Widget _buildLastName() {
return TextFormField(
controller: _lastNameController,
//validator: usernameValidator,
keyboardType: TextInputType.text,
decoration: InputDecoration(
errorStyle: _errorStyle,
border: OutlineInputBorder(),
contentPadding:
EdgeInsets.symmetric(vertical: _minValue, horizontal: _minValue),
hintText: 'Last Name',
labelText: 'Last Name',
labelStyle: TextStyle(fontSize: 16.0, color: Colors.black87)),
);
}
Widget _buildEmail() {
return TextFormField(
controller: _emailController,
keyboardType: TextInputType.text,
//validator: validateEmail,
onChanged: (String value) {},
readOnly: true,
decoration: InputDecoration(
errorStyle: _errorStyle,
border: OutlineInputBorder(),
contentPadding:
EdgeInsets.symmetric(vertical: _minValue, horizontal: _minValue),
labelText: 'Email',
labelStyle: TextStyle(fontSize: 16.0, color: Colors.black87)),
);
}
Widget _buildDescription() {
return TextFormField(
controller: _messageController,
keyboardType: TextInputType.text,
maxLines: 2,
decoration: InputDecoration(
errorStyle: _errorStyle,
labelText: 'Description',
border: OutlineInputBorder(),
contentPadding:
EdgeInsets.symmetric(vertical: _minValue, horizontal: _minValue),
labelStyle: TextStyle(fontSize: 16.0, color: Colors.black87)),
);
}
Widget _buildFeedbackType() {
return Row(
children: [
Radio(
value: 'COMMENT',
groupValue: _feedbackType,
onChanged: (v) {
setState(() {
//_feedbackType = v;
});
}),
Text('Comments'),
SizedBox(
width: _minValue,
),
Radio(
value: 'BUG',
groupValue: _feedbackType,
onChanged: (v) {
setState(() {
//_feedbackType = v;
});
}),
Text('Bug Reports'),
SizedBox(
width: _minValue,
),
Radio(
value: 'QUESTION',
groupValue: _feedbackType,
onChanged: (v) {
setState(() {
//_feedbackType = v;
});
}),
Text('Questiions')
],
);
}
@override
Widget build(BuildContext context) {
return GetBuilder(
builder: (controller) => Scaffold(
appBar: AppBar(
title: const Text('Home'),
),
body: ListView(
scrollDirection: Axis.vertical,
children: [
Padding(
padding: EdgeInsets.symmetric(
horizontal: _minValue * 2, vertical: _minValue * 3),
child: Text(
"We would love to hear your thoughts, concerns and problem with anything, so we can improve.",
style: Theme.of(context).textTheme.subtitle1,
),
),
SizedBox(
height: 15.0,
),
Container(
padding: EdgeInsets.all(_minValue * 2),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Feedback Type"),
_buildFeedbackType(),
SizedBox(
height: _minValue * 3,
),
_buildFirstName(),
SizedBox(
height: _minValue * 3,
),
_buildLastName(),
SizedBox(
height: _minValue * 3,
),
_buildEmail(),
SizedBox(
height: _minValue * 3,
),
_buildDescription(),
SizedBox(
height: _minValue * 3,
),
SizedBox(
height: _minValue * 4,
),
],
)),
),
],
),
),
);
}
}