我使用以下代码在sqflite数据库中进行搜索
Future<Albums> getAlbumSearch([String search]) async {
var dbClient = await db;
// specify the column names you want in the result set
List<Map> maps =
await dbClient.rawQuery("SELECT * FROM $TABLE WHERE $TITLE LIKE '%${search}%' ");
Albums allAlbums = Albums();
List<Album> albums = [];
if (maps.length > 0) {
for (int i = 0; i < maps.length; i++) {
albums.add(Album.fromJson(maps[i]));
}
}
allAlbums.albums = albums;
return allAlbums;
}
但是它在应用程序中给了我这个错误:错误类型'String'不是强制类型转换中'num'类型的子类型
我该如何解决?
我的相册和相册课程
class Album {
Album();
num albumId;
num id;
String title;
String url;
String thumbnailUrl;
factory Album.fromJson(Map<String,dynamic> json) => _$AlbumFromJson(json);
Map<String, dynamic> toJson() => _$AlbumToJson(this);
}
class Albums {
Albums();
List<Album> albums;
factory Albums.fromJson(Map<String,dynamic> json) => _$AlbumsFromJson(json);
Map<String, dynamic> toJson() => _$AlbumsToJson(this);
}