Home > Software engineering >  Flutter: problem in fetching data: type 'Null' is not a subtype of type 'String'
Flutter: problem in fetching data: type 'Null' is not a subtype of type 'String'

Time:10-06

I am trying to fetch google book search api data. enter image description here

I think I have same issue with this. enter image description here

my code: https://github.com/kangsudal/millie/blob/7f1f912c5a0eba0fe09de67c1c729be73b660da1/lib/screens/0_today/tab_widdget/tab_now.dart#L62

how to get data?

CodePudding user response:

because title and author is not inside item object, it inside volumeInfo, so you much change fromJson method of your Book class to

factory Book.fromJson(Map json) {
    return Book(
      id: json['id'],
      title: json['volumeInfo']['title'],
      authors: json['volumeInfo']['author'],
    );
  }
  • Related