Search code examples
flutterdarthttpdart-null-safety

Flutter 'get method was call on nul' Error


I was doing news app on Flutter and I was working with non-null safety because I was doing the older project.But then I started getting errors and I change my version to make the app with null-safety. Anyways, I changed the version re-edit the code I was thinking that I did great work but suddenly I'm getting this error right now. How can I fix this?


Solution

  • in your import do like below.

    import 'package:http/http.dart' as http;
    

    call your response like below...

    http.Response response = await http.get(
          endPointUrl,
        );
    

    As of my knowledge we cant declare http with var....thats why its shows error...above code will work