navigateTo method
void
navigateTo(
Navigates to a new screen using MaterialPageRoute.
This is a simplified wrapper for Navigator.push.
@param page The new Widget page to navigate to.
Example:
ElevatedButton(
onPressed: () => context.navigateTo(const DetailScreen()),
child: const Text('Go to Details'),
)
Note: For more advanced navigation (named routes, replacement), use push, pushNamed, or pushReplacement.
Implementation
void navigateTo(Widget page) {
Navigator.push(this, MaterialPageRoute(builder: (context) => page));
}