Search code examples
flutterflutter-listview

How can I correct this to satisfy the Lint message in Flutter?


I am getting the following lint on

Text("The color is " + item['color'])

"Use interpolation to compose strings and values. (Documentation) Try using string interpolation to build the composite string."

Here is how the code is used in my ListView / ListTile. How could I re-write it better, there are no hints.

child: ListView.separated(
            itemCount: dataList.length,
            itemBuilder: (ctx, index) {
              final item = dataList[index];
              return ListTile(
                title: item['value'] == ''
                    ? 
                    Text(
                            "The color is " + item['color'])
                       

Solution

  • u can use

    Text("The color is ${item['color']}")
    

    instead of

    Text("The color is " + item['color'])