Flutter : credit card textfield style all details in single texfield - flutter

please i looking to do this particular kind of texfield for credit card with flutter. In a single texfield there have all number, exp date and cvv in the same line of texfield. Thank you for help.
Textfield basic code example :
import 'package:flutter/material.dart';
class MyCardField extends StatelessWidget {
final TextEditingController controller;
final String hintText;
const MyCardField({Key key, this.controller, this.hintText}) : super(key: key);
#override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(bottom: 16),
child: TextField(
controller: controller,
decoration: InputDecoration(
hintText: hintText,
hintStyle: TextStyle(
color: Colors.grey[400],
fontSize: 16,
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.blue, width: 2),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.grey[300], width: 2),
),
),
),
);
}
}

I am not aware of a solution that lets you have multiple TextFields in one TextField. What you can do though, is make it look like you have.
In the code below I have made a Container with decoration making it look like a TextField. The Container takes a Form as a child and the Form takes a Row as a child. Inside the Row I put the TextFields as children.
Make sure you don't use fixed whidts, but rather calculate the devices width using MediaQuery.of(context).size.width.
import 'package:flutter/material.dart';
class Test extends StatelessWidget {
final GlobalKey _formKey = GlobalKey();
final TextEditingController cardNumberController;
final TextEditingController expireDateController;
final TextEditingController cvcController;
final String hintText;
Test({
Key key,
this.cardNumberController,
this.hintText,
this.expireDateController,
this.cvcController,
}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Column(
children: [
Container(
margin: EdgeInsets.all(4),
height: 50,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
border: Border.all(color: Colors.black38),
),
child: Form(
key: _formKey,
child: Row(
children: [
SizedBox(
width: 190,
child: TextField(
controller: cardNumberController,
decoration: InputDecoration(
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
prefixIcon:
Icon(Icons.credit_card, color: Colors.black54),
labelText: 'Card number',
labelStyle: TextStyle(
color: Colors.black54,
fontSize: 12,
),
),
),
),
Expanded(
child: TextField(
controller: expireDateController,
decoration: InputDecoration(
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
labelText: 'MM/YY',
labelStyle: TextStyle(
color: Colors.black54,
fontSize: 12,
),
),
),
),
SizedBox(
width: 90,
child: TextField(
controller: cvcController,
decoration: InputDecoration(
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
labelText: 'CVC',
labelStyle: TextStyle(
color: Colors.black54,
fontSize: 12,
),
),
),
),
],
),
),
),
TextButton(
onPressed: () {},
child: Text(
'Pay',
style: TextStyle(
color: Colors.blueGrey,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
],
),
);
}
}

Related

How can I solve this TextField Underline issue?

I have face a issue in flutter textfield , When I am trying to use underline property in my code - show some field good some issued.
How can I solve this issue, help me someone
Here is the issue :
This is my reuseable code :
import 'package:flutter/material.dart';
import '../../configs/appColors.dart';
class LoginSignUpFormField extends StatelessWidget {
const LoginSignUpFormField({
Key? key,
required this.labelText,
required this.icons,
this.controller,
}) : super(key: key);
final String? labelText;
final IconData icons;
final TextEditingController? controller;
#override
Widget build(BuildContext context) {
return TextField(
controller: controller,
autocorrect: true,
decoration: InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.red),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.green),
),
// enabledBorder: UnderlineInputBorder(
// borderSide: BorderSide(color: black45),
// ),
// focusedBorder: UnderlineInputBorder(
// borderSide: BorderSide(color: black45),
// ),
// border: UnderlineInputBorder(
// borderSide: BorderSide(color: black45),
// ),
hintText: labelText,
hintStyle: TextStyle(
color: black45,
fontSize: 15,
),
prefixIcon: Icon(
icons,
color: black45,
),
),
);
}
}
This is SignUp screen Code :
import 'package:duaredoctor_app/src/configs/appColors.dart';
import 'package:duaredoctor_app/src/configs/appUtils.dart';
import 'package:duaredoctor_app/src/pages/loginPage.dart';
import 'package:duaredoctor_app/src/widgets/formField/loginSignUpForm.dart';
import 'package:duaredoctor_app/src/widgets/kText.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class RegisterPage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: ListView(
// physics: NeverScrollableScrollPhysics(),
children: [
FittedBox(
child: Container(
height: Get.height,
width: Get.width,
child: Stack(
clipBehavior: Clip.none,
children: [
Container(
alignment: Alignment.center,
height: 150,
width: Get.width,
color: green50,
child: KText(
text: 'REGISTER',
color: white,
fontSize: 30,
fontWeight: FontWeight.bold,
),
),
Positioned(
top: 130,
child: Container(
height: Get.height,
width: Get.width,
decoration: BoxDecoration(
color: white,
borderRadius: BorderRadius.circular(20),
),
child: Padding(
padding: paddingH10V10,
child: Column(
children: [
sizeH40,
LoginSignUpFormField(
labelText: 'Full name',
icons: Icons.person_outlined,
),
sizeH20,
LoginSignUpFormField(
labelText: 'Email',
icons: Icons.email_outlined,
),
sizeH20,
LoginSignUpFormField(
labelText: 'Phone',
icons: Icons.call_outlined,
),
sizeH20,
LoginSignUpFormField(
labelText: 'Password',
icons: Icons.lock_outline,
),
sizeH20,
LoginSignUpFormField(
labelText: 'Password',
icons: Icons.lock_outline,
),
sizeH30,
Container(
height: 40,
width: Get.width,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: greenDark,
),
child: Center(
child: KText(
text: 'Login',
fontSize: 17,
color: white,
),
),
),
sizeH30,
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
KText(
text: 'Already have an account?',
fontSize: 16,
color: black54,
),
InkWell(
onTap: () => Get.to(LoginPage()),
child: Padding(
padding: paddingH10,
child: KText(
text: 'Login',
fontWeight: FontWeight.bold,
fontSize: 17,
color:
Color.fromARGB(255, 75, 174, 255),
),
),
),
],
),
],
),
),
),
),
],
),
),
)
],
),
),
);
}
}
this is an example how to do it
TextField(
................
.....................
border: InputBorder.none,
)
make all border to InputBorder.none, that is (focusedErrorBorder,focusedBorder,enabledBorder,errorBorder,etc...)

