class DiscoverRemoteDataSourceImpl implements DiscoverRemoteDataSource { DiscoverRemoteDataSourceImpl(this._real); final FirebaseDatabase _real; @override Future<List<ShoeModel>> getShoes() async { try { final data = await _real.ref('product').child('products').once(); List<ShoeModel> shoes = []; for (int i = 0; i < data.snapshot.children.length; i++) { var shoe = data.snapshot.children.elementAt(i).value as Map<Object?, Object?>; Map<String, dynamic> shoeMap = {}; shoe.forEach((key, value) { shoeMap[key.toString()] = value; }); shoes.add(ShoeModel.fromMap( shoeMap)); // Pass the Map<String, dynamic> to ShoeModel.fromMap } return shoes; } catch (e) { throw CustomFirebaseException( message: e.toString(), code: 500, ); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)