how to import a text from that list in flutter

Hi I am new to flutter and i need your help with that issue I want to import the item from this list=>

List values = [
  {"category":'موبيلات',
   'categorybackimage':'images/backgroundimage',
   'categoryimage':'images/iphone'},
  {'category':'موبيلات',
   'categorybackimage':'images/backgroundimage',
   'categoryimage':'images/iphone'},
  {'category':'موبيلات',
   'categorybackimage':'images/backgroundimage',
   'categoryimage':'images/iphone'},
  {'category':'موبيلات',
   'categorybackimage':'images/backgroundimage',
   'categoryimage':'images/iphone'}
];

that what i've tried=>

 Text("${(values['category'])}"),
 Card(color: Colors.white,
      child: 
      Text( "عروض ", 
           style: TextStyle(color: Colors.red, fontSize: 20,fontWeight: FontWeight.w900)),

but there is an error says =>

the argument type 'String' can't be assigned to the parameter type 'int'.

why does that error appears and how to fix things and if there is other ways please help me with it

Upvotes: 0

Views: 594

Answers (1)

fayeed
fayeed

Reputation: 2485

You can use ListView.builder for this it is used to create a scrollable, linear array of widgets that are created on-demand:

ListView.builder(
  itemCount: values.length,
  itembuilder: (context, i) => Card(
    color: Colors.white,
    child: Text(
    values[i]['category'],
    style: TextStyle(
      color: Colors.red,
      fontSize: 20,
      fontWeight: FontWeight.w900,
    ),
  ),
)

Upvotes: 3

Related Questions