Flutter - Google Maps inside reorderable List

173 Views Asked by At

I am using the Reorderables Package to create a reorder-able List with the GoogleMaps widget inside. On long press to reorder the tiles, the GoogleMaps widget refreshes and the tile is not selected anymore. onReorderStarted of ReorderableColumn is triggered but onNoReorder is triggered immediately after.

Here is is a code Example to reproduce the problem:

class MapTest extends StatefulWidget {
  const MapTest({Key key}) : super(key: key);

  @override
  State<MapTest> createState() => _MapTestState();
}

class _MapTestState extends State<MapTest> {
  List<int> list = List.generate(2, (index) => index);

  @override
  Widget build(BuildContext context) {
    return ReorderableColumn(
      onReorder: (int oldIndex, int newIndex) {},
      children: list
          .asMap()
          .map((key, link) => MapEntry(
                key,
                Map(
                  key: ValueKey(key),
                ),
              ))
          .values
          .toList(),
    );
  }
}

class Map extends StatelessWidget {
  const Map({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AbsorbPointer(
      child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: AspectRatio(
          aspectRatio: 370 / 138,
          child: GoogleMap(
            initialCameraPosition: CameraPosition(
              target: LatLng(36, 48),
              zoom: 12.0,
            ),
          ),
        ),
      ),
    );
  }
}

I have tried the following:

  • Make Map constant
  • Show different widget on buildDraggableFeedback
0

There are 0 best solutions below