Flutter: How to underline in textformfield

I'm trying to make it such that the user can enter his pin, and the pin is supposed to be 4 digits long. Now, the 4 digits that he can enter should be underscored in the text form field (even before he enters the pin), somewhat like ____.
So something like this:
Basically just a normal input field that has the 4 underscores. Is there anyway I can do this in textformfield?
Thanks in advance!
I have tried this on Android Kotlin by using TextWatcher, and I think this could be done by this link below:
Here's a reference!
Try This : https://api.flutter.dev/flutter/material/UnderlineInputBorder-class.html
Full Code :
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key}) : super(key: key);
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('TextField Input Decoration Demo'),
),
body: new SafeArea(
top: true,
bottom: true,
child: Column(
children: [
Padding(
padding: EdgeInsets.all(20),
child: Row(
children: [
Container(
width: 40,
child: TextFormField(
style: TextStyle(fontSize: 50),
textInputAction: TextInputAction.next,
decoration: const InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 10.0,
)),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 10.0,
),
),
),
)),
SizedBox(width: 5),
Container(
width: 40,
child: TextFormField(
style: TextStyle(fontSize: 50),
textInputAction: TextInputAction.next,
decoration: const InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 10.0,
)),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 10.0,
),
),
),
)),
SizedBox(width: 5),
Container(
width: 40,
child: TextFormField(
style: TextStyle(fontSize: 50),
textInputAction: TextInputAction.next,
decoration: const InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 10.0,
)),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 10.0,
),
),
),
)),
SizedBox(width: 5),
Container(
width: 40,
child: TextFormField(
style: TextStyle(fontSize: 50),
textInputAction: TextInputAction.next,
decoration: const InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 10.0,
)),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.black,
width: 10.0,
),
),
),
)),
],
)),
new Divider(
color: Colors.black,
),
],
)));
}
}

Flutter : How to center an icon next to hint text inside an input decoration?

