material-components / material-components-flutter-codelabs

Codelabs for Material Components for Flutter
212 stars 247 forks source link

[MDC-104] - Step 8 - Duplicate code on 'Add a shortcut back to the login screen' #167

Closed zhaoshengjun closed 5 years ago

zhaoshengjun commented 5 years ago

On step 7, part "Add a shortcut back to the login screen", the code is duplicated.

  // TODO: Add shortcut to login screen from trailing icons (104)
        IconButton(
          icon: Icon(
            Icons.search,
            semanticLabel: 'login', // New code
          ),
          onPressed: () {
            // TODO: Add open login (104)
            Navigator.push(
              context,
              MaterialPageRoute(builder: (BuildContext context) => LoginPage()),
            );
          },
        ),
        IconButton(
          icon: Icon(
            Icons.tune,
            semanticLabel: 'login', // New code
          ),
          onPressed: () {
            // TODO: Add open login (104)
            Navigator.push(
              context,
              MaterialPageRoute(builder: (BuildContext context) => LoginPage()),
            );
          },
        ),

should be:

  // TODO: Add shortcut to login screen from trailing icons (104)
        IconButton(
          icon: Icon(
            Icons.search,
            semanticLabel: 'login', // New code
          ),
          onPressed: () {
            // TODO: Add open login (104)
            Navigator.push(
              context,
              MaterialPageRoute(builder: (BuildContext context) => LoginPage()),
            );
          },
        )
lisa-liao commented 5 years ago

Hi @zhaoshengjun, thanks for opening this issue! I believe the IconButtons are 2 separate trailing icons (search icon and tune icon), which is why two separate icons are added. If you have any other questions, please let us know!