Skip to content

Instantly share code, notes, and snippets.

@VB10
Last active December 8, 2020 23:56
Show Gist options
  • Save VB10/fb7f3b928177718470d3634dbb673b90 to your computer and use it in GitHub Desktop.
Save VB10/fb7f3b928177718470d3634dbb673b90 to your computer and use it in GitHub Desktop.
Positioned positionedPageView(
BuildContext context, PointsCompleted completed) {
return Positioned(
height: context.dynamicHeight(0.12),
bottom: 0,
right: 0,
left: -context.dynamicWidth(0.1),
child: PageView.builder(
onPageChanged: (value) {
context
.read<LineCubit>()
.changeMarker(value, completed.coordinates[value]);
},
itemCount: completed.coordinates.length,
controller: PageController(viewportFraction: 0.8),
itemBuilder: (context, index) =>
CoordinateCard(coordinate: completed.coordinates[index]),
),
);
}
Widget pointsList(PointsCompleted completed, BuildContext context) {
final coordinates = completed.coordinates;
return BlocConsumer<LineCubit, LineState>(
listener: (context, LineState state) {},
builder: (context, state) {
List<Marker> markers = [];
int selectedLines = 0;
if (state is GoogleMapsStateMarkers) {
markers = state.marrkers;
} else if (state is MapsMarkerChange) {
selectedLines = state.currentIndex;
markers = context.watch<LineCubit>().markers;
}
return GoogleMap(
onMapCreated: (controller) {
context
.read<LineCubit>()
.initMapControllerMarkers(controller, context, coordinates);
},
polylines: Set.from([polylineCreate(markers, selectedLines)]),
markers: Set.from(markers),
initialCameraPosition:
CameraPosition(target: coordinates.first.coordinate, zoom: 13),
);
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment