Open Vasilisk7 opened 3 years ago
Testing in clear app. Click 'Go to Detail Screen' and has error
main.dart
import 'package:flutter/material.dart'; import 'package:no_context_navigation/no_context_navigation.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( navigatorKey: NavigationService.navigationKey, onGenerateRoute: (RouteSettings settings) { switch (settings.name) { case '/': return MaterialPageRoute(builder: (context) => HomeScreen()); case '/detail_screen': return MaterialPageRoute( builder: (context) => DetailScreen(settings.arguments as String)); default: return null; } }, ); } } class DetailScreen extends StatelessWidget { const DetailScreen(this.message, {Key? key}) : super(key: key); final String message; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Detail Screen')), body: Center( child: Text(message), ), ); } } class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( body: Center( child: ElevatedButton( onPressed: () { navService.pushNamed('/detail_screen', args: 'From Home Screen'); }, child: Text('Go to Detail Screen'), ), ), ); } }
Same, any update?
Testing in clear app. Click 'Go to Detail Screen' and has error
main.dart