Skip to content

How can I use switch statement to change listview colors  #1

@ABINASH56

Description

@ABINASH56

here is the code .i need help in switch case. I watched this video but I need more examples to completely understand switch case..

How can i use switch case to change bg color of listview .I want to add 10 different types of colors in listview


ListView.builder(
  itemBuilder: (BuildContext context, int index) {
    return Container(
      color: (index % 10 == 0) ? Colors.red : Colors.green,
      child: ListTile(
        title: ...
      ),
    );
  },
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions