Faadiaf
Faadiaf

Reputation: 1

How to change the color of Listview to transparent in flutter?

I'm creating an app which requires the background to have a gradient. now I need the listview to be transparent to have the color show, how am I supposed to do that because Colors.transparent is not working.

Upvotes: 0

Views: 1725

Answers (2)

user18964872
user18964872

Reputation:

try this code it's work with me to keep the background listview in transparent

ListView.builder(
       itemCount: ItemCount,
       itemBuilder: (context, index) {
     return Card(
     color: Colors.transparent,// this line for keep the listview transparent
       child : Row(
           children [
         //your code ])
             
            ),
})

Upvotes: 0

Erfan Taghinia
Erfan Taghinia

Reputation: 1

if your wanna create gradient BG in flutter I Think this would be work

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return const MaterialApp(
  // Remove the debug banner
  debugShowCheckedModeBanner: false,
  title: 'Kindacode.com',
  home: HomePage(),
);
}
}

class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
  decoration: const BoxDecoration(
      gradient: LinearGradient(
          begin: Alignment.topLeft,
          end: Alignment.bottomRight,
          colors: [Colors.purple, Colors.orange])),
  child: Scaffold(
      // By defaut, Scaffold background is white
      // Set its value to transparent
      backgroundColor: Colors.transparent,
      appBar: AppBar(
        backgroundColor: Colors.black45,
        title: const Text('Kindacode.com'),
      ),
      body: Center(
        child: Container(
          width: 200,
          height: 200,
          color: Colors.white,
        ),
      )),
  );
 }
 }

Upvotes: 0

Related Questions