Example of desired effect
I have a TextField with an InputDecoration where I set a hintText and a prefixIcon, however the prefixIcon property that I am using will always pull the Icon all the way to the left.
TextField(
textAlign: TextAlign.center,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(0, 30, 0, 30),
prefixIcon: Icon(Icons.search),
hintText: 'Search',
fillColor: Color(0xffF1F4FB),
filled: true,
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(25),
borderSide: BorderSide(
color: Color(0xffF1F4FB),
),
),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(25),
borderSide: BorderSide(
color: Color(0xffF1F4FB),
),
),
),
),
I'm trying to change this to have the search icon and the hint text initially centered next to each other. How can I achieve this effect?
Here is a solution using IntrinsicWidth.
With this solution, the search icon will be next to the hinttext and then it will stay next to the text input from the User.
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
home: HomePage(),
),
);
}
class HomePage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Container(
height: 48.0,
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 0.0),
margin: EdgeInsets.all(8.0),
decoration: BoxDecoration(
color: Colors.amber.shade300,
border: Border.all(
color: Colors.brown,
width: 3.0,
),
borderRadius: BorderRadius.circular(25),
),
child: Center(
child: IntrinsicWidth(
child: TextField(
textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
prefixIcon: Icon(Icons.search),
hintText: 'Search',
border: InputBorder.none,
),
),
),
),
),
),
);
}
}
setting prefixIcon as a Row with MainAxisAlignment.center could do the trick. but it covers the whole textField, so we need to replace it with a normal icon when the textField is in focus.
You can detect focus using a FocusNode. To learn more read Focus and text fields
Code:
class MyTextField extends StatefulWidget {
const MyTextField({Key key}) : super(key: key);
#override
_MyTextFieldState createState() => _MyTextFieldState();
}
class _MyTextFieldState extends State<MyTextField> {
TextEditingController _controller = TextEditingController();
FocusNode _focusNode = FocusNode();
#override
void initState() {
// rebuild the textfield on focus changes
_focusNode.addListener(() {
setState(() {});
});
super.initState();
}
#override
void dispose() {
_controller.dispose();
_focusNode.dispose();
super.dispose();
}
#override
Widget build(BuildContext context) {
return TextField(
controller: _controller,
focusNode: _focusNode,
textAlign: TextAlign.center,
decoration: InputDecoration(
contentPadding: EdgeInsets.fromLTRB(0, 30, 0, 30),
prefixIcon: !_focusNode.hasFocus && _controller.text.isEmpty
? Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.search),
Text('Search'),
],
)
: Icon(Icons.search),
// hintText: 'Search',
fillColor: Color(0xffF1F4FB),
filled: true,
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(25),
borderSide: BorderSide(
color: Color(0xffF1F4FB),
),
),
disabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(25),
borderSide: BorderSide(
color: Color(0xffF1F4FB),
),
),
),
);
}
}
I use prefixIconConstraints to do that. Just add that to your TextFormField's decoration with your prefixIcon like this:
prefixIconConstraints: const BoxConstraints(),
prefixIcon: Container(
margin: EdgeInsets.symmetric(horizontal: 12),
child: const Text('Rp'),
),
you should also want to make your field look bigger by adding some padding to TextFormField's decoration:
contentPadding: EdgeInsets.all(8),

How to add a toggle for hiding and viewing password in Flutter?

I have been trying to develop an app and for its sign up, I am not sure how and where a toggle to hide/view the password can be added. Is it under obscuretext? If so, how do I add a condition for it to my code? (Used a form to create for entering sign up details.)
Code of the form where the Custom Text Field was implemented:
_signUpForm() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 25, vertical: 30),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(5)),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
CustomRoundedTextField(
label: 'Email',
onChange: (val) {
email = val;
},
),
CustomRoundedTextField(
label: 'Password',
isPassword: true,
onChange: (val) {
password = val;
},
),
SizedBox(height: 40),
CustomBlueRoundedButton(
child: Text(
'Register Account',
style: TextStyle(color: Colors.white),
),
onPressed: _createAccount,
),
SizedBox(height: 15,),
Container(
child: Center(
child: Text("Already have an account?"),
),
),
SizedBox(height: 5),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
InkWell(
onTap: openLoginPage,
child: Text("Login", style: TextStyle(
color: Color(0xff1A3C90),
fontWeight: FontWeight.w700
),),
)
],
)
],
),
);
}
Custom Text Field Class Code:
class CustomRoundedTextField extends StatelessWidget {
final label;
final onChange;
final isPassword;
final bottomPadding;
final textCapitalization;
final inputType;
final controller;
final iconData;
CustomRoundedTextField(
{
this.iconData,
this.controller,
this.inputType = TextInputType.text,
this.label,
this.onChange,
this.isPassword = false,
this.bottomPadding = 16,
this.textCapitalization = TextCapitalization.none});
#override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 16),
child: TextField(
controller: controller,
keyboardType: inputType,
textCapitalization: textCapitalization,
obscureText: isPassword,
style:
TextStyle(fontSize: 15, color: Colors.black),
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
color: Colors.black54,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
color: Colors.black,
),
),
labelText: label,
labelStyle: TextStyle(
fontSize: 15,
color: Colors.black,
fontWeight: FontWeight.w600,
),
),
onChanged: onChange,
),
);
}
}
Make your CustomRoundedTextField as StatefulWidget and add suffixIcon to TextField's InputDecoration. Below your code:
class CustomRoundedTextField extends StatefulWidget {
final label;
final onChange;
final isPassword;
final bottomPadding;
final textCapitalization;
final inputType;
final controller;
final iconData;
CustomRoundedTextField(
{
this.iconData,
this.controller,
this.inputType = TextInputType.text,
this.label,
this.onChange,
this.isPassword = false,
this.bottomPadding = 16,
this.textCapitalization = TextCapitalization.none});
#override
_CustomRoundedTextFieldState createState() => _CustomRoundedTextFieldState();
}
class _CustomRoundedTextFieldState extends State<CustomRoundedTextField> {
bool _showPwd = false;
#override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 16),
child: TextField(
controller: widget.controller,
keyboardType: widget.inputType,
textCapitalization: widget.textCapitalization,
obscureText: widget.isPassword && !_showPwd,
style:
TextStyle(fontSize: 15, color: Colors.black),
decoration: InputDecoration(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
color: Colors.black54,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15),
borderSide: BorderSide(
color: Colors.black,
),
),
labelText: widget.label,
labelStyle: TextStyle(
fontSize: 15,
color: Colors.black,
fontWeight: FontWeight.w600,
),
suffixIcon: widget.isPassword ? IconButton(
icon: Icon(_showPwd ? Icons.visibility : Icons.visibility_off),
onPressed:(){
setState((){
_showPwd = !_showPwd;
});
}
) : null,
),
onChanged: widget.onChange,
),
);
}
}

