web-app tutorial missing line

38 views
Skip to first unread message

Francesco Gurrieri

unread,
Apr 24, 2020, 6:16:37 AM4/24/20
to Flutter Development (flutter-dev)
Hi,

I am completely new to flutter and relatively new to web design, so it's possible I am missing something.

However,
Doing the tutorial until the end of step 1 at https://flutter.dev/docs/get-started/codelab-web
I found this error when pressing the button:


════════ Exception caught by gesture ═══════════════════════════════════════════
Could not find a generator for route RouteSettings("/welcome", null) in the _WidgetsAppState.

I solved it by  modifying routed in the LoginApp widget

class LoginApp extends StatelessWidget {
 @override
 Widget build(BuildContext context) {
   return MaterialApp(
     routes: {
       '/': (context) => LoginScreen(),
       '/welcome': (context) => WelcomeScreen(), // Added this line to fix the issue
     },
   );
 }
}

In case I am right it may be worth to update tutorial

Regards,
Francesco

Souvik Dutta

unread,
Apr 24, 2020, 6:41:22 AM4/24/20
to Francesco Gurrieri, Flutter Development (flutter-dev)
Post your whole code. This happened with me and I understood it was a spelling mistake.

Souvik flutter dev

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/26b1eea6-5e5f-42c5-b20f-57a83b703758%40googlegroups.com.

Francesco Gurrieri

unread,
Apr 24, 2020, 6:46:42 AM4/24/20
to Flutter Development (flutter-dev)
Thanks for your reply!

This is my whole main.dart:
import 'package:flutter/material.dart';

void main() => runApp(LoginApp());

class LoginApp extends StatelessWidget {
 @override
 Widget build(BuildContext context) {
   return MaterialApp(
     routes: {
       '/': (context) => LoginScreen(),
       '/welcome': (context) => WelcomeScreen(), // Added this line to fix the issue
     },
   );
 }
}

class WelcomeScreen extends StatelessWidget {
 @override
 Widget build(BuildContext context) {
   return Scaffold(
     body: Center(
       child: Text('Welcome!', style: Theme.of(context).textTheme.display3),
     ),
   );
 }
}

class LoginScreen extends StatelessWidget {
 @override
 Widget build(BuildContext context) {
   return Scaffold(
     backgroundColor: Colors.grey[200],
     body: Center(
       child: SizedBox(
         width: 400,
         child: Card(
           child: LoginForm(),
         ),
       ),
     ),
   );
 }
}

class LoginForm extends StatefulWidget {
 @override
 _LoginFormState createState() => _LoginFormState();
}

class _LoginFormState extends State<LoginForm> {
 final _firstNameTextController = TextEditingController();
 final _lastNameTextController = TextEditingController();
 final _usernameTextController = TextEditingController();

  double _formProgress = 0;
 void _showWelcomeScreen() {
   Navigator.of(context).pushNamed('/welcome');
 }

  @override
 Widget build(BuildContext context) {
   return Form(
     child: Column(
       mainAxisSize: MainAxisSize.min,
       children: [
         LinearProgressIndicator(value: _formProgress),
         Text('Sign Up', style: Theme
             .of(context)
             .textTheme
             .display1), // display1 changes to headline4 in 1.16
         Padding(
           padding: EdgeInsets.all(8.0),
           child: TextFormField(
             controller: _firstNameTextController,
             decoration: InputDecoration(hintText: 'First name'),
           ),
         ),
         Padding(
           padding: EdgeInsets.all(8.0),
           child: TextFormField(
             controller: _lastNameTextController,
             decoration: InputDecoration(hintText: 'Last name'),
           ),
         ),
         Padding(
           padding: EdgeInsets.all(8.0),
           child: TextFormField(
             controller: _usernameTextController,
             decoration: InputDecoration(hintText: 'Username'),
           ),
         ),
         FlatButton(
           color: Colors.blue,
           textColor: Colors.white,
           onPressed:  _showWelcomeScreen,
           child: Text('Sign up'),
         ),
       ],
     ),
   );
 }
}


To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages