title: Unhandled Exception: NoSuchMethodError: The method 'split' was called on null
body: <p>This is a simple contact app that allows to add view and edit contact details of individuals. The error here can't be totally understood by me.</p>
  
  <pre><code> class ViewContact extends StatefulWidget {
    final String id;
    ViewContact(this.id);
    @override
    _ViewContactState createState() =&gt; _ViewContactState(this.id);
  }
  
  class _ViewContactState extends State&lt;ViewContact&gt; {  
    DatabaseReference _databaseReference = FirebaseDatabase.instance.reference();
     String mascot = "https://learncodeonline.in/mascot.png";
     String id; 
    _ViewContactState(id);
    Contact _contact;                                   
    bool isLoading = true;
  
    getContact(id) async {
       _databaseReference.child(id).onValue.listen ((event){
        setState(()  {
          print(event.snapshot);
          _contact =   Contact.fromSnapshot(event.snapshot);
          isLoading = false;
          print(_contact.lastName);
        });
      });
    }
    @override
    void initState(){
      super.initState();
      this.getContact(id);
    }
  
    callAction(String number) async{
      String url = 'tel: $number';
      if (await canLaunch(url)){
        await launch(url);
      }
      else {
        throw 'Could call $number';
      }
    }
    smsAction(String number) async{
      String url ='sms: $number';
      if (await canLaunch(url)){
        await launch(url);
      }
      else {
        throw 'lol';
      }
    }
    navigateToLastScreen(){
      Navigator.pop(context);
    }
    navigateToEditScreen(id){
      Navigator.push(context, MaterialPageRoute(builder: (context){
        return EditContact();
      }));
    }
  </code></pre>
  
  <p>The error shown is below. Can the error be because of the id variable? (Pretty new towards Flutter).</p>
  
  <pre><code>[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: NoSuchMethodError: The method 'split' was called on null.
  E/flutter (12369): Receiver: null
  E/flutter (12369): Tried calling: split("/")
  E/flutter (12369): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
  E/flutter (12369): #1      DatabaseReference.child (package:firebase_database/src/database_reference.dart:24:58)
  E/flutter (12369): #2      _ViewContactState.getContact (package:firebase_authentication/screens/view_contact.dart:24:25)
  E/flutter (12369): &lt;asynchronous suspension&gt;
  E/flutter (12369): #3      _ViewContactState.initState (package:firebase_authentication/screens/view_contact.dart:36:10)
  E/flutter (12369): #4      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4033:58)
  E/flutter (12369): #5      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
  E/flutter (12369): #6      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
  E/flutter (12369): #7      Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
  E/flutter (12369): #8      SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5092:14)
  E/flutter (12369): #9      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
  E/flutter (12369): #10     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
  E/flutter (12369): #11     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16)
  E/flutter (12369): #12     Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
  E/flutter (12369): #13     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5)
  E/flutter (12369): #14     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
  E/flutter (12369): #15     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
  E/flutter (12369): #16     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
  E/flutter (12369): #17     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5092:14)
  E/flutter (12369): #18     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
  E/flutter (12369): #19     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
  E/flutter (12369): #20     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5092:14)
  E/flutter (12369): #21     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
  E/flutter (12369): #22     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
  E/flutter (12369): #23     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5092:14)
  E/flutter (12369): #24     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
  E/flutter (12369): #25     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
  E/flutter (12369): #26     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5092:14)
  E/flutter (12369): #27     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
  E/flutter (12369): #28     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
  E/flutter (12369): #29     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16)
  E/flutter (12369): #30     Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
  E/flutter (12369): #31     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5)
  E/flutter (12369): #32     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4053:11)
  E/flutter (12369): #33     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
  E/flutter (12369): #34     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
  E/flutter (12369): #35     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
  E/flutter (12369): #36     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16)
  E/flutter (12369): #37     Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
  E/flutter (12369): #38     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5)
  E/flutter (12369): #39     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
  E/flutter (12369): #40     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
  E/flutter (12369): #41     Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
  E/flutter (12369): #42     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16)
  E/flutter (12369): #43     Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
  E/flutter (12369): #44     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart
  </code></pre>
  
  <p>this is the stack over flow error i am facing. Well same as the previous error , i can't figure out this one too :(</p>
  
  <pre><code>I/flutter ( 4594): The following StackOverflowError was thrown building ViewContact(dirty, state:
  I/flutter ( 4594): _ViewContactState#4e21c):
  I/flutter ( 4594): Stack Overflow
  I/flutter ( 4594):
  I/flutter ( 4594): When the exception was thrown, this was the stack:
  I/flutter ( 4594): #0      Contact.email (package:firebase_authentication/model/contact.dart:25:4)
  I/flutter ( 4594): #1      Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #2      Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #3      Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #4      Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #5      Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #6      Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #7      Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #8      Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #9      Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #10     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #11     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #12     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #13     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #14     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #15     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #16     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #17     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #18     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #19     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #20     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #21     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #22     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #23     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #24     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #25     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #26     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #27     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #28     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #29     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #30     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #31     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #32     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #33     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #34     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #35     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #36     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #37     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #38     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #39     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #40     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #41     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #42     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #43     Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): ...
  I/flutter ( 4594): ...
  I/flutter ( 4594): #59478  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59479  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59480  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59481  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59482  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59483  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59484  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59485  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59486  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59487  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59488  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59489  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59490  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59491  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59492  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59493  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59494  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59495  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59496  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59497  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59498  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59499  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59500  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59501  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59502  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59503  Contact.email (package:firebase_authentication/model/contact.dart:25:29)
  I/flutter ( 4594): #59504  _ViewContactState.build (package:firebase_authentication/screens/view_contact.dart:179:40)
  I/flutter ( 4594): #59505  StatefulElement.build (package:flutter/src/widgets/framework.dart:4012:27)
  I/flutter ( 4594): #59506  ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3924:15)
  I/flutter ( 4594): #59507  Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
  I/flutter ( 4594): #59508  BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2340:33)
  I/flutter ( 4594): #59509  _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding&amp;ServicesBinding&amp;SchedulerBinding&amp;PaintingBinding&amp;SemanticsBinding&amp;RendererBinding&amp;WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:700:20)
  I/flutter ( 4594): #59510  _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding&amp;ServicesBinding&amp;SchedulerBinding&amp;PaintingBinding&amp;SemanticsBinding&amp;RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:285:5)
  I/flutter ( 4594): #59511  _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding&amp;ServicesBinding&amp;SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1016:15)
  I/flutter ( 4594): #59512  _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding&amp;ServicesBinding&amp;SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:958:9)
  I/flutter ( 4594): #59513  _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding&amp;ServicesBinding&amp;SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:874:5)
  I/flutter ( 4594): #59517  _invoke (dart:ui/hooks.dart:236:10)
  I/flutter ( 4594): #59518  _drawFrame (dart:ui/hooks.dart:194:3)
  I/flutter ( 4594): (elided 3 frames from package dart:async)
  </code></pre>
  
  <p>================================================================================
  This is the Widget Associated with the View Contact state. </p>
  
  <pre><code>@override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text("Add Contact"),
          centerTitle: true,
          leading: IconButton(
            icon: Icon(Icons.arrow_back_ios),
            onPressed: (){navigateToLastScreen(context);},
          ),
        ),
        body: Container(
          padding: EdgeInsets.all(20.0),
          child: ListView(
            children: &lt;Widget&gt;[
              Container(
                margin: EdgeInsets.only(top: 20.0),
                child: GestureDetector(
                  onTap: (){
                    this.pickImage();
                  },
                  child: Center(
                    child: Container(
                      width: 130.0,
                      height: 130.0,
  
                      decoration: BoxDecoration(
                        border: Border.all(color: Colors.white, width: 4.0),
                        shape: BoxShape.circle,
  
                        image: DecorationImage(
                          fit: BoxFit.fill,
                          image: _photoUrl=="empty"? NetworkImage("https://i.imgur.com/BoN9kdC.png"): NetworkImage(_photoUrl),
                        ),
                      ),
                    ),
                  ),
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 40.0),
                child: TextField(
  
                  onChanged: (value){
                    setState(() {
                     _firstName = value; 
                    });
                  },
                  decoration: InputDecoration(
                    labelText: 'First Name',
                    border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(10.0),
                    ),
                  ),
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 20.0),
                child: TextField(
  
                  onChanged: (value){
                    setState(() {
                     _lastName = value; 
                    });
                  },
                  decoration: InputDecoration(
                    labelText: 'Last Name',
                    border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(10.0),
                    ),
                  ),
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 20.0),
                child: TextField(
                  onChanged: (value){
                    setState(() {
                     _email = value; 
                    });
                  },
                  decoration: InputDecoration(
                    labelText: 'E-mail',
                    border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(10.0),
                    ),
                  ),
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 20.0),
                child: TextField(
  
                  onChanged: (value){
                    setState(() {
                     _phone = value; 
                    });
                  },
                  decoration: InputDecoration(
                    labelText: 'Phone',
                    border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(10.0),
                    ),
                  ),
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 20.0),
                child: TextField(
  
                  onChanged: (value){
                    setState(() {
                     _address = value; 
                    });
                  },
                  decoration: InputDecoration(
                    labelText: 'Address',
  
                    border: OutlineInputBorder(
                      borderRadius: BorderRadius.circular(10.0),
                    ),
                  ),
                ),
              ),
              //save the shit
              Container(
                padding: EdgeInsets.only(top: 20.0),
                child: RaisedButton(
                  color: Colors.teal,
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)),
                  padding: EdgeInsets.fromLTRB(50, 10, 50, 10),
                  onPressed: (){
                    saveContact(context);
                  },
                  child: Text("ADD CONTACT", style: TextStyle(color: Colors.white, fontSize: 20.0, fontWeight: FontWeight.bold),),
                ),
              ),
            ],
          ),
        ),
      );
    }
  }
  </code></pre>