Code Room
Vibe codingMediumvc-g245
Subject Ai code reviewLevel Mid–Senior~15 minCommon in Security · Code quality & review interviewsIndustries Software development

Question

An AI wrote this Flutter function to grab the user's location for a 'find nearby' feature. It works fine on the dev's phone where location is already granted, but testers report the app hangs forever or crashes when they tap the feature after denying the permission prompt. What's the bug and how would you catch it?

dart
Future<Position> getLocation() async {  await Geolocator.requestPermission();  final pos = await Geolocator.getCurrentPosition(    desiredAccuracy: LocationAccuracy.high,  );  return pos;}
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.