title: NoSuchMethodError: The method '+' was called on null. Receiver: null Tried calling: +(" ")
body: <p>I'm fetching data from the server, with success. But in my app, I want one-time login, in my case when I log in to my app then I can logged in successfully but when I clear my app from memory and then open it again then first it shows splash screen after that it will show this error: <code>"No Such Method Error: The method '+' was called on null. Receiver: null Tried calling: +(" ")."</code> I tried so many solutions from stack overflow but I can't get exact solution. </p>
  
  <p>Login </p>
  
  <pre><code>import 'dart:io';
  import 'package:bar_app/Home.dart';
  import 'package:bar_app/Methods/ALLResourceMethods.dart';
  import 'package:bar_app/Models/ALLModels.dart';
  import 'package:bar_app/SignUp1.dart';
  import 'package:flutter/material.dart';
  import 'package:flutter/services.dart';
  import 'package:shared_preferences/shared_preferences.dart';
  
  void main() {
    runApp(Login());
  }
  
  class Login extends StatefulWidget {
    @override
    _LoginPageState createState() =&gt; _LoginPageState();
  }
  
  class _LoginPageState extends State&lt;Login&gt; {
  
    TextEditingController getEmail = TextEditingController();
    TextEditingController getPassword = TextEditingController();
  
    Future&lt;bool&gt; _onWillPop() {
      exit(0);
    }
    @override
    void initState() {
      SystemChrome.setEnabledSystemUIOverlays([]);
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return WillPopScope(
        onWillPop: _onWillPop,
        child: Scaffold(
          body: Center(
            child: SingleChildScrollView(
              child: Center(
                child: Container(
                  child: Column(
                    children: &lt;Widget&gt;[
                      Container(
                        margin: EdgeInsets.only(top: 50),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: &lt;Widget&gt;[
                            Image(
                              image: new AssetImage("images/logoorg.png"),
                              height: 200,
                              width: 200,
                            ),
                            Text(
                              'Welcome back.',
                              style: TextStyle(
                                fontFamily: 'Poppins',
                                fontSize: 18,
                              ),
                            ),
                          ],
                        ),
                      ),
                      Container(
                        height: MediaQuery.of(context).size.height / 2,
                        width: MediaQuery.of(context).size.width,
                        padding: EdgeInsets.only(top: 62),
                        child: Column(
                          children: &lt;Widget&gt;[
                            Container(
                              width: MediaQuery.of(context).size.width / 1.3,
                              height: 50,
                              padding: EdgeInsets.only(
                                  top: 4, left: 16, right: 16, bottom: 4),
                              decoration:
                                  BoxDecoration(color: Colors.white, boxShadow: [
                                BoxShadow(color: Colors.black12, blurRadius: 5)
                              ]),
                              child: TextField(
                                controller: getEmail,
                                autofocus: true,
                                decoration: InputDecoration(
                                    border: InputBorder.none, hintText: 'Email'),
                              ),
                            ),
                            Container(
                              width: MediaQuery.of(context).size.width / 1.3,
                              height: 50,
                              margin: EdgeInsets.only(top: 20, bottom: 20),
                              padding: EdgeInsets.only(
                                  top: 4, left: 16, right: 16, bottom: 4),
                              decoration:
                                  BoxDecoration(color: Colors.white, boxShadow: [
                                BoxShadow(color: Colors.black12, blurRadius: 5)
                              ]),
                              child: TextField(
                                controller: getPassword,
                                decoration: InputDecoration(
                                    border: InputBorder.none,
                                    hintText: 'Password'),
                                obscureText: true,
                              ),
                            ),
                            Container(
                              height: 50,
                              width: MediaQuery.of(context).size.width / 1.3,
                              child: RaisedButton(
                                shape: RoundedRectangleBorder(
                                  borderRadius: BorderRadius.circular(25.0),
                                ),
                                child: Text(
                                  'Login',
                                  style: TextStyle(fontFamily: 'Poppins'),
                                ),
                                textColor: Colors.white,
                                onPressed: () {
                                  setState(() {
                                   Login1.SignIn(getEmail.toString(),getPassword.toString(), context);
                                  });
                                },
                                color: Colors.orange,
                                padding: EdgeInsets.symmetric(
                                    horizontal: 8.0,
                                    vertical: 5.0), // gives padding to the button
                              ),
                            ),
                            Align(
                              alignment: Alignment.center,
                              child: Padding(
                                padding: const EdgeInsets.only(top: 20),
                                child: new GestureDetector(
                                  onTap: () {
                                    Navigator.push(
                                      context,
                                      MaterialPageRoute(
                                          builder: (context) =&gt; SignUp1()),
                                    );
                                  },
                                  child: new Text(
                                    "SIGN UP",
                                    style: TextStyle(
                                        fontFamily: 'Poppins',
                                        fontWeight: FontWeight.bold,
                                        fontSize: 15),
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ),
        ),
      );
    }
  }
  
  API Calling  method here I set shared preference data
  
  class Login1 {
    static Future&lt;LoginModel&gt; SignIn(
        String email, String password, context) async {
      var url = 'https://bruyou.project-demo.info/api/V1/customer/login';
      Map data = {
        "email": email,
        "password": password,
      };
      var body = json.encode(data);
      var response = await http.post(url,
          headers: {"Content-Type": "application/json"}, body: body);
      final responseJson = json.decode(response.body);
  
      if (responseJson["status"] == "error") {
        Navigator.of(context).pushAndRemoveUntil(
            MaterialPageRoute(builder: (context) =&gt; Login()),
            (Route&lt;dynamic&gt; route) =&gt; false);
      } else {
        var dataModel = LoginModel.fromJson(responseJson);
        SharedPreferences prefs = await SharedPreferences.getInstance();
        prefs.setString("id", dataModel.successData.id.toString());
        prefs.setString("token", dataModel.successData.rememberToken);
        prefs.setString("fn", dataModel.successData.firstName);
        prefs.setString("ln", dataModel.successData.lastName);
        prefs.setString("img", dataModel.successData.profileImage);
        prefs.setString("pn", dataModel.successData.phoneNumber);
        prefs.setString("isTrue", "true");
        Navigator.of(context).push(
          MaterialPageRoute(
            builder: (context) =&gt; Home(
              pn: dataModel.successData.phoneNumber,
              img: dataModel.successData.profileImage,
              fn: dataModel.successData.firstName,
            ),
          ),
        );
      }
    }
  }
  
  Splash screen code
  
  import 'package:bar_app/Home.dart';
  import 'package:flutter/material.dart';
  import 'package:flutter/services.dart';
  import 'package:shared_preferences/shared_preferences.dart';
  
  import 'Login.dart';
  import 'dart:async';
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext contextP) {
      return MaterialApp(debugShowCheckedModeBanner: false, home: splash());
    }
  }
  
  class splash extends StatefulWidget {
    @override
    _SplashScreenState createState() =&gt; _SplashScreenState();
  }
  
  class _SplashScreenState extends State&lt;splash&gt; {
    var CheckToken = null;
    var Check = null;
  
    oneTime() async{
      SharedPreferences Preference = await SharedPreferences.getInstance();
      var Check = Preference.getString("isTrue");
      var fn= Preference.getString("fn");
      //var ln= Preference.getString("ln");
      var img= Preference.getString("img");
      var pn= Preference.getString("pn");
      print("fnnnn"+fn);
      if (Check == "true") {
        Timer(
          Duration(seconds: 5),
          () =&gt; Navigator.of(context).push(
            MaterialPageRoute(builder: (BuildContext context) =&gt; Home(fn: fn,img: img,pn:pn)),
          ),
        );
      } else {
        Timer(
          Duration(seconds: 5),
          () =&gt; Navigator.of(context).push(
            MaterialPageRoute(builder: (BuildContext context) =&gt; Login()),
          ),
        );
      }
    }
  
    @override
    void initState() {
      oneTime();
      SystemChrome.setEnabledSystemUIOverlays([]);
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        backgroundColor: Colors.white,
        body: Center(
          child: SingleChildScrollView(
            padding: const EdgeInsets.all(8.0),
            child: Center(
              child: Container(
                child: Center(
                  child: Image(
                    image: new AssetImage("images/photofunky.gif"),
                  ),
                ),
              ),
            ),
          ),
        ),
      );
    }
  }
  </code></pre>