How do you return data from a screen in Flutter?
Navigator.pop(context, result) closes the screen and passes the result back to the awaiting Navigator.push call.
Pass data back to the previous screen after navigation
Passing the Quiz & Exercises is mandatory to earn FX and proceed. If you fail, try again to gain the required FX, then the Proceed button will become available.
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
Having trouble? AI is here to help
Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.
Use the AI button at the bottom of the screen
Sometimes a screen needs to send data back to whoever opened it. For example, a color picker screen returning the selected color, or a form screen returning the submitted data.
1// ── Returning data with Navigator.pop() ──23// On the receiving screen (calls pop with result)4class ColorPickerScreen extends StatelessWidget {5@override6Widget build(BuildContext context) {7return Scaffold(8body: Center(9child: ElevatedButton(10onPressed: () {11// Pop and send data back12Navigator.pop(context, 'red');13},14child: const Text('Choose Red'),15),16),17);18}19}
1// ── On the calling screen (await for the result) ──2class HomeScreen extends StatefulWidget {3@override4State<HomeScreen> createState() => _HomeScreenState();5}67class _HomeScreenState extends State<HomeScreen> {8String _selectedColor = 'none';910Future<void> _openColorPicker() async {11// await the result from the pushed screen12final result = await Navigator.push<String>(13context,14MaterialPageRoute(builder: (_) => const ColorPickerScreen()),15);1617// result is null if user pressed back without selecting18if (result != null) {19setState(() => _selectedColor = result);20}21}2223@override24Widget build(BuildContext context) {25return Scaffold(26body: Column(27children: [28Text('Selected: $_selectedColor'),29ElevatedButton(30onPressed: _openColorPicker,31child: const Text('Pick Color'),32),33],34),35);36}37}
Navigator.push returns a Future that completes with `null` if the user pressed the back button without providing a result. Always check `if (result != null)` before using it.
Returned data is ideal for transient decisions such as pickers, confirmations, and quick editors.
This keeps screens loosely coupled: child screen decides output, parent screen decides how to use that output.
If the parent screen is disposed before the awaited navigation result returns, avoid calling setState. Check mounted before updating UI state.
Pass data back to the previous screen after navigation. Navigation manages how users move between screens and return to previous states.
Connect each concept to real app features you can build.
Design route names and arguments before wiring screen UI.
Poor routing decisions create confusing UX and fragile deep-link behavior.
Navigator.pop(context, result) closes the screen and passes the result back to the awaiting Navigator.push call.
await Navigator.push() waits for the pushed screen to be popped and returns its result. The calling function must be async.
If the user navigates back without calling Navigator.pop(context, value), the Future completes with null.
Something seems incorrect, unclear, or missing? Let us know.
FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.
Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.
Sign in to continue with exercises and quiz for this lesson.
Sign In to Continue