deletePlaceByFilePath static method

Future<bool> deletePlaceByFilePath(
  1. String filePath,
  2. BuildContext context,
  3. Widget returnWidget
)

Delete a place by its individual file path. This is called when a user deletes place_xxx.json from the file browser. It will also remove the place from the main places.json file.

Implementation

static Future<bool> deletePlaceByFilePath(
  String filePath,
  BuildContext context,
  Widget returnWidget,
) async {
  // Extract place ID from file path like "place_abc123.json"
  final fileName = filePath.split('/').last;
  final match = RegExp(r'^place_(.+)\.json$').firstMatch(fileName);
  if (match == null) return false;

  final placeId = match.group(1)!;
  return deletePlace(placeId, context, returnWidget);
}