3

I am using where clause to filter out what user is typing with the api result but I am getting Error: Unexpected null value. I am using a post request.

my code with error

this is my model :-

   class SearchSquad {
  SearchSquad({
    required this.count,
    required this.res,
  });

  int count;
  List<Re> res;

  factory SearchSquad.fromJson(Map<String, dynamic> json) => SearchSquad(
        count: json["count"],
        res: List<Re>.from(json["res"].map((x) => Re.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "count": count,
        "res": List<dynamic>.from(res.map((x) => x.toJson())),
      };
}

class Re {
  Re({        
    required this.squadName,       
    required this.profimgname,
    required this.profimgurl,
    
  });

  String squadId;
  String squadName;

My error

  • the `searchSquad` variable is probably null, can you show all of your code? preferably not as a screenshot? – h8moss Nov 21 '22 at 03:32

0 Answers0