Last active
December 8, 2020 23:38
-
-
Save VB10/a28f7c4baa7e0260a4f68398b6059f14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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