Help post .... As you can see in the flutter code. I was trying to figure out how to see apps with colors and titles with a map inside a list, but I could see the titles. There was a problem with the colors. How can I fix this? So that I can see my color and title
import 'package:flutter/material.dart';
class HomePage extends StatelessWidget {
final myCatagory = [
{
'title': 'Samsung',
'color': Colors.pink[800],
},
{
'title': 'Symphony',
'color': Colors.tealAccent[800],
},
{
'title': 'MI',
'color': Colors.amberAccent[800],
},
{
'title': 'Oppo',
'color': Colors.blue[800],
},
{
'title': 'Vivo',
'color': Colors.redAccent[800],
},
{
'title': 'Iphone',
'color': Colors.greenAccent[800],
},
];
// final catagoryColors = [
// Colors.red,
// Colors.green,
// Colors.black87,
// ];
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey,
appBar: AppBar(
title: const Text('My Blog'),
backgroundColor: Colors.redAccent,
),
body: Container(
height: 150,
child: ListView.builder(
itemCount: myCatagory.length,
shrinkWrap: true,
primary: false,
physics: BouncingScrollPhysics(),
scrollDirection: Axis.horizontal,
itemBuilder: (BuildContext context, int index) {
return Container(
alignment: Alignment.center,
margin: EdgeInsets.only(
left: 10,
top: 10,
),
color: myCatagory[index]['color'], **The problem in this line**
height: 200,
width: 100,
child: Text(
'${myCatagory[index]['title']}',
style: TextStyle(
color: Colors.white,
fontSize: 15,
fontWeight: FontWeight.w400,
),
),
);
},
),
),
);
}enter image description here
enter code here
