Passing Data Between Screens

Google Flutter 9 min min read Updated: Nov 16, 2026 Beginner
Passing Data Between Screens
Beginner Topic 2 of 4

The Most Common Need

You show a list of products. The user taps one. The detail screen must know which product was tapped. Here is how to pass data.

Method 1: Constructor Parameters (Best)

dart class Product { final String name; final double price; final String image; const Product(this.name, this.price, this.image); } class ProductListPage extends StatelessWidget { const ProductListPage({super.key}); final products = const [ Product('Shoes', 49.9, 'https://picsum.photos/id/21/400/300'), Product('Watch', 89.0, 'https://picsum.photos/id/22/400/300'), Product('Bag', 35.5, 'https://picsum.photos/id/23/400/300'), ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Products')), body: ListView.builder( itemCount: products.length, itemBuilder: (context, i) { final p = products[i]; return ListTile( title: Text(p.name), subtitle: Text('\$${p.price}'), onTap: () => Navigator.push( context, MaterialPageRoute(builder: (_) => ProductDetailPage(product: p)), ), ); }, ), ); } } class ProductDetailPage extends StatelessWidget { final Product product; const ProductDetailPage({super.key, required this.product}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(product.name)), body: Column( children: [ Image.network(product.image), Padding( padding: const EdgeInsets.all(16), child: Text('Price: \$${product.price}', style: const TextStyle(fontSize: 22)), ), ], ), ); } }
Why this is best: The compiler checks the type. You cannot forget a parameter, and your IDE helps you with autocomplete.

Method 2: Route Arguments

dart // Send Navigator.pushNamed(context, '/detail', arguments: product); // Receive class DetailPage extends StatelessWidget { const DetailPage({super.key}); @override Widget build(BuildContext context) { final product = ModalRoute.of(context)!.settings.arguments as Product; return Scaffold(appBar: AppBar(title: Text(product.name))); } }

This works, but you lose type safety because of the cast with as.

Method 3: Send Data Back with pop

dart final rating = await Navigator.push<int>( context, MaterialPageRoute(builder: (_) => const RatePage()), ); // In RatePage: Navigator.pop(context, 5);

Method 4: Callbacks

dart class FilterPage extends StatelessWidget { final ValueChanged<String> onSelected; const FilterPage({super.key, required this.onSelected}); @override Widget build(BuildContext context) { return ListTile( title: const Text('Cheapest first'), onTap: () { onSelected('price_asc'); Navigator.pop(context); }, ); } }
NeedUse
Send data to a new screenConstructor parameters
Get a single result backNavigator.pop(context, value)
Share data between many screensState management (Provider, Riverpod, Bloc)
Open by URL with an idgo_router path parameters (next lesson)
Tip: Pass only what the screen needs, such as an id or a small model. For large or shared data use state management.

Conclusion

Constructor parameters are the cleanest way to send data to another screen, and pop can return a value.

Quick Summary: Use constructor parameters to send data, pop with a value to return data and state management for shared data.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators