Reputation: 35
someone help me plz. i can solve it .please solve this error .why show null is not subtype please solve this error
its textfiled code now plz solve this code.here we using textfiled code this called should called bulder
setDataTextField(data) {
Column(
children: [
TextField(
decoration: InputDecoration(fillColor: Colors.blue),
controller: _nameController =
TextEditingController(text: data['name']),
),
TextField(
decoration: InputDecoration(fillColor: Colors.blue),
controller: _phoneController =
TextEditingController(text: data['contract']),
),
TextField(
decoration: InputDecoration(fillColor: Colors.blue),
controller: _dobController = TextEditingController(text: data['dob']),
),
TextField(
decoration: InputDecoration(fillColor: Colors.blue),
controller: _genderController =
TextEditingController(text: data['gender']),
),
TextField(
decoration: InputDecoration(fillColor: Colors.blue),
controller: _ageController = TextEditingController(text: data['age']),
),
SizedBox(
height: 40.h,
),
SizedBox(
height: 56.h,
width: 1.sw,
child: ElevatedButton(
onPressed: () {},
child: Text(
'UPDATE YOUR PROFILE',
style: TextStyle(fontSize: 18.sp),
),
),
),
],
);
}
its stream builder code
StreamBuilder(
stream: FirebaseFirestore.instance
.collection('users-data-form')
.doc(FirebaseAuth.instance.currentUser!.email)
.snapshots(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
var data = snapshot.data;
return setDataTextField(data);
},
),
Upvotes: 0
Views: 2109
Reputation: 652
setDataTextField
should have return
.
change it to this.
Widget SetDataTextField(dynamic data) {
return Column(
children: [...]);
and inside StreamBuilder
you should wrap your code inside this condition:
if (snapshot.hasData) {YourCode}
StreamBuilder(
stream: FirebaseFirestore.instance
.collection('users-data-form')
.doc(FirebaseAuth.instance.currentUser!.email)
.snapshots(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if(snapshot.hasData) {
var data = snapshot.data;
return setDataTextField(data);
}
},
),
Upvotes: 2
Reputation: 4567
maybe u forgot the return
left of column
in the first line of your method?
Upvotes: 0