mutation graphql using flutter forms not working - flutter

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),
),
);
},
),
],
)
])))));
}
}```

Related

getting error in Registration screen in flutter

account is not registering and it is already in use the snackbar is working when i am connected with usb and run the code but when i am generating apk file the snackbar and signin is not working i added all the details in my gradle file like storefile progaurd file everything with signingConfig signingConfigs.release key too
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
i added this permission
class SignUpPage extends StatefulWidget {
const SignUpPage({Key? key}) : super(key: key);
#override
_SignUpPageState createState() => _SignUpPageState();
}
class _SignUpPageState extends State<SignUpPage> {
final _formKey = GlobalKey<FormState>();
var email = "";
var password = "";
var confirmpassword = "";
final emailController = TextEditingController();
final passwordController = TextEditingController();
final confirmPasswordController = TextEditingController();
final storage = new FlutterSecureStorage();
String? validateEmail(String value) {
Pattern pattern =
r'^(([^<>()[\]\\.,;:\s#\"]+(\.[^<>()[\]\\.,;:\s#\"]+)*)|(\".+\"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$';
RegExp regex = RegExp(pattern as String);
if (!regex.hasMatch(value)) {
return 'Enter Valid Email';
} else {
return null;
}
}
#override
void dispose() {
emailController.dispose();
passwordController.dispose();
confirmPasswordController.dispose();
super.dispose();
}
registration() async {
if (password == confirmpassword) {
try {
UserCredential userCredential = await FirebaseAuth.instance
.createUserWithEmailAndPassword(email: email, password: password);
if (kDebugMode) {
print(userCredential);
}
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
backgroundColor: Colors.redAccent,
content: Text(
"Registered Successfully. Logged In..",
style: TextStyle(fontSize: 20.0, color: Colors.white),
),
));
Navigator.pushReplacement(
context, MaterialPageRoute(builder: (context) => StartQuiz()));
} on FirebaseAuthException catch (e) {
if (e.code == 'email-already-in-use') {
if (kDebugMode) {
print(" Account Already in use");
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
backgroundColor: Colors.black,
content: Text(
"Account Already in use",
style: TextStyle(fontSize: 18.0, color: Colors.white),
),
));
}
}
}
} else {
if (kDebugMode) {
print("Password and Confirm Password doesn't match");
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
backgroundColor: Colors.black,
content: Text(
"Password and Confirm Password doesn't match",
style: TextStyle(fontSize: 16.0),
),
));
}
}
}
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Container(
width: 500,
height: 800,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
"images/data7.png",
),
fit: BoxFit.cover,
),
),
child: Column(
children: [
Align(
alignment: Alignment.center,
child: Container(
width: 500,
height: 300,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(
"images/d9.png",
),
fit: BoxFit.cover,
),
)),
),
Form(
key: _formKey,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 20, horizontal: 30),
child: Column(
children: [
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(30),
boxShadow: [
BoxShadow(
spreadRadius: 7,
blurRadius: 10,
offset: const Offset(1, 1),
color: Colors.grey.withOpacity(0.2))
]),
child: TextField(
autofocus: false,
decoration: InputDecoration(
hintText: "Email",
prefixIcon: const Icon(
Icons.email,
color: Color.fromARGB(255, 150, 188, 255),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide: const BorderSide(
color: Colors.white, width: 1.0)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide: const BorderSide(
color: Colors.white, width: 1.0)),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(30))),
controller: emailController,
),
),
const SizedBox(
height: 20,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(30),
boxShadow: [
BoxShadow(
spreadRadius: 7,
blurRadius: 10,
offset: const Offset(1, 1),
color: Colors.grey.withOpacity(0.2))
]),
child: TextField(
autofocus: false,
obscureText: true,
decoration: InputDecoration(
hintText: "Password",
prefixIcon: const Icon(
Icons.lock,
color: Color.fromARGB(255, 150, 188, 255),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide: const BorderSide(
color: Colors.white, width: 1.0)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide: const BorderSide(
color: Colors.white, width: 1.0)),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(30)),
errorStyle: const TextStyle(
color: Colors.redAccent, fontSize: 15),
),
controller: passwordController,
),
),
const SizedBox(
height: 20,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(30),
boxShadow: [
BoxShadow(
spreadRadius: 7,
blurRadius: 10,
offset: const Offset(1, 1),
color: Colors.grey.withOpacity(0.2))
]),
child: TextField(
autofocus: false,
obscureText: true,
decoration: InputDecoration(
hintText: "Confirm Password",
prefixIcon: const Icon(
Icons.lock,
color: Color.fromARGB(255, 150, 188, 255),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide: const BorderSide(
color: Colors.white, width: 1.0)),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(30),
borderSide: const BorderSide(
color: Colors.white, width: 1.0)),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(30))),
controller: confirmPasswordController,
),
),
const SizedBox(
height: 20,
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GestureDetector(
onTap: () {
// Validate returns true if the form is valid, otherwise false.
if (_formKey.currentState!.validate()) {
setState(() {
email = emailController.text;
password = passwordController.text;
confirmpassword =
confirmPasswordController.text;
});
registration();
}
},
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
gradient: const LinearGradient(
colors: [
Color(0xFFACB6E5),
Color(0xFF86FDE8)
],
)),
width: 190,
height: 60,
child: const Center(
child: Text(
'Sign Up',
style: TextStyle(
fontWeight: FontWeight.bold ,fontSize: 21.0, color: Colors.indigo), ),
),
),
),
],
),
),
const SizedBox(
height: 10,
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Already have an Account? ",
style: TextStyle(color: Colors.indigo.shade300),
),
TextButton(
onPressed: () => {
Navigator.pushReplacement(
context,
PageRouteBuilder(
pageBuilder: (context, animation1,
animation2) =>
const LoginPage(),
transitionDuration:
const Duration(seconds: 0),
),
)
},
child: const Text(
'Login here',
style: TextStyle(
color: Colors.black54,
fontFamily: 'Montserrat',
fontSize: 15,
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline),
))
],
),
)
],
),
)),
}

Creating an flutter app in vs code with firebase its showing the specific errors .Errors that showing is mentioned below and the signup widget code

'The name UserRecord isn't a type so it can't be used as a type argument Try correcting the name to an existing type or defining a type named UserRecord
The method 'queryUserRecordOnce' isn't defined for the type '_SignupWidgetState'.
Try correcting the name to the name of an existing method, or defining a method named 'queryUserRecordOnce'
The method 'createUserRecordData' isn't defined for the type '_SignupWidgetState'.
Try correcting the name to the name of an existing method, or defining a method named 'createUserRecordData''
*import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'login.dart';
import 'package:easy_debounce/easy_debounce.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:easy_debounce/easy_debounce.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:google_fonts/google_fonts.dart';
class SignupWidget extends StatefulWidget {
const SignupWidget({Key key}) : super(key: key);
#override
_SignupWidgetState createState() => _SignupWidgetState();
}
class _SignupWidgetState extends State<SignupWidget> {
TextEditingController emailTextController;
TextEditingController textController1;
TextEditingController textController2;
TextEditingController passwordTextController;
bool passwordVisibility;
var collection = FirebaseFirestore.instance.collection('UserRecord');
final auth = FirebaseAuth.instance;
final scaffoldKey = GlobalKey<ScaffoldState>();
#override
void initState() {
super.initState();
emailTextController = TextEditingController();
textController1 = TextEditingController();
textController2 = TextEditingController();
passwordTextController = TextEditingController();
passwordVisibility = false;
}
#override
Widget build(BuildContext context) {
return Scaffold(
key: scaffoldKey,
body: SafeArea(
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Align(
alignment: AlignmentDirectional(0.3, -0.8),
child: Container(
width: double.infinity,
height: double.infinity,
decoration: BoxDecoration(
color: Color(0xFFEEEEEE),
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 100, 0, 0),
child: ListView(
padding: EdgeInsets.zero,
shrinkWrap: true,
scrollDirection: Axis.vertical,
children: [
Align(
alignment: AlignmentDirectional(0.2, -0.35),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Align(
alignment: AlignmentDirectional(-0.55, -0.35),
child: InkWell(
onTap: () async {
Navigator.pop(context);
},
child: const FaIcon(
FontAwesomeIcons.arrowLeft,
color: Color.fromRGBO(5, 4, 0, 5),
size: 24,
),
),
),
),
const Expanded(
child: Align(
alignment: AlignmentDirectional(-2.5, -0.1),
child: Text(
'Signup',
style: TextStyle(
fontFamily: 'Oswald',
color: Color(0xFF0F5AA5),
fontSize: 40,
fontWeight: FontWeight.bold,
),
),
),
),
],
),
),
Align(
alignment: AlignmentDirectional(0, 0),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Align(
alignment: AlignmentDirectional(0, 0.05),
child: Container(
width: 250,
height: 400,
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xFF0F5AA5),
Color(0xFF0F5AA5),
],
stops: [0, 0, 1],
begin: AlignmentDirectional(0, -1),
end: AlignmentDirectional(0, 1),
),
),
alignment: AlignmentDirectional(
-0.09999999999999998, 0.5),
child: Align(
alignment: AlignmentDirectional(-0.1, 1),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
10, 15, 10, 0),
child: TextFormField(
controller: emailTextController,
onChanged: (_) => EasyDebounce.debounce(
'emailTextController',
Duration(milliseconds: 2000),
() => setState(() {}),
),
autofocus: true,
obscureText: false,
decoration: InputDecoration(
hintText: 'Mobile or Email',
hintStyle: const TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF000509),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF080F18),
width: 1,
),
borderRadius:
BorderRadius.circular(5),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF080F18),
width: 1,
),
borderRadius:
BorderRadius.circular(5),
),
suffixIcon: emailTextController
.text.isNotEmpty
? InkWell(
onTap: () => setState(
() => emailTextController
?.clear(),
),
child: Icon(
Icons.clear,
color: Color(0xFF757575),
size: 22,
),
)
: null,
),
style: TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF1A1F24),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
10, 10, 10, 0),
child: TextFormField(
controller: textController1,
onChanged: (_) => EasyDebounce.debounce(
'textController1',
Duration(milliseconds: 1000),
() => setState(() {}),
),
autofocus: true,
obscureText: false,
decoration: InputDecoration(
hintText: 'Full name',
hintStyle: TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF000509),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF080F18),
width: 1,
),
borderRadius:
BorderRadius.circular(5),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF080F18),
width: 1,
),
borderRadius:
BorderRadius.circular(5),
),
suffixIcon: textController1
.text.isNotEmpty
? InkWell(
onTap: () => setState(
() => textController1
?.clear(),
),
child: Icon(
Icons.clear,
color: Color(0xFF757575),
size: 22,
),
)
: null,
),
style: TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF1A1F24),
),
textAlign: TextAlign.start,
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
10, 10, 10, 0),
child: TextFormField(
controller: textController2,
onChanged: (_) => EasyDebounce.debounce(
'textController2',
Duration(milliseconds: 1000),
() => setState(() {}),
),
autofocus: true,
obscureText: false,
decoration: InputDecoration(
hintText: 'User name',
hintStyle: TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF000509),
),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF080F18),
width: 1,
),
borderRadius:
BorderRadius.circular(5),
),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF080F18),
width: 1,
),
borderRadius:
BorderRadius.circular(5),
),
suffixIcon: textController2
.text.isNotEmpty
? InkWell(
onTap: () => setState(
() => textController2
?.clear(),
),
child: Icon(
Icons.clear,
color: Color(0xFF757575),
size: 22,
),
)
: null,
),
style: TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF1A1F24),
),
textAlign: TextAlign.start,
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
10, 10, 10, 25),
child: FutureBuilder<List<UserRecord>>(
future: queryUserRecordOnce(
singleRecord: true,
),
builder: (context, snapshot) {
// Customize what your widget looks like when it's loading.
if (!snapshot.hasData) {
return const Center(
child: SizedBox(
width: 50,
height: 50,
child:
CircularProgressIndicator(
color: Colors.black,
),
),
);
}
List<UserRecord>
textFieldUserRecordList =
snapshot.data;
final textFieldUserRecord =
textFieldUserRecordList.isNotEmpty
? textFieldUserRecordList
.first
: null;
return TextFormField(
controller: passwordTextController,
onChanged: (_) =>
EasyDebounce.debounce(
'passwordTextController',
Duration(milliseconds: 1000),
() => setState(() {}),
),
autofocus: true,
obscureText: !passwordVisibility,
decoration: InputDecoration(
hintText: 'Password',
hintStyle: TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF000509),
),
enabledBorder:
UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF080F18),
width: 1,
),
borderRadius:
BorderRadius.circular(5),
),
focusedBorder:
UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFF080F18),
width: 1,
),
borderRadius:
BorderRadius.circular(5),
),
suffixIcon: InkWell(
onTap: () => setState(
() => passwordVisibility =
!passwordVisibility,
),
focusNode: FocusNode(
skipTraversal: true),
child: Icon(
passwordVisibility
? Icons
.visibility_outlined
: Icons
.visibility_off_outlined,
color: Color(0xFF757575),
size: 22,
),
),
),
style: TextStyle(
fontFamily: 'Poppins',
color: Color(0xFF1A1F24),
),
textAlign: TextAlign.start,
);
},
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0, 0, 30),
child: ElevatedButton(
onPressed: () async {
final user = await FirebaseAuth
.instance
.createUserWithEmailAndPassword(
email:
emailTextController.text,
password:
passwordTextController
.text);
if (user == null) {
return;
}
final userCreateData =
createUserRecordData(
username: textController2.text,
pass: passwordTextController.text,
email: emailTextController.text,
uid: textController1.text,
);
await UserRecord.collection
.doc(user.uid)
.update(userCreateData);
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
LoginWidget(),
),
);
},
child: Text("signup"),
),
),
],
),
),
),
),
],
),
),
],
),
),
),
),
),
),
);
}
}*

SingleChildScrollView isn't working in my login screen

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(
....

W/GooglePlayServicesUtil(16928): Google Play Store is missing. flutter

i am trying to get user location but get the google play store service is missing while i dont use any google apps or service in my app. help
i get this error everytime, i try to get my current location
i marked it by ----->
it should give me the latitude and longitude
W/GooglePlayServicesUtil(16928): Google Play Store is missing. flutter
here is my main code i am trying to click on prefixicon to get my location
import 'package:flutter/material.dart';
import 'package:project/screens/sign_page.dart';
import 'package:project/screens/home_screen.dart';
import 'package:geolocator/geolocator.dart';
//textediting controller needed to be added
// Define a custom Form widget.
class MyCustomForm extends StatefulWidget {
const MyCustomForm({Key? key}) : super(key: key);
#override
MyCustomFormState createState() {
return MyCustomFormState();
}
}
// Define a corresponding State class.
// This class holds data related to the form.
class MyCustomFormState extends State<MyCustomForm> {
final _formKey = new GlobalKey<FormState>();
getcurrentlocation() async {
Position position = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high);
var latitude = position.latitude;
var longitude = position.longitude;
print(latitude);
print(longitude);
}
TextEditingController name = TextEditingController();
TextEditingController phone = TextEditingController();
TextEditingController address = TextEditingController();
#override
Widget build(BuildContext context) {
return Material(
child: Form(
key: _formKey,
child: SafeArea(
child: Column(
children: [
Container(
height: MediaQuery.of(context).size.height * 0.15,
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/background.png"),
fit: BoxFit.cover)),
padding: EdgeInsets.only(top: 47, left: 20),
child: Text(
"Personal info",
style: TextStyle(
fontSize: 45,
fontWeight: FontWeight.bold,
color: Colors.white),
),
),
SizedBox(
height: 20,
),
Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.only(left: 29),
child: Text(
"Name",
style: TextStyle(fontSize: 18, color: Colors.black),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 25, vertical: 20),
child: TextFormField(
keyboardType: TextInputType.name,
controller: name,
onFieldSubmitted: (value) {},
validator: (value) {
if (value!.isEmpty) {
return 'Enter a valid Name!';
}
return null;
},
decoration: InputDecoration(
filled: true,
isDense: true, // Added this
contentPadding: EdgeInsets.symmetric(vertical: 22),
fillColor: Color.fromRGBO(238, 247, 246, 1),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12.0)),
borderSide: BorderSide(color: Colors.white, width: 2),
),
hintText: '',
),
),
),
Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.only(left: 29),
child: Text(
"Address",
style: TextStyle(fontSize: 18, color: Colors.black),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 25, vertical: 20),
child: TextFormField(
keyboardType: TextInputType.text,
controller: address,
onFieldSubmitted: (value) {},
validator: (value) {
if (value!.isEmpty) {
return 'Enter a valid address!';
}
return null;
},
decoration: InputDecoration(
prefixIcon: IconButton(
onPressed: () async {
getcurrentlocation(); **----->here!**
},
icon: Icon(Icons.location_on),
),
isDense: true, // Added this
contentPadding: EdgeInsets.symmetric(vertical: 22),
filled: true,
fillColor: Color.fromRGBO(238, 247, 246, 1),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12.0)),
borderSide: BorderSide(color: Colors.white, width: 2),
),
hintText: '',
),
),
),
Container(
alignment: Alignment.topLeft,
padding: EdgeInsets.only(left: 29),
child: Text(
"Phone Number",
style: TextStyle(fontSize: 18, color: Colors.black),
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 25, vertical: 15),
child: TextFormField(
keyboardType: TextInputType.number,
controller: phone,
onFieldSubmitted: (value) {},
validator: (value) {
if (value!.isEmpty) {
return 'Enter a valid phone number!';
}
return null;
},
decoration: InputDecoration(
isDense: true, // Added this
contentPadding: EdgeInsets.symmetric(vertical: 22),
filled: true,
fillColor: Color.fromRGBO(238, 247, 246, 1),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(12.0)),
borderSide: BorderSide(color: Colors.white, width: 2),
),
hintText: '',
),
),
),
Expanded(child: Text("")),
FlatButton(
height: 50,
minWidth: 300,
onPressed: () {
if (_formKey.currentState!.validate()) {
Navigator.push(context,
MaterialPageRoute(builder: (_) => homeScreen()));
// 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("")),
);
}
},
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),
),
),
SizedBox(
height: 20,
)
],
),
// Add TextFormFields and ElevatedButton here.
)));
}
}
I think you run application with emulator without Playstore.
Google core needs google play installed on your virtual device to get ads maps and core functionality that include google play SDK.
you just need to create an emulator with google play as shown in the image below one with the google play icon.
I hope this answer will help you..

How to make TextField's label wont move when out of focus in Flutter

I'm new to flutter.
I'm trying to replicate the following UI, it has multiple TextField and all of their labels won't maximize when I click on other TextField, they keep on focus to show the content inside it: https://i.stack.imgur.com/8lUeV.png
The UI I made: https://i.stack.imgur.com/o9Rpj.png
I tried the autofocus: on but it didn't work cuz it only work for one TextField at a time.
My code:
import 'dart:core';
import 'package:flutter/material.dart';
import 'package:login_sample/models/user.dart';
class EmployeeProfile extends StatefulWidget {
const EmployeeProfile({Key? key, required this.user}) : super(key: key);
final User user;
#override
_EmployeeProfileState createState() => _EmployeeProfileState();
}
class _EmployeeProfileState extends State<EmployeeProfile> {
late String name = '';
late String email = '';
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.bottomCenter,
colors: [Colors.blue, Colors.blue])),
height: MediaQuery.of(context).size.height * 0.3
),
Card(
elevation: 20.0,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
),
),
margin: const EdgeInsets.only(left: 0.0, right: 0.0, top: 100.0),
child: ListView(
children: <Widget>[
SizedBox(
child: TextField(
autofocus: true,
onChanged: (val){
name = val;
},
decoration: InputDecoration(
contentPadding: const EdgeInsets.all(10.0),
labelText: 'Employee Name',
hintText: widget.user.name,
labelStyle: const TextStyle(
color: Color.fromARGB(255, 107, 106, 144),
fontSize: 14,
fontWeight: FontWeight.w500,
),
border: OutlineInputBorder(
borderSide: const BorderSide(color: Color.fromARGB(255, 107, 106, 144), width: 2),
borderRadius: BorderRadius.circular(10),
),
),
),
width: 150.0,
),
SizedBox(
child: TextField(
autofocus: true,
onChanged: (val){
email = val;
},
decoration: InputDecoration(
contentPadding: const EdgeInsets.all(10.0),
labelText: 'Employee Email',
hintText: widget.user.email,
labelStyle: const TextStyle(
color: Color.fromARGB(255, 107, 106, 144),
fontSize: 14,
fontWeight: FontWeight.w500,
),
border: OutlineInputBorder(
borderSide: const BorderSide(color: Color.fromARGB(255, 107, 106, 144), width: 2),
borderRadius: BorderRadius.circular(10),
),
),
),
width: 150.0,
),
TextButton(
onPressed: (){
print(widget.user.name);
print(widget.user.email);
setState(() {
widget.user.name = name;
widget.user.email = email;
});
},
child: const Text('Save'),
),
],
)
),
Positioned(
top: 0.0,
left: 0.0,
right: 0.0,
child: AppBar(// Add AppBar here only
backgroundColor: Colors.transparent,
elevation: 0.0,
title: Text(
widget.user.name.toString(),
style: const TextStyle(
letterSpacing: 0.0,
fontSize: 20.0,
),
),
),
),
],
),
);
}
}
P/s: sr im not really good at English to describe it correctly
Label will be visible if you focus on the TextField or TextField has content. If what you mean is keeping the label always be visible, you can add floatingLabelBehavior: FloatingLabelBehavior.always on InputDecoration.
import 'dart:core';
import 'package:flutter/material.dart';
import 'package:login_sample/models/user.dart';
class EmployeeProfile extends StatefulWidget {
const EmployeeProfile({Key? key, required this.user}) : super(key: key);
final User user;
#override
_EmployeeProfileState createState() => _EmployeeProfileState();
}
class _EmployeeProfileState extends State<EmployeeProfile> {
late String name = '';
late String email = '';
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.centerLeft,
end: Alignment.bottomCenter,
colors: [Colors.blue, Colors.blue])),
height: MediaQuery.of(context).size.height * 0.3
),
Card(
elevation: 20.0,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50),
topRight: Radius.circular(50),
),
),
margin: const EdgeInsets.only(left: 0.0, right: 0.0, top: 100.0),
child: ListView(
children: <Widget>[
SizedBox(
child: TextField(
autofocus: true,
onChanged: (val){
name = val;
},
decoration: InputDecoration(
contentPadding: const EdgeInsets.all(10.0),
labelText: 'Employee Name',
hintText: widget.user.name,
// add here
floatingLabelBehavior: FloatingLabelBehavior.always
labelStyle: const TextStyle(
color: Color.fromARGB(255, 107, 106, 144),
fontSize: 14,
fontWeight: FontWeight.w500,
),
border: OutlineInputBorder(
borderSide: const BorderSide(color: Color.fromARGB(255, 107, 106, 144), width: 2),
borderRadius: BorderRadius.circular(10),
),
),
),
width: 150.0,
),
SizedBox(
child: TextField(
autofocus: true,
onChanged: (val){
email = val;
},
decoration: InputDecoration(
contentPadding: const EdgeInsets.all(10.0),
labelText: 'Employee Email',
hintText: widget.user.email,
// add here
floatingLabelBehavior: FloatingLabelBehavior.always
labelStyle: const TextStyle(
color: Color.fromARGB(255, 107, 106, 144),
fontSize: 14,
fontWeight: FontWeight.w500,
),
border: OutlineInputBorder(
borderSide: const BorderSide(color: Color.fromARGB(255, 107, 106, 144), width: 2),
borderRadius: BorderRadius.circular(10),
),
),
),
width: 150.0,
),
TextButton(
onPressed: (){
print(widget.user.name);
print(widget.user.email);
setState(() {
widget.user.name = name;
widget.user.email = email;
});
},
child: const Text('Save'),
),
],
)
),
Positioned(
top: 0.0,
left: 0.0,
right: 0.0,
child: AppBar(// Add AppBar here only
backgroundColor: Colors.transparent,
elevation: 0.0,
title: Text(
widget.user.name.toString(),
style: const TextStyle(
letterSpacing: 0.0,
fontSize: 20.0,
),
),
),
),
],
),
);
}
}
Try below code hope its helpful to you. add your ListView() inside Padding
Padding(
padding: EdgeInsets.all(20),
child: ListView(
children: <Widget>[
SizedBox(
child: TextField(
autofocus: true,
onChanged: (val) {},
decoration: InputDecoration(
contentPadding: const EdgeInsets.all(10.0),
labelText: 'Employee Name',
hintText: 'widget.user.name',
labelStyle: const TextStyle(
color: Color.fromARGB(255, 107, 106, 144),
fontSize: 14,
fontWeight: FontWeight.w500,
),
border: OutlineInputBorder(
borderSide: const BorderSide(
color: Color.fromARGB(255, 107, 106, 144),
width: 2),
borderRadius: BorderRadius.circular(10),
),
),
),
width: 150.0,
),
SizedBox(
height: 20,
),
SizedBox(
child: TextField(
autofocus: true,
onChanged: (val) {},
decoration: InputDecoration(
contentPadding: const EdgeInsets.all(10.0),
labelText: 'Employee Email',
hintText: 'widget.user.email',
labelStyle: const TextStyle(
color: Color.fromARGB(255, 107, 106, 144),
fontSize: 14,
fontWeight: FontWeight.w500,
),
border: OutlineInputBorder(
borderSide: const BorderSide(
color: Color.fromARGB(255, 107, 106, 144),
width: 2),
borderRadius: BorderRadius.circular(10),
),
),
),
width: 150.0,
),
TextButton(
onPressed: () {},
child: const Text('Save'),
),
],
),
),
Your Screen->