flutterflutter-dependencies

How to fix Flutter error: "Type 'Item' not found."


This code has been working for several weeks, but suddenly brought up errors after an AndroidStudio update:

    class _GameState extends State<Game> {
  List<Item> its = [
    Item('fins','images/idea-fins.png'),
    Item('sonar','images/idea-sonar.png'),
    Item('suction','images/idea-suction.png'),
    Item('tires','images/idea-tire.png'),
    Item('velcro','images/idea-velcro.png'),
    Item('propeller','images/idea-propeller.png')
  ];

The error I get is:

    Error: Type 'Item' not found.
  List<Item> its = [

Does "Item" now have to be defined, somehow, or has some more fundamental change been made?


Solution

  • Added this near the beginning and now it works:

    class Item {
      String name="";
      bool dropped=false;
      String pic="";
    
      Item(String a, String b)
      {
        name =a;
        pic =b;
      }
    }