I need to get all the data from the firestore database. I follow this way, https://stackoverflow.com/a/55865045/9139407
Future<Photography> getPhotography() {
Future<Photography> data = await db
.collection('photography')
.document('0yUc5QBGHNNq6WK9CyyF')
.setData(jsonDecode(jsonEncode(Photography(
[AllImages(["list"])],
"image_url",
"Shanika",
"image_url",
"lovely couple",
"Bhanuka"
))));
return data;
}
The error message is:
Unhandled Exception: type 'Future< void >' is not a subtype of type 'Future< Photography> '
Photography model class
import 'package:json_annotation/json_annotation.dart';
part 'Model.g.dart';
@JsonSerializable()
class Photography{
List<AllImages> all_images;
String couplePhoto;
String female;
String image_url;
String info;
String male;
Photography();
factory Photography.fromJson(Map<String, dynamic> json) => _$PhotographyFromJson(json);
Map<String,dynamic> toJson() => _$PhotographyToJson(this);
}
@JsonSerializable()
class AllImages {
final List<String> imageUrl;
AllImages(this.imageUrl);
factory AllImages.fromJson(Map<String, dynamic> json) => _$AllImagesFromJson(json);
Map<String,dynamic> toJson() => _$AllImagesToJson(this);
}
And next problem is, how to add to these data on bloc sink?
Sink<Photography> get inFirestore => _firestoreController.sink;
something like this? but error is, The argument type 'Future' can't be assigned to the parameter type 'Photography'
final result = db.getPhotography();
inFirestore.add(result);