ListView Other Example

 import "package:flutter/material.dart";


void main()
{
runApp(MyApp());
}
class MyApp extends StatelessWidget
{
MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "ListView",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: DemoList(),
);
}
}
class DemoList extends StatefulWidget {
@override
State<DemoList> createState()
{
return DemoListState();
}
}
class DemoListState extends State<DemoList>
{
var arrNames = ["Raman", "Ramanujan", "Rajesh", "James", "John", "Rahim", "Ram"];

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("ListView practice"),
centerTitle: true,
),
/// ListView
// body: ListView(
// // scrollDirection: Axis.horizontal,
// // reverse: true,
// children: [
// Padding(
// padding: const EdgeInsets.all(8.0),
// child: Text("One", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),),
// ),
// Padding(
// padding: const EdgeInsets.all(8.0),
// child: Text("Two", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),),
// ),
// Padding(
// padding: const EdgeInsets.all(8.0),
// child: Text("Three", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),),
// ),
// Padding(
// padding: const EdgeInsets.all(8.0),
// child: Text("Four", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),),
// ),
// Padding(
// padding: const EdgeInsets.all(8.0),
// child: Text("Five", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),),
// ),
// ],
// ),

/// ListView.builder()
// body: ListView.builder(
// itemBuilder: (context, index) {
// return Text(arrNames[index], style: TextStyle(fontWeight: FontWeight.bold),);
// },
// itemCount: arrNames.length,
// itemExtent: 200.0,
// // scrollDirection: Axis.horizontal,
// ),

/// ListView.separated()
body: ListView.separated(
itemBuilder: (context, index) {
return Row(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Text("Raman", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("John", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500),),
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Ramanujan", style: TextStyle(fontSize: 15.0, fontWeight: FontWeight.bold),),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Raju", style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),),
),
],
);
},
itemCount: arrNames.length,
separatorBuilder: (context, index) {
return const Divider(height: 100.0, thickness: 4);
},
),

);
}
}

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