Should you use named routes or MaterialPageRoute directly?
Short Answer
Named routes work well for simple, static navigation with no arguments; MaterialPageRoute pushed directly is more flexible for passing complex objects — though most new apps reach for go_router instead of either.
Navigator.pushNamed(context, '/details') looks up a route by string name in a table defined in MaterialApp(routes: {...}). It's concise, but passing data requires either a generic arguments object (losing compile-time type safety) or global state.
Navigator.push(context, MaterialPageRoute(builder: (context) => DetailScreen(item: item))) passes strongly-typed data directly as a constructor parameter, safer and easier to refactor, at the cost of slightly more verbose call sites. For apps beyond a handful of screens, most teams now skip both in favor of go_router's typed path/query parameters.
Common Mistakes
- ×Passing complex objects through named routes' arguments as Object? and casting them unsafely in the destination screen.
- ×Registering every screen as a named route even when the app never needs deep linking or URL-based navigation.