0

Summing up the situation, I'm making a simple App in Flutter, which displays a List of Items you've added (I won't detail the app, as it would be unnecessary).

The file I created (log.dart) has a Property Class

class LogItem { /* code and stuff inside */ }

And it has a List with items

List<LogItem> itemsList = [test01, test02];

I created a simple Widget to display data for each item in this List

class SpecificItem extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Row(
        children: [
          Text(
            " R\$ ${itensList[i].price}",
          ),
          Spacer(),
          Text(
            "${itensList[i].title}",
          ),
        ],
      ),
    );
  }
}

Just below in another widget, I created a for loop to make a variable "i" change, to display different items from this list.

class LogGraphical extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Container(
      child: ListView(
        children: [
          for (int item = 0; item < itensList.length; item++) SpecificItem(item),
        ],
      ),
    );
  }
}

Can someone explain to me exactly how I do the Widget ACCEPT PARAMETERS and change it? In this way creating multiple items? I tried in many ways, but I could never get it to work!

(In the code I inserted here, I didn't put the Widget accepting anything.)

  • see this answer [flutter-how-to-pass-arguments-to-a-widget-using-a-variable](https://stackoverflow.com/questions/65796594/flutter-how-to-pass-arguments-to-a-widget-using-a-variable). – Chance Sep 29 '22 at 18:53

0 Answers0