'The getter 'password' isn't defined for the type 'Icons'

The icons I selected appear to be undefined even though they are in the class. What is the reason for this?

Icon(
    Icons.password,
    color: iconColor,
    )

enter image description here



Solution 1:[1]

Open your cmd or android studio terminal and type[flutter doctor, then flutter doctor --android-licenses] and accept all of the licenses that terminal suggest you.

Solution 2:[2]

Check if in your pubspec.yaml the section uses-material-design is set to true.

After seeing your flutter doctor output: try upgrading your version by using flutter upgrade. Then, run flutter clean and then flutter run in terminal.

Solution 3:[3]

You can use material_design_icons_flutter package.

import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';

class MyWidget extends StatelessWidget {
  Widget build(BuildContext context) {
    return new IconButton(
      // Use the MdiIcons class for the IconData
      icon: new Icon(MdiIcons.sword),
      onPressed: () { print('Using the sword'); }
     );
  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Saiful Islam
Solution 2
Solution 3 Timur Turbil