Related
this is the login screen I had Implemented using flutter. I want this screen to be scrollable. how can I do that? I have uploaded my login screen code for your reference. I have tried out my column wrap with a single-child scroll view. but it doesn't work. there are multiple columns, maybe I'm wrapping the wrong column. I appriciate your help on this.
class LoginScreen extends StatefulWidget {
const LoginScreen({Key? key}) : super(key: key);
#override
_LoginScreenState createState() => _LoginScreenState();
}
class _LoginScreenState extends State<LoginScreen> {
#override
Widget build(BuildContext context) {
final Size = MediaQuery.of(context).size;
return GestureDetector(
onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Color.fromARGB(255, 3, 86, 124), Color(0xff141a3a)],
begin: Alignment.topRight,
end: Alignment.bottomLeft,
)),
child: Scaffold(
backgroundColor: Colors.transparent,
resizeToAvoidBottomInset: false,
body: Padding(
padding: const EdgeInsets.only(top: 40, left: 20, right: 20),
child: Column(
children: [
Expanded(
flex: 2,
child: Column(
children: [
// Spacer(flex: 1),
Image(
image: const AssetImage(
'assets/images/LogoVector.png',
),
height: Size.width / 2.9,
width: Size.width / 2.9,
),
SizedBox(height: 5),
Text(
"LOGIN",
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 30,
color: textWhite,
fontFamily: "Roboto"),
),
],
),
),
// const Spacer(flex: 1),
const Expanded(flex: 3, child: Center(child: LoginForm())),
],
),
),
),
),
);
}
}
class LoginForm extends StatefulWidget {
const LoginForm({Key? key}) : super(key: key);
#override
_LoginFormState createState() => _LoginFormState();
}
Map<String, String> loginUserData = {
'email': '',
'password': '',
'id': '',
'userName': '',
'token': '',
'userStatus': '',
};
class _LoginFormState extends State<LoginForm> {
TextEditingController emailEditingController = new TextEditingController();
TextEditingController passwordEditingController = new TextEditingController();
final _formKey = GlobalKey<FormState>();
String email = "";
String password = "";
String username = "";
bool isLoading = false;
bool typing = true;
bool _isObscure = true;
#override
Widget build(BuildContext context) {
final Size = MediaQuery.of(context).size;
return Form(
key: _formKey,
autovalidateMode: AutovalidateMode.disabled,
child: Column(
children: [
TextFormField(
controller: emailEditingController,
enabled: true,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30.0),
borderSide: const BorderSide(
color: textWhite,
),
// borderSide: BorderSide.none
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30.0),
borderSide: const BorderSide(color: textWhite),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30.0),
borderSide: const BorderSide(color: Colors.red),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30.0),
borderSide: const BorderSide(color: Colors.red),
),
isDense: true,
contentPadding: EdgeInsets.fromLTRB(10, 30, 10, 0),
hintText: "Email/ Username",
hintStyle: TextStyle(
color: textWhite, fontFamily: "Roboto", fontSize: 14),
),
style: TextStyle(color: textWhite),
validator: (String? UserName) {
if (UserName != null && UserName.isEmpty) {
return "Email can't be empty";
}
return null;
},
onChanged: (String? text) {
email = text!;
// print(email);
},
onSaved: (value) {
loginUserData['email'] = value!;
},
),
SizedBox(
height: 10,
),
TextFormField(
controller: passwordEditingController,
obscureText: _isObscure,
enabled: true,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30.0),
borderSide: const BorderSide(color: textWhite),
// borderSide: BorderSide.none
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30.0),
borderSide: const BorderSide(color: textWhite),
),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide: const BorderSide(color: Colors.red),
),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide: const BorderSide(color: Colors.red),
),
isDense: true,
contentPadding: EdgeInsets.fromLTRB(10, 10, 10, 0),
suffixIcon: IconButton(
icon: Icon(
_isObscure ? Icons.visibility : Icons.visibility_off),
color: textWhite,
onPressed: () {
setState(() {
_isObscure = !_isObscure;
});
}),
hintText: "Password",
hintStyle: TextStyle(
color: textWhite,
fontFamily: "Roboto",
fontSize: 14,
)),
style: TextStyle(color: textWhite),
validator: (String? Password) {
if (Password != null && Password.isEmpty) {
return "Password can't be empty";
}
return null;
},
onChanged: (String? text) {
password = text!;
print(password);
},
onSaved: (value) {
loginUserData['password'] = value!;
},
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(
child: CheckboxListTile(
title: const Text(
"Remember Me",
style: TextStyle(
color: textWhite, fontFamily: "Roboto", fontSize: 14),
),
activeColor: buttontext,
// tileColor: buttontext,
value: checkedValue,
onChanged: (newValue) {
FocusManager.instance.primaryFocus?.unfocus();
setState(() {
if (isLoading != true) {
checkedValue = newValue!;
print(newValue);
}
});
},
contentPadding: EdgeInsets.only(left: 0, top: 0),
controlAffinity:
ListTileControlAffinity.leading, // <-- leading Checkbox
),
),
TextButton(
child: Text(
"Forget Password",
style: TextStyle(
color: textWhite, fontFamily: "Roboto", fontSize: 14),
),
onPressed: () {
Get.to(() => Forget_Screen());
},
)
],
),
SizedBox(height: 40),
isLoading
? SpinKitDualRing(
color: textWhite,
size: 40,
)
: GestureDetector(
child: MainButton("Login"),
onTap: () async {
FocusManager.instance.primaryFocus?.unfocus();
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
await LoginData();
// Get.to(BottomNavigation());
}
},
),
SizedBox(height: 15),
Container(
width: 275.0,
height: 40.0,
child: OutlinedButton(
onPressed: () {
Get.to(() => const Signup_Screen());
},
child: const Text(
'Signup',
style: TextStyle(
fontSize: 15, fontFamily: "Roboto", color: textWhite
//fontWeight: FontWeight.w500,
// color: Colors.black,
),
),
style: OutlinedButton.styleFrom(
side: const BorderSide(
width: 1.0,
color: textWhite,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
),
),
)
],
),
);
}
}
You should wrap everything under the Scaffold:
Scaffold(
backgroundColor: Colors.transparent,
resizeToAvoidBottomInset: false,
body: SingleChildScrollView(child: Padding(
padding: const EdgeInsets.only(top: 40, left: 20, right: 20),
child: Column(
........
I can not see you using the SingleChildScrollView in then code sample you have provided with.
But if you want to make the page scrollable, Wrap the child of the scaffold in the SingleChildScrollView
Scaffold(
body: SingleChildScrollView(
....
trying to use mutation on forms but got this error while addins runmutation and queryresult result in builder ().all i get is dead code in vscode
The argument type 'Widget Function(MultiSourceResult Function(Map<String, dynamic>, {Object? optimisticResult}), QueryResult<Object?>)' can't be assigned to the parameter type 'Widget Function(MultiSourceResult<Object?> Function(Map<String, dynamic>, {Object? optimisticResult}), QueryResult
import 'dart:io';
import 'package:country_code_picker/country_code_picker.dart';
import 'package:project/API/Api.dart';
import 'package:project/screens/form_info.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import '../API/querys.dart';
import '../API/mutations.dart';
class Sign_Number extends StatefulWidget {
Sign_Number({Key? key}) : super(key: key);
#override
State<Sign_Number> createState() => _Sign_NumberState();
}
class _Sign_NumberState extends State<Sign_Number> {
var PhoneNumber = "";
void _onCountryChange(CountryCode countryCode) {
this.PhoneNumber = countryCode.toString();
print("new country selected: " + countryCode.toString());
}
TextEditingController phoneNumberhere = TextEditingController();
TextEditingController password = TextEditingController();
void initState() {
super.initState();
_onCountryChange(CountryCode());
this.PhoneNumber = "+20";
}
var _formKey1 = new GlobalKey<FormState>();
#override
Widget build(BuildContext context) {
return GraphQLProvider(
client: client,
child: MaterialApp(
home: Container(
height: double.infinity,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: [0.5, 0.5],
colors: <Color>[Color.fromRGBO(0, 37, 43, 1), Colors.white],
tileMode:
TileMode.clamp, // clamp the gradient over the canvas
),
),
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Container(Image(
// height: MediaQuery.of(context).size.height *0.5,
// width: 250,
// image: AssetImage('assets/images/2.jpg')),
// ),
Container(
height: 300,
width: 300,
child: const Image(
image: AssetImage(
'assets/images/2.jpg',
),
fit: BoxFit.cover,
),
),
const SizedBox(
//Use of SizedBox
height: 30,
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
child: Row(
children: [
const SizedBox(
width: 47,
),
const Text("Enter mobile number for login",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold)),
],
)),
const SizedBox(
//Use of SizedBox
height: 20,
),
Mutation(
options: new MutationOptions(
document: gql(insertUser()),
/// Tell the GraphQL client to fetch the data from
/// the network only and don't cache it
fetchPolicy: FetchPolicy.noCache,
/// Whenever the [Form] closes, this tells the previous [route]
/// whether it needs to rebuild itself or not
onCompleted: (data) =>
Navigator.pop(context, data != null),
),
builder: (QueryResult, RunMutation) {
return Form(
key: _formKey1,
child: Container(
height: 100,
padding: const EdgeInsets.symmetric(
horizontal: 30),
child: Column(children: [
TextFormField(
controller: phoneNumberhere,
autocorrect: true,
keyboardType:
TextInputType.number,
onFieldSubmitted: (value) {},
validator: (value) {
if (value!.isEmpty) {
return 'Enter a valid Phone Number!';
}
return null;
},
decoration: InputDecoration(
prefixIcon: CountryCodePicker(
onChanged: _onCountryChange,
// Initial selection and favorite can be one of code ('IT') OR dial_code('+39')
initialSelection: '+20',
favorite: ['+20', 'EG'],
textStyle: const TextStyle(
color: Colors.black),
showFlag: true,
),
contentPadding:
const EdgeInsets.all(10),
hintText:
'Enter valid phone number...',
hintStyle: const TextStyle(
color: Colors.black),
filled: true,
fillColor: const Color.fromRGBO(
227, 227, 226, 0.2),
enabledBorder:
const OutlineInputBorder(
borderRadius:
BorderRadius.all(
Radius.circular(
12.0)),
borderSide: BorderSide(
color: Colors.white,
width: 2),
),
focusedBorder:
const OutlineInputBorder(
borderRadius:
BorderRadius.all(
Radius.circular(
10.0)),
borderSide: BorderSide(
color: Colors.white),
),
),
),
const SizedBox(
//Use of SizedBox
height: 10,
),
SizedBox(
height: 50,
child: TextFormField(
autofocus: false,
obscureText: true,
controller: password,
autocorrect: true,
keyboardType: TextInputType
.visiblePassword,
onFieldSubmitted: (value) {},
validator: (value) {
if (value!.isEmpty) {
return 'Enter a valid password!';
}
return null;
},
decoration: InputDecoration(
contentPadding:
const EdgeInsets.all(10),
hintText: 'Enter Password.',
hintStyle: const TextStyle(
color: Colors.black),
filled: true,
fillColor:
const Color.fromRGBO(
227, 227, 226, 0.2),
enabledBorder:
const OutlineInputBorder(
borderRadius:
BorderRadius.all(
Radius.circular(
12.0)),
borderSide: BorderSide(
color: Colors.white,
width: 2),
),
focusedBorder:
const OutlineInputBorder(
borderRadius:
BorderRadius.all(
Radius.circular(
10.0)),
borderSide: BorderSide(
color: Colors.white),
),
),
),
),
const SizedBox(
//Use of SizedBox
height: 5,
),
const Text(
"forgot your password?",
style: TextStyle(
color: Color.fromRGBO(
218, 218, 218, 1),
fontSize: 10),
textAlign: TextAlign.left,
),
])));
const SizedBox(
//Use of SizedBox
height: 50,
);
FlatButton(
height: 50,
minWidth: 300,
onPressed: () {
if (_formKey1.currentState!.validate()) {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) =>
MyCustomForm()));
// If the form is valid, display a snackbar. In the real world,
// you'd often call a server or save the information in a database.
ScaffoldMessenger.of(context)
.showSnackBar(
SnackBar(
content:
Text(phoneNumberhere.text)),
);
}
},
color: const Color.fromRGBO(0, 168, 165, 1),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10)),
child: const Text(
"Continue",
style: TextStyle(
color: Colors.white, fontSize: 19),
),
);
},
),
],
)
])))));
}
}```
I have a few rules for validator e-mail and password of my registration page and I want to check them. But it's not working.
import 'package:flutter/material.dart';
class register extends StatefulWidget {
register({Key? key}) : super(key: key);
#override
_registerState createState() => _registerState();
}
class _registerState extends State<register> {
late TextEditingController textController1;
late TextEditingController textController2;
late bool passwordVisibility1;
late TextEditingController textController3;
late bool passwordVisibility2;
final scaffoldKey = GlobalKey<ScaffoldState>();
String email = '';
String password = '';
String error = '';
#override
void initState() {
super.initState();
textController1 = TextEditingController();
textController2 = TextEditingController();
passwordVisibility1 = false;
textController3 = TextEditingController();
passwordVisibility2 = false;
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Stack(
children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
image: DecorationImage(
fit: BoxFit.cover,
image: Image.asset(
'assets/img/backgraund_page.jpg',
).image,
),
),
),
Align(
alignment: AlignmentDirectional(0, -0.8),
child: Image.asset(
'assets/logo/Aet_page-0001-removebg-preview.png',
width: 250,
height: 170,
fit: BoxFit.contain,
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 300, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width,
height: 565,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(0),
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
),
),
child: Stack(
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 70, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
validator: (val) =>
val!.isEmpty ? 'Enter an email' : null,
onChanged: (val) {
setState(() {
email = val;
});
},
controller: textController1,
obscureText: false,
decoration: const InputDecoration(
hintText: 'E-Posta',
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
),
keyboardType: TextInputType.emailAddress,
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 120, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
validator: (val) => val!.length < 6
? 'Ender a password 6+ chars long'
: null,
onChanged: (val) {
setState(() {
password = val;
});
},
controller: textController2,
obscureText: !passwordVisibility1,
decoration: InputDecoration(
hintText: 'Password',
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
suffixIcon: InkWell(
onTap: () => setState(
() =>
passwordVisibility1 = !passwordVisibility1,
),
child: Icon(
passwordVisibility1
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
color: Color(0xFF757575),
size: 22,
),
),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 170, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
controller: textController3,
obscureText: !passwordVisibility2,
decoration: InputDecoration(
hintText: 'Confirm Password',
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
suffixIcon: InkWell(
onTap: () => setState(
() =>
passwordVisibility2 = !passwordVisibility2,
),
child: Icon(
passwordVisibility2
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
color: Color(0xFF757575),
size: 22,
),
),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 120, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 170, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 220, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
// ignore: prefer_const_constructors
padding: EdgeInsetsDirectional.fromSTEB(40, 270, 0, 0),
// ignore: deprecated_member_use
child: SizedBox(
height: 40,
width: MediaQuery.of(context).size.width * 0.8,
child: RaisedButton(
onPressed: () {
print(email);
print(password);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
color: Color(0xFF36A8D3),
child: const Center(
child: Text(
"Sign In",
style: TextStyle(color: Colors.white),
),
),
),
),
),
const Padding(
padding: EdgeInsetsDirectional.fromSTEB(65, 512, 0, 0),
child: Text(
'Are you already a member?',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 15,
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(265, 512, 0, 0),
child: InkWell(
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => loginpage(),
),
);
},
child: const Text(
'Login In',
style: TextStyle(
fontFamily: 'Poppins',
color: Colors.blue,
fontSize: 15,
),
),
),
),
],
),
),
),
],
),
),
);
}
}
hello everyone, above are the codes for my registration page. With Validator I have a few rules required for e-mail password and I want to check these rules, but the validator is not working at all. How can I fix this. Can you help me?
You have to wrap your TextFormField with Form.
import 'package:flutter/material.dart';
class register extends StatefulWidget {
register({Key? key}) : super(key: key);
#override
_registerState createState() => _registerState();
}
class _registerState extends State<register> {
late TextEditingController textController1;
late TextEditingController textController2;
late bool passwordVisibility1;
late TextEditingController textController3;
late bool passwordVisibility2;
final scaffoldKey = GlobalKey<ScaffoldState>();
final formKey = GlobalKey<FormState>();
String email = '';
String password = '';
String error = '';
#override
void initState() {
super.initState();
textController1 = TextEditingController();
textController2 = TextEditingController();
passwordVisibility1 = false;
textController3 = TextEditingController();
passwordVisibility2 = false;
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Stack(
children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
image: DecorationImage(
fit: BoxFit.cover,
image: Image.asset(
'assets/img/backgraund_page.jpg',
).image,
),
),
),
Align(
alignment: AlignmentDirectional(0, -0.8),
child: Image.asset(
'assets/logo/Aet_page-0001-removebg-preview.png',
width: 250,
height: 170,
fit: BoxFit.contain,
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 300, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width,
height: 565,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(0),
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
),
),
child: Form(
key: formKey,
child: Stack(
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 70, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
validator: (val) =>
val!.isEmpty ? 'Enter an email' : null,
onChanged: (val) {
setState(() {
email = val;
});
},
controller: textController1,
obscureText: false,
decoration: const InputDecoration(
hintText: 'E-Posta',
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
),
keyboardType: TextInputType.emailAddress,
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 120, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: const BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
validator: (val) => val!.length < 6
? 'Ender a password 6+ chars long'
: null,
onChanged: (val) {
setState(() {
password = val;
});
},
controller: textController2,
obscureText: !passwordVisibility1,
decoration: InputDecoration(
hintText: 'Password',
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
suffixIcon: InkWell(
onTap: () => setState(
() =>
passwordVisibility1 = !passwordVisibility1,
),
child: Icon(
passwordVisibility1
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
color: Color(0xFF757575),
size: 22,
),
),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 170, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 50,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: TextFormField(
controller: textController3,
obscureText: !passwordVisibility2,
decoration: InputDecoration(
hintText: 'Confirm Password',
enabledBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0x00000000),
width: 1,
),
),
suffixIcon: InkWell(
onTap: () => setState(
() =>
passwordVisibility2 = !passwordVisibility2,
),
child: Icon(
passwordVisibility2
? Icons.visibility_outlined
: Icons.visibility_off_outlined,
color: Color(0xFF757575),
size: 22,
),
),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 120, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 170, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(40, 220, 0, 0),
child: Container(
width: MediaQuery.of(context).size.width * 0.8,
height: 1,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
border: Border.all(
color: Color(0xFFB9B7B7),
),
),
),
),
Padding(
// ignore: prefer_const_constructors
padding: EdgeInsetsDirectional.fromSTEB(40, 270, 0, 0),
// ignore: deprecated_member_use
child: SizedBox(
height: 40,
width: MediaQuery.of(context).size.width * 0.8,
child: RaisedButton(
onPressed: () {
if(!formKey.currentState!.validate()) return;
print(email);
print(password);
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
color: Color(0xFF36A8D3),
child: const Center(
child: Text(
"Sign In",
style: TextStyle(color: Colors.white),
),
),
),
),
),
const Padding(
padding: EdgeInsetsDirectional.fromSTEB(65, 512, 0, 0),
child: Text(
'Are you already a member?',
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 15,
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(265, 512, 0, 0),
child: InkWell(
onTap: () async {
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => loginpage(),
),
);
},
child: const Text(
'Login In',
style: TextStyle(
fontFamily: 'Poppins',
color: Colors.blue,
fontSize: 15,
),
),
),
),
],
),
),
),
),
],
),
),
);
}
}
I'm Working on app, and i'm navigating through pages using routes, i'm not using any hero or FloatingActionButtons but i'm getting this hero related error, does anybody has any idea what could be the cause of that?
Here's the navigation call
nextTapped()async{
if(occasionTitleTxtField.text.isEmpty || dateTxtField.text.isEmpty || detailsTxtField.text.isEmpty)
ErrorOverlay("Invalid Data", false);
else
{
await LoadingOverlay.of(context).during(UserOperations().createFirstOccasion(context, occasionTitleTxtField.text, dateTxtField.text, detailsTxtField.text, repeatEveryYear, timeLimit)).then((value){
if(value.elementAt(0) == "true")
Navigator.of(context).pushReplacementNamed('/firstGift',arguments: FirstGiftPage(value.elementAt(1),occasionTitleTxtField.text));
});
}
}
Here's the route_generator
class RouteGenerator {
static Route<dynamic> generateRoute(RouteSettings settings) {
// Getting arguments passed in while calling Navigator.pushNamed
final args = settings.arguments;
switch (settings.name) {
case '/':
return MaterialPageRoute(builder: (_) => SplashScreen());
case '/login':
return MaterialPageRoute(builder: (_) => LoginPage());
case '/homepage':
return MaterialPageRoute(builder: (_) => HomePage());
case '/signUp':
return MaterialPageRoute(builder: (_) => SignUpScreen());
case '/otpScreen':
return MaterialPageRoute(builder: (_) {
OTPScreen screenArgs = args;
return OTPScreen(screenArgs.phoneNumber,screenArgs.countryCode);
});
case '/phoneNumber':
return MaterialPageRoute(builder: (_) {
PhoneNumberScreen screenArgs = args;
return PhoneNumberScreen(screenArgs.Provider);
});
case '/interests':
return MaterialPageRoute(builder: (_) => InterestsPage());
case '/invitation':
return MaterialPageRoute(builder: (_) => InvitationPage());
case '/firstOccasion':
return MaterialPageRoute(builder: (_) => FirstOccasion());
case '/firstGift':
return MaterialPageRoute(builder: (_) {
FirstGiftPage screenArgs = args;
return FirstGiftPage(screenArgs.occasionID,screenArgs.occasionTitle);
});
case '/map':
return MaterialPageRoute(builder: (_) => MapsPage());
default:
return _errorRoute();
}
}
static Route<dynamic> _errorRoute() {
return MaterialPageRoute(builder: (_) {
return Scaffold(
appBar: AppBar(
title: Text('Error'),
),
body: Center(
child: Text('UnderConstruction'),
),
);
});
}
}
Page i want to navigate to
class FirstGiftPage extends StatefulWidget {
String occasionID;
String occasionTitle;
static LatLng storeLocation;
FirstGiftPage(this.occasionID,this.occasionTitle);
#override
_FirstGiftPageState createState() => _FirstGiftPageState();
}
class _FirstGiftPageState extends State<FirstGiftPage> {
TextEditingController giftTitleTxtField = TextEditingController();
TextEditingController giftLinkTxtField = TextEditingController();
TextEditingController giftPriceTxtField = TextEditingController();
TextEditingController giftStoreAddTxtField = TextEditingController();
int giftCounter = 0;
TextEditingController detailsTxtField = TextEditingController();
Future<File> imageFile;
nextTapped()async{
if(giftTitleTxtField.text.isEmpty || giftLinkTxtField.text.isEmpty || giftPriceTxtField.text.isEmpty || detailsTxtField.text.isEmpty)
ErrorOverlay("Invalid Data",false);
else
{
Map<String,dynamic> giftData={
"giftName" : giftTitleTxtField.text,
"giftLink" : giftLinkTxtField.text,
"giftPrice" : giftPriceTxtField.text,
"storeAddress": giftStoreAddTxtField.text,
"details" : detailsTxtField.text,
"giftQuantity" : giftCounter,
"images":[imageFile.toString()],
"occasionID": widget.occasionID
};
ErrorOverlay("Gift Done",true);
Navigator.of(context).pushReplacementNamed("/homepage");
}
}
showMaps(){
Navigator.of(context).pushNamed("/map");
}
#override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromRGBO(246, 76, 77, 1),
Color.fromRGBO(156, 51, 117, 1)
],
begin: Alignment .topRight,
end: Alignment.bottomLeft
)
),
child: Scaffold(
backgroundColor: Colors.transparent,
appBar:AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
elevation: 0,
bottom: PreferredSize(
preferredSize: Size(0.0, 80.0),
child: Padding(
//TODO::Change padding to ScreenWidth - 300 / 2
padding: const EdgeInsets.only(left: 55.0 ,right: 55.0,bottom: 30.0),
child: Text(AppLocalizations.of(context).firstGift,style: TextStyle(color: Colors.white,fontSize: 30.0),textAlign: TextAlign.center,maxLines: 2,),
),
),
),
body: Padding(
padding: const EdgeInsets.only(top: 20.0,left: 15.0,right: 15.0),
child: Align(
alignment: Alignment.topCenter,
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
controller: giftTitleTxtField,
obscureText: false,
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
contentPadding:EdgeInsets.only(top:20.0,bottom:20.0,left: 15.0),
hintText: AppLocalizations.of(context).giftName,
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(30.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(30.0),
),
prefix: Container(width: 10.0,),
hintStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
)
),),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
controller: giftLinkTxtField,
obscureText: false,
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
contentPadding:EdgeInsets.only(top:20.0,bottom:20.0,left: 15.0),
hintText: AppLocalizations.of(context).giftLink,
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(30.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(30.0),
),
prefix: Container(width: 10.0,),
hintStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
)
),),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
controller: giftPriceTxtField,
obscureText: false,
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
contentPadding:EdgeInsets.only(top:20.0,bottom:20.0,left: 15.0),
hintText: AppLocalizations.of(context).giftPrice,
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(30.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(30.0),
),
prefix: Container(width: 10.0,),
hintStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
)
),),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
readOnly: true,
onTap: showMaps,
controller: giftStoreAddTxtField,
obscureText: false,
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
contentPadding:EdgeInsets.only(top:20.0,bottom:20.0,left: 15.0),
hintText: AppLocalizations.of(context).giftStoreAdd,
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(30.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(30.0),
),
hintStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
)
),),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(AppLocalizations.of(context).giftQuantity,style: TextStyle(color: Colors.white),),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Counter(
initialValue: giftCounter,
minValue: 0,
maxValue: 10,
step: 1,
decimalPlaces: 0,
textStyle: TextStyle(color: Colors.white),
onChanged: (value) { // get the latest value from here
setState(() {
giftCounter = value;
});
},
),
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
enabled: false,
obscureText: false,
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
contentPadding: EdgeInsets.only(top: 20),
hintText: widget.occasionTitle,
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(20.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(20.0),
),
prefix: Container(width: 10.0,),
hintStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
)
),),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
maxLines: null,
textAlign: TextAlign.center,
textAlignVertical: TextAlignVertical.center,
controller: detailsTxtField,
obscureText: false,
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
contentPadding: EdgeInsets.only(top: 20),
hintText: AppLocalizations.of(context).details,
border: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(20.0),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(20.0),
),
prefix: Container(width: 10.0,),
hintStyle: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
height: 4.0
)
),),
),
InkWell(
onTap: null,
child: Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 50.0,
height: 50.0,
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.white,width: 4.0),
borderRadius: BorderRadius.circular(2.0)
),
child: Center(
child: Icon(Icons.camera_alt_outlined,color: Colors.white,size: 25.0,),
),
),
),
),
)
],
),
),
),
bottomNavigationBar: BottomAppBar(
child: Container(
child: Wrap(
//mainAxisAlignment: MainAxisAlignment.end,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Align(
alignment: MyApp.getLocale(context).languageCode == "ar" ? Alignment.centerLeft:Alignment.centerRight,
child: Text("(4/5)"),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: LinearProgressIndicator(
minHeight: 10.0,
backgroundColor: Colors.white,
value: 0.80,
valueColor: AlwaysStoppedAnimation<Color>(Colors.orange),
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: InkWell(
onTap: (){
Navigator.of(context).pushReplacement(MaterialPageRoute(builder: (BuildContext context)=> FirstGiftPage("","")));
},
child: Text(AppLocalizations.of(context).ignore,style: TextStyle(decoration: TextDecoration.underline),)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: InkWell(
onTap: nextTapped,
child: Container(
width: 80.0,
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10.0),
gradient: LinearGradient(
colors: [
Color.fromRGBO(246, 76, 77, 1),
Color.fromRGBO(156, 51, 117, 1)
],
begin: Alignment .topRight,
end: Alignment.bottomLeft
)
),
child: Center(child: Text(AppLocalizations.of(context).next, style: TextStyle(color: Colors.white),)),
),
),
)
],
)
],
),
),
),
),
);
}
}
Here's the error
════════ Exception caught by scheduler library ═════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
There are multiple heroes that share the same tag within a subtree.
Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), each Hero must have a >unique non-null tag.
In this case, multiple heroes had the following tag:
Here is the subtree for one of the offending heroes: Hero
tag:
state: _HeroState#48fb7
When the exception was thrown, this was the stack:
#0 Hero._allHeroesFor.inviteHero. >(package:flutter/src/widgets/heroes.dart:268:11)
#1 Hero._allHeroesFor.inviteHero (package:flutter/src/widgets/heroes.dart:279:8)
#2 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:298:21)
#3 SingleChildRenderObjectElement.visitChildren >(package:flutter/src/widgets/framework.dart:6105:14)
#4 Hero._allHeroesFor.visitor (package:flutter/src/widgets/heroes.dart:311:15)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
If you are using more than one floating action button then you need to pass your own tag to each button like this
FloatingActionButton(
heroTag: "tag1",
)
FloatingActionButton(
heroTag: "tag2",
)
By default, the heroTag is tag so in this case, you will get an error.
Second thing
If you are using more than one hero animation widget on the same page and share the same tag then also same error exist so you need to pass your own tag to each Hero widget
I solved this by creating a new file for the page i want to navigate to and it worked, have no idea how
I am creating a Password Manager Application and when user entering his details then I wont to show them a slider which generates a password in upper Password field. I have created a some code but i am not getting result as expected when user click on GENERATE PASSWORD the it show the following output.
Expected output:-
Here is my code:
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
class PasswordInput extends StatefulWidget {
#override
_PasswordInputState createState() => _PasswordInputState();
}
class _PasswordInputState extends State<PasswordInput> {
bool _obscureText = true;
int generatePasswordHelper = 0;
String _passwordStrength = "Hello";
int _currentRangeValues = 6;
void _toggle() {
setState(() {
_obscureText = !_obscureText;
});
}
Widget WebsiteName() {
return TextFormField(
textCapitalization: TextCapitalization.words,
keyboardType: TextInputType.text,
decoration: InputDecoration(
labelText: "Name of website",
labelStyle: TextStyle(fontSize: 14, color: Colors.grey.shade400),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.grey.shade300,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.red,
),
),
),
);
}
Widget WebsiteAddress() {
return TextFormField(
keyboardType: TextInputType.url,
decoration: InputDecoration(
labelText: "Website address",
labelStyle: TextStyle(fontSize: 14, color: Colors.grey.shade400),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.grey.shade300,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.red,
),
),
),
);
}
Widget UserName() {
return TextFormField(
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
labelText: "Username / Email",
labelStyle: TextStyle(fontSize: 14, color: Colors.grey.shade400),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.grey.shade300,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.red,
),
),
),
);
}
Widget Password() {
return TextFormField(
keyboardType: TextInputType.text,
obscureText: _obscureText,
decoration: InputDecoration(
labelText: "Password",
labelStyle: TextStyle(fontSize: 14, color: Colors.grey.shade400),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.grey.shade300,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.red,
),
),
suffixIcon: IconButton(
icon: Icon(
_obscureText ? Icons.visibility : Icons.visibility_off,
color: Colors.grey.shade600,
),
onPressed: _toggle,
),
),
);
}
Widget Note() {
return TextFormField(
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.sentences,
maxLines: null,
decoration: InputDecoration(
labelText: "Note",
labelStyle: TextStyle(fontSize: 14, color: Colors.grey.shade400),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.grey.shade300,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: BorderSide(
color: Colors.red,
),
),
),
);
}
Widget GeneratePassword() {
this.generatePasswordHelper = 0;
return Container(
padding: EdgeInsets.only(left: 10),
child: RichText(
text: TextSpan(
style: TextStyle(
color: Colors.deepOrange,
),
children: <TextSpan>[
TextSpan(
text: "GENERATE PASSWORD",
recognizer: TapGestureRecognizer()
..onTap = () {
setState(() {
generatePasswordHelper = 1;
});
})
]),
),
);
}
Widget PasswordGenerator() {
return Container(
color: Colors.grey.shade200,
//height: MediaQuery.of(context).size.width / 2,
width: MediaQuery.of(context).size.width / 1.1,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
padding: EdgeInsets.only(left: 10),
child: Text(
_passwordStrength,
),
),
IconButton(
icon: Icon(Icons.close),
onPressed: () {
setState(() {
generatePasswordHelper = 0;
});
},
),
],
),
Slider(
value: _currentRangeValues.toDouble(),
min: 0,
max: 100,
divisions: 27,
onChanged: (double newValue) {
setState(() {
_currentRangeValues = newValue.round();
});
},
semanticFormatterCallback: (double newValue) {
return '${newValue.round()} dollars';
}
)
],
),
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
//resizeToAvoidBottomPadding: false,
appBar: AppBar(
centerTitle: true,
title: Text("Add Password"),
),
body: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(),
child: Container(
padding: EdgeInsets.only(left: 16, right: 16),
child: Column(
//mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(
height: 20,
),
WebsiteName(),
SizedBox(
height: 20,
),
WebsiteAddress(),
SizedBox(
height: 20,
),
UserName(),
SizedBox(
height: 20,
),
Password(),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
if (generatePasswordHelper == 0)
GeneratePassword()
else
PasswordGenerator()
],
),
SizedBox(
height: 20,
),
Note(),
SizedBox(
height: 20,
),
Container(
height: 50,
width: double.infinity,
child: FlatButton(
onPressed: () {},
padding: EdgeInsets.all(0),
child: Ink(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.centerRight,
colors: [
Color(0xffff5f6d),
Color(0xffff5f6d),
Color(0xffffc371),
],
),
),
child: Container(
alignment: Alignment.center,
constraints: BoxConstraints(
maxWidth: double.infinity, minHeight: 50),
child: Text(
"Submit",
style: TextStyle(
color: Colors.white, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
),
),
),
],
),
),
),
),
);
}
}
You should provide an initalValue to your password field. Init a variable with a default blank value, then when you generate a password save it in that variable and use it as the password field value
https://api.flutter.dev/flutter/widgets/FormField/initialValue.html
class _PasswordInputState extends State<PasswordInput> {
bool _obscureText = true;
int generatePasswordHelper = 0;
String _passwordStrength = "Hello";
int _currentRangeValues = 6;
String currentPassword = ""
...
Widget Password() {
return TextFormField(
keyboardType: TextInputType.text,
obscureText: _obscureText,
initialValue: currentPassword
...
When you generate a password save it in currentPassword using setState