Change ListView Background Color
Complete Code For Change ListView Background Color In Flutter
main.dart
import 'package:flutter/material.dart'; void main(){ runApp(MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { final List<String> _listViewData = [ "Lorem Ipsum is simply dummy text", "Lorem Ipsum is simply dummy text another.", "Lorem Ipsum is simply dummy text more.", "Lorem Ipsum is simply dummy text more.", "Lorem Ipsum is simply dummy text more.", "Lorem Ipsum is simply dummy text more.", "Lorem Ipsum is simply dummy text more.", "Lorem Ipsum is simply dummy text more.", "Lorem Ipsum is simply dummy text more.", ]; int _selectedIndex = 0; _onSelected(int index) { setState(() => _selectedIndex = index); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.lightGreen, title: Text('Change ListView Bg Color',style: TextStyle(color: Colors.white),), ), body: Padding( padding: const EdgeInsets.all(0.0), child: ListView.builder( itemCount: _listViewData.length, itemBuilder: (context, index) => Container( color: _selectedIndex != null && _selectedIndex == index ? Colors.lightGreen : Colors.white, child: ListTile( title: Text(_listViewData[index],style: TextStyle(fontSize: 12),), onTap: () => _onSelected(index), ), ), ), ), ); } }