Skip to content

Instantly share code, notes, and snippets.

@VB10
Last active December 8, 2020 23:38
Show Gist options
  • Save VB10/a28f7c4baa7e0260a4f68398b6059f14 to your computer and use it in GitHub Desktop.
Save VB10/a28f7c4baa7e0260a4f68398b6059f14 to your computer and use it in GitHub Desktop.
class PointsCompleted extends PointsState {
final List<Coordinate> coordinates;
final int selectedItem;
PointsCompleted(this.coordinates, {this.selectedItem});
PointsCompleted copyWith({
List<Coordinate> coordinates,
int selectedItem,
}) {
return PointsCompleted(coordinates ?? this.coordinates,
selectedItem: selectedItem ?? this.selectedItem);
}
}
class PointsCubit extends Cubit<PointsState> {
Future<void> fetchPoints() async { }
Future<void> fetchPointsCustomMarker() async {
final responseItems = await mapService.getAllPoints();
if (responseItems != null)
emit(PointsCompleted(responseItems, selectedItem: 0));
else
emit(PointsError("Data Not Found"));
}
void changeSelectedCoordinate(int index, List<Coordinate> items) {
final _state = state as PointsCompleted;
emit(_state.copyWith(selectedItem: index));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment