title: Flutter: The method '/' was called on null. Receiver: null Tried calling: /(1080.0)
body: <p>I'm getting this error since I've used <strong>Media Query</strong> for setting up Responsive UI. Below is the error that I'm getting in the terminal.</p>
  
  <p><a href="https://i.stack.imgur.com/xR3EY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xR3EY.png" alt="enter image description here"></a></p>
  
  <p>I don't know which method calling is returning null according to Dart. Because I'm navigating to new Screen via Raised Button and it is showing this error on <strong>Constructor of Widget/Class</strong> that I called on <em>onPressed</em> of the button</p>
  
  <p>Here is the code of my class from where I'm navigating to new Screen of Doctor's Login:</p>
  
  <pre><code>import 'dart:io';
  import 'package:flutter/cupertino.dart';
  import 'package:flutter/material.dart';
  import 'package:medkit/animations/fadeAnimation.dart';
  import 'package:medkit/animations/bottomAnimation.dart';
  import 'package:medkit/doctor/doctorLogin.dart';
  import 'package:medkit/doctor/doctorPanel.dart';
  import 'aboutUs.dart';
  
  class UserType extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      double width = MediaQuery.of(context).size.width;
      double height = MediaQuery.of(context).size.height;
  
      Future&lt;bool&gt; _onWillPop() async {
        return (await showDialog(
          context: context,
          builder: (context) =&gt; new AlertDialog(
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(12)
            ),
            title: new Text(
              "Exit Application",
              style: TextStyle(fontWeight: FontWeight.bold),
            ),
            content: new Text("Are You Sure?"),
            actions: &lt;Widget&gt;[
              // usually buttons at the bottom of the dialog
              FlatButton(
                shape: StadiumBorder(),
                color: Colors.white,
                child: new Text(
                  "Close",
                  style: TextStyle(color: Colors.blue),
                ),
                onPressed: () {
                  Navigator.of(context).pop();
                },
              ),
              FlatButton(
                shape: StadiumBorder(),
                color: Colors.white,
                child: new Text(
                  "Yes",
                  style: TextStyle(color: Colors.red),
                ),
                onPressed: () {
                  exit(0);
                },
              ),
            ],
          ),
        )) ??
            false;
      }
  
      return WillPopScope(
        onWillPop: _onWillPop,
        child: Scaffold(
          body: SafeArea(
            child: Padding(
              padding: EdgeInsets.symmetric(horizontal: width * 0.04),
              child: Column(
                children: &lt;Widget&gt;[
                  SizedBox(
                    height: height * 0.08,
                  ),
                  FadeAnimation(
                    0.3,
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: &lt;Widget&gt;[
                        Text(
                          'Category',
                          style: TextStyle(color: Colors.black, fontSize: 30),
                        ),
                        GestureDetector(
                          onTap: () =&gt; _exitAlert(context),
                          child: Icon(
                            Icons.exit_to_app,
                            size: height * 0.04,
                          ),
                        )
                      ],
                    ),
                  ),
                  SizedBox(height: height * 0.09),
                  Column(
                    children: &lt;Widget&gt;[
                      FadeAnimation(
                        0.4,
                        CircleAvatar(
                          backgroundColor: Colors.black.withOpacity(0.2),
                          radius: height * 0.075,
                          child: Image(image: AssetImage("assets/doctor.png")),
                        ),
                      ),
                      WidgetAnimator(patDocBtn('Doctor', context)),
                      SizedBox(
                        height: height * 0.1,
                      ),
                      FadeAnimation(
                        0.4,
                        CircleAvatar(
                          backgroundColor: Colors.black.withOpacity(0.2),
                          radius: height * 0.075,
                          child: Image(image: AssetImage("assets/patient.png")),
                        ),
                      ),
                      WidgetAnimator(patDocBtn('Patient', context)),
                      SizedBox(height: height * 0.13,),
                      GestureDetector(
                        onTap: () =&gt; Navigator.push(context, new MaterialPageRoute(builder: (context) =&gt; AboutUs())),
                        child: Column(
                          children: &lt;Widget&gt;[
                            Text('Version', style: TextStyle(fontWeight: FontWeight.bold),),
                            Text('V 0.1', style: TextStyle(fontSize: 12),)
                          ],
                        ),
                      ),
                      SizedBox(height: 5,)
                    ],
                  )
                ],
              ),
            ),
          ),
        ),
      );
  
    }
  
    Widget patDocBtn(String categoryText, context) {
      return Container(
        width: MediaQuery.of(context).size.width * 0.5,
        child: RaisedButton(
          onPressed: () {
            if (categoryText == 'Doctor') {
              Navigator.pushNamed(context, 'DoctorLogin');
            } else {
              Navigator.pushNamed(context, 'PatientLogin');
            }
          },
          color: Colors.white,
          child: Text("I am " + categoryText),
          shape: StadiumBorder(),
        ),
      );
    }
  
    _exitAlert(context) {
      showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(12)
            ),
            title: new Text(
              "Exit Application",
              style: TextStyle(fontWeight: FontWeight.bold),
            ),
            content: new Text("Are You Sure?"),
            actions: &lt;Widget&gt;[
              // usually buttons at the bottom of the dialog
              FlatButton(
                color: Colors.white,
                child: new Text(
                  "Close",
                  style: TextStyle(color: Colors.blue),
                ),
                onPressed: () {
                  Navigator.of(context).pop();
                },
              ),
              FlatButton(
                color: Colors.white,
                child: new Text(
                  "Yes",
                  style: TextStyle(color: Colors.red),
                ),
                onPressed: () {
                  exit(0);
                },
              ),
            ],
          );
        },
      );
    }
  }
  
  </code></pre>
  
  <p>And here is <strong>Doctor's Login</strong> class code</p>
  
  <pre><code>import 'dart:math';
  
  import 'package:cloud_firestore/cloud_firestore.dart';
  import 'package:firebase_auth/firebase_auth.dart';
  import 'package:flutter/cupertino.dart';
  import 'package:flutter/material.dart';
  import 'package:flutter_screenutil/flutter_screenutil.dart';
  import 'package:google_fonts/google_fonts.dart';
  import 'package:google_sign_in/google_sign_in.dart';
  import 'package:medkit/animations/fadeAnimation.dart';
  import 'package:medkit/animations/bottomAnimation.dart';
  import 'package:medkit/doctor/doctorPanel.dart';
  import 'package:medkit/otherWidgetsAndScreen/backBtn.dart';
  import 'package:medkit/otherWidgetsAndScreen/imageAvatar.dart';
  import 'package:toast/toast.dart';
  
  class DoctorLogin extends StatefulWidget {
    @override
    _DoctorLoginState createState() =&gt; _DoctorLoginState();
  }
  
  class _DoctorLoginState extends State&lt;DoctorLogin&gt; {
    final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
    final GoogleSignIn _googleSignIn = new GoogleSignIn();
  
    Future&lt;FirebaseUser&gt; _signIn(BuildContext context) async {
      final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
      final GoogleSignInAuthentication googleAuth =
          await googleUser.authentication;
  
      final AuthCredential credential = GoogleAuthProvider.getCredential(
          idToken: googleAuth.idToken, accessToken: googleAuth.accessToken);
  
      FirebaseUser userDetails =
          await _firebaseAuth.signInWithCredential(credential);
      ProviderDoctorDetails providerInfo =
          new ProviderDoctorDetails(userDetails.providerId);
  
      List&lt;ProviderDoctorDetails&gt; providerData =
          new List&lt;ProviderDoctorDetails&gt;();
      providerData.add(providerInfo);
  
      DoctorDetails details = new DoctorDetails(
        userDetails.providerId,
        userDetails.displayName,
        userDetails.photoUrl,
        userDetails.email,
        providerData,
      );
  
      Navigator.push(
          context,
          new MaterialPageRoute(
              builder: (context) =&gt; DoctorPanel(
                    detailsUser: details,
                  )));
  
      return userDetails;
    }
  
    @override
    Widget build(BuildContext context) {
  
      final nameTextFieldController = TextEditingController();
      final nameTextField = TextField(
        keyboardType: TextInputType.text,
        autofocus: false,
        maxLength: 30,
        textInputAction: TextInputAction.next,
        onSubmitted: (_) =&gt; FocusScope.of(context).nextFocus(),
        controller: nameTextFieldController,
        decoration: InputDecoration(
            fillColor: Colors.black.withOpacity(0.07),
            filled: true,
            labelText: 'Enter Name',
            prefixIcon: Icon(Icons.person),
            border: OutlineInputBorder(
                borderRadius: const BorderRadius.all(const Radius.circular(20)))),
      );
  
      final phNumberTextController = TextEditingController();
      final phoneTextField = TextField(
        keyboardType: TextInputType.phone,
        autofocus: false,
        maxLength: 11,
        controller: phNumberTextController,
        textInputAction: TextInputAction.next,
        onSubmitted: (_) =&gt; FocusScope.of(context).nextFocus(),
        decoration: InputDecoration(
          filled: true,
          fillColor: Colors.black.withOpacity(0.07),
          labelText: 'Enter Number',
          prefixIcon: Icon(Icons.phone),
          border: new OutlineInputBorder(
            borderRadius: const BorderRadius.all(const Radius.circular(20)),
          ),
        ),
      );
  
      final cnicTextController = TextEditingController();
      final cnicTextField = TextFormField(
        keyboardType: TextInputType.number,
        autofocus: false,
        maxLength: 13,
        controller: cnicTextController,
        decoration: InputDecoration(
            filled: true,
            fillColor: Colors.black.withOpacity(0.07),
            labelText: 'Enter CNIC',
            prefixIcon: Icon(Icons.card_membership),
            border: OutlineInputBorder(borderRadius: BorderRadius.circular(20))),
      );
  
      final double width = MediaQuery.of(context).size.width;
      final double height = MediaQuery.of(context).size.height;
      return GestureDetector(
        onTap: () {
          FocusScopeNode currentFocus = FocusScope.of(context);
          if (!currentFocus.hasPrimaryFocus) {
            currentFocus.unfocus();
          }
        },
        child: Scaffold(
            resizeToAvoidBottomPadding: false,
            body: SafeArea(
              child: Container(
                width: width,
                height: height,
                child: Stack(
                  children: &lt;Widget&gt;[
                    ImageAvatar(
                      assetImage: 'assets/bigDoc.png',
                    ),
                    Container(
                      width: width,
                      height: height,
                      margin: EdgeInsets.fromLTRB(width * 0.03, 0, width * 0.03, 0),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: &lt;Widget&gt;[
                          BackBtn(),
                          SizedBox(height: height * 0.05,),
                          Text(
                            "\t\tLogin",
                            style: GoogleFonts.abel(
                                fontSize: ScreenUtil.instance.setSp(35),
                                fontWeight: FontWeight.bold),
                          ),
                          SizedBox(
                            height: height * 0.05,
                          ),
                          WidgetAnimator(nameTextField),
                          WidgetAnimator(phoneTextField),
                          WidgetAnimator(cnicTextField),
                          SizedBox(height: height * 0.01,),
                          FadeAnimation(
                            1.5,
                            SizedBox(
                              width: width,
                              height: height * 0.07,
                              child: RaisedButton(
                                color: Colors.white,
                                shape: StadiumBorder(),
                                onPressed: () {
                                  if (nameTextFieldController.text != "" ||
                                      phNumberTextController.text != "" ||
                                      cnicTextController.text != "") {
                                    Firestore.instance
                                        .collection('doctorInfo')
                                        .document(nameTextFieldController.text)
                                        .setData({
                                      'cnic': cnicTextController.text,
                                      'phoneNumber': phNumberTextController.text,
                                    });
                                    _signIn(context)
                                        .then((FirebaseUser user) =&gt;
                                            print('Gmail Logged In'))
                                        .catchError((e) =&gt; print(e));
                                    nameTextFieldController.clear();
                                    cnicTextController.clear();
                                    phNumberTextController.clear();
                                  } else {
                                    Toast.show('Fields Cannot be Empty!', context,
                                        backgroundColor: Colors.red,
                                        gravity: Toast.CENTER,
                                        duration: Toast.LENGTH_SHORT);
                                  }
                                },
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: &lt;Widget&gt;[
                                    Image(
                                      image: AssetImage('assets/google.png'),
                                      height: ScreenUtil.instance.setHeight(35),
                                    ),
                                    SizedBox(width: ScreenUtil.instance.setWidth(15)),
                                    Text(
                                      'Login',
                                      style: TextStyle(
                                          letterSpacing: 2,
                                          fontWeight: FontWeight.bold,
                                          fontSize: ScreenUtil.instance.setSp(18)),
                                    )
                                  ],
                                ),
                              ),
                            ),
                          ),
                          SizedBox(height: height * 0.02,),
                          FadeAnimation(
                            2,
                            Text(
                              'You Will be asked Question regarding your Qualifications!', textAlign: TextAlign.center,
                              style: TextStyle(color: Colors.black.withOpacity(0.5),),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            )),
      );
    }
  }
  
  class DoctorDetails {
    final String providerDetails;
    final String userName;
    final String photoUrl;
    final String userEmail;
    final List&lt;ProviderDoctorDetails&gt; providerData;
  
    DoctorDetails(this.providerDetails, this.userName, this.photoUrl,
        this.userEmail, this.providerData);
  }
  
  class ProviderDoctorDetails {
    ProviderDoctorDetails(this.providerDetails);
  
    final String providerDetails;
  }
  
  </code></pre>