The setter 'phone=' was called on null. I/flutter (32048): Receiver: null I/flutter (32048): Tried calling: phone="48787487"

The following NoSuchMethodError was thrown while handling a gesture:
The method 'phone' was called on null.
Receiver: null
Tried calling: phone= "1235451"
I'm creating a page to update user registration data, and when I click on update this error appears and nothing happens. I'm learning flutter now, and there's a lot that I don't know, can someone help me?
[User dart file]: https://i.stack.imgur.com/RLimv.png
import 'package:flutter/material.dart';
import '../../generated/l10n.dart';
import '../models/user.dart';
import '../helpers/helper.dart';
import '../elements/BlockButtonWidget.dart';
import '../helpers/app_config.dart' as config;
import 'package:mvc_pattern/mvc_pattern.dart';
import '../repository/user_repository.dart' as repository;
import '../repository/user_repository.dart';
class SettingsController extends ControllerMVC {
GlobalKey<FormState> loginFormKey;
GlobalKey<ScaffoldState> scaffoldKey;
SettingsController() {
loginFormKey = new GlobalKey<FormState>();
this.scaffoldKey = new GlobalKey<ScaffoldState>();
}
void update(User user) async {
user.deviceToken = null;
repository.update(user).then((value) {
scaffoldKey?.currentState?.showSnackBar(SnackBar(
content: Text("Atualizado com Sucesso"),
));
});
}
}
class ProfileSettingsDialog extends StatefulWidget {
final User user;
final VoidCallback onChanged;
ProfileSettingsDialog({Key key,#required this.user, this.onChanged}) : super(key: key);
#override
_ProfileSettingsDialogState createState() => _ProfileSettingsDialogState();
}
class _ProfileSettingsDialogState extends State<ProfileSettingsDialog> {
GlobalKey<FormState> _profileSettingsFormKey = new GlobalKey<FormState>();
#override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: Helper.of(context).onWillPop,
child: Scaffold(
resizeToAvoidBottomPadding: false,
body: Stack(
alignment: AlignmentDirectional.topCenter,
children: <Widget>[
Positioned(
top: 0,
child: Container(
width: config.App(context).appWidth(100),
height: config.App(context).appHeight(29.5),
decoration: BoxDecoration(color: Theme.of(context).accentColor),
),
),
Positioned(
top: config.App(context).appHeight(29.5) - 120,
child: Container(
width: config.App(context).appWidth(84),
height: config.App(context).appHeight(29.5),
child: Text(
S.of(context).lets_start_with_register,
style: Theme.of(context).textTheme.headline2.merge(TextStyle(color: Theme.of(context).primaryColor)),
),
),
),
Positioned(
top: config.App(context).appHeight(29.5) - 50,
child: Container(
decoration: BoxDecoration(color: Theme.of(context).primaryColor, borderRadius: BorderRadius.all(Radius.circular(10)), boxShadow: [
BoxShadow(
blurRadius: 50,
color: Theme.of(context).hintColor.withOpacity(0.2),
)
]),
margin: EdgeInsets.symmetric(
horizontal: 20,
),
padding: EdgeInsets.symmetric(vertical: 50, horizontal: 27),
width: config.App(context).appWidth(88),
// height: config.App(context).appHeight(55),
child: Form(key: _ProfileSettingsFormKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextFormField(
keyboardType: TextInputType.text,
onSaved: (input) => widget.user.phone = input,
validator: (input) => input.trim().length < 3 ? S.of(context).not_a_valid_phone : null,
decoration: InputDecoration(
labelText: "Celular",
labelStyle: TextStyle(color: Theme.of(context).accentColor),
contentPadding: EdgeInsets.all(12),
hintText: S.of(context).john_doe,
hintStyle: TextStyle(color: Theme.of(context).focusColor.withOpacity(0.7)),
prefixIcon: Icon(Icons.person_outline, color: Theme.of(context).accentColor),
border: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.2))),
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.5))),
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.2))),
),
),
SizedBox(height: 30),
TextFormField(
keyboardType: TextInputType.text,
onSaved: (input) => widget.user.address = input,
validator: (input) => input.trim().length < 3 ? S.of(context).not_a_valid_address : null,
decoration: InputDecoration(
labelText: "Endereço",
labelStyle: TextStyle(color: Theme.of(context).accentColor),
contentPadding: EdgeInsets.all(12),
hintText: 'johndoe#gmail.com',
hintStyle: TextStyle(color: Theme.of(context).focusColor.withOpacity(0.7)),
prefixIcon: Icon(Icons.alternate_email, color: Theme.of(context).accentColor),
border: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.2))),
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.5))),
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.2))),
),
),
SizedBox(height: 30),
TextFormField(
keyboardType: TextInputType.text,
onSaved: (input) => widget.user.bio = input,
validator: (input) => input.trim().length < 3 ? S.of(context).not_a_valid_biography : null,
decoration: InputDecoration(
labelText: "Biografia",
labelStyle: TextStyle(color: Theme.of(context).accentColor),
contentPadding: EdgeInsets.all(12),
hintText: 'johndoe#gmail.com',
hintStyle: TextStyle(color: Theme.of(context).focusColor.withOpacity(0.7)),
prefixIcon: Icon(Icons.alternate_email, color: Theme.of(context).accentColor),
border: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.2))),
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.5))),
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Theme.of(context).focusColor.withOpacity(0.2))),
),
),
SizedBox(height: 30),
BlockButtonWidget(
text: Text(
S.of(context).register,
style: TextStyle(color: Theme.of(context).primaryColor),
),
color: Theme.of(context).accentColor,
onPressed: () {
_profileSettingsFormKey.currentState.save();
widget.onChanged();
Navigator.pop(context);
update(currentUser.value);
//setState(() {});
},
// widget.update(currentUser.value);
),
SizedBox(height: 25),
// FlatButton(
// onPressed: () {
// Navigator.of(context).pushNamed('/MobileVerification');
// },
// padding: EdgeInsets.symmetric(vertical: 14),
// color: Theme.of(context).accentColor.withOpacity(0.1),
// shape: StadiumBorder(),
// child: Text(
// 'Register with Google',
// textAlign: TextAlign.start,
// style: TextStyle(
// color: Theme.of(context).accentColor,
// ),
// ),
// ),
],
),
),
),
),
],
),
),
);
}
InputDecoration getInputDecoration({String hintText, String labelText}) {
return new InputDecoration(
hintText: hintText,
labelText: labelText,
hintStyle: Theme.of(context).textTheme.bodyText2.merge(
TextStyle(color: Theme.of(context).focusColor),
),
enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Theme.of(context).hintColor.withOpacity(0.2))),
focusedBorder: UnderlineInputBorder(borderSide: BorderSide(color: Theme.of(context).hintColor)),
floatingLabelBehavior: FloatingLabelBehavior.auto,
labelStyle: Theme.of(context).textTheme.bodyText2.merge(
TextStyle(color: Theme.of(context).hintColor),
),
);
}
}
I cannot see the definition of your User class but it seems that the property phone is defined as final (hence, you get the error the setter method was called on null).
You need to make the property mutable (non-final such as String phone) in order to be able to change its value in the same way as in your code.