Bidev
BeginnerNavigation & Routing

How do you return data from a screen when popping it?

Short Answer

Pass a value to Navigator.pop(context, value), and await the result of the original Navigator.push call — the awaited Future resolves with whatever value was passed to pop.

Navigator.push returns a Future that doesn't resolve until the pushed route is popped. If you await that push call, and the pushed screen calls Navigator.pop(context, someValue) instead of just Navigator.pop(context), the awaited Future resolves with someValue — a clean, typed way to get a result back from a screen without callbacks or global state.

Code Example

// Caller
final result = await Navigator.push<String>(
  context,
  MaterialPageRoute(builder: (context) => const PickerScreen()),
);
if (result != null) print('Picked: \$result');

// PickerScreen
Navigator.pop(context, 'selected-value');

Common Mistakes

  • ×Forgetting to specify the generic type on Navigator.push<T>, causing the awaited result to be typed as dynamic/Object? unnecessarily.
  • ×Not handling the null case when the user backs out without picking anything — pop() with no argument resolves the Future with null.