ListTile with spaced items

 import "package:flutter/material.dart";


void main()
{
runApp(const MyApp());
}
class MyApp extends StatelessWidget
{
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "List with spaced items",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.grey,
),
home: ListPractice(),
);
}
}
class ListPractice extends StatelessWidget
{
List titleList = ["login_screen_image", "Login_screen_image_3", "Lord-Hanuman", "Natural_image",
"quote3", "login_screen_image", "Login_screen_image_3", "Lord-Hanuman", "Natural_image",
"quote3"];

// List imageList = ["assets/images/login_screen_image.png", "assets/images/Login_screen_image_3.png",
// "assets/images/Lord-Hanuman.jpg", "assets/images/Natural_image.jpg", "assets/images/quote3.jpg"];

// List imageList = <Image>[Image.asset("assets/images/login_screen_image.png"),
// Image.asset("assets/images/Login_screen_image_3.png"),
// Image.asset("assets/images/Lord-Hanuman.jpg"),
// Image.asset("assets/images/Natural_image.jpg"),
// Image.asset("assets/images/quote3.jpg")];

List imageList = [AssetImage("assets/images/login_screen_image.png"),
AssetImage("assets/images/Login_screen_image_3.png"),
AssetImage("assets/images/Lord-Hanuman.jpg"),
AssetImage("assets/images/Natural_image.jpg"),
AssetImage("assets/images/quote3.jpg"),
AssetImage("assets/images/login_screen_image.png"),
AssetImage("assets/images/Login_screen_image_3.png"),
AssetImage("assets/images/Lord-Hanuman.jpg"),
AssetImage("assets/images/Natural_image.jpg"),
AssetImage("assets/images/quote3.jpg"),
];

ListPractice({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("List with spaced items"),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: ListView.builder(
shrinkWrap: true,
padding: const EdgeInsets.all(11.0),
itemBuilder: (context, index) {
return Card(
child: ListTile(
leading: CircleAvatar(backgroundImage: imageList[index]),
title: Text("${titleList[index]}", style: const TextStyle(fontWeight: FontWeight.bold),),
subtitle: Text("${titleList[index]}"),
),
);
},
itemCount: imageList.length,
),


// body: Center(
// child: Column(
// children: List.generate(imageList.length, (index) {
// return Expanded(
// child: ListView.separated(
// shrinkWrap: true,
// padding: const EdgeInsets.all(11.0),
// itemBuilder: (context, index) {
// return ListTile(
// leading: CircleAvatar(backgroundImage: imageList[index]),
// title: Text("${titleList[index]}"),
// );
// },
// separatorBuilder: (context, index) {
// return const Divider(thickness: 2);
// },
// itemCount: imageList.length,
// ),
// );
// }).toList(),
// ),
// ),
);
}
}

Comments

Popular posts from this blog

Pagination with Bloc Pattern in Flutter

Pagination First Practical in Flutter

ExpansionPanel with ExpansionPanelList with Complete Collapse Operation in Flutter