Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

type 'null' is not subtype of type "widget"

someone help me plz. i can solve it .please solve this error .why show null is not subtype please solve this error enter image description here

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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);
              }
            },
          ),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading