creating a list using ListTile in ListView in flutter

 import 'package:flutter/material.dart';


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

class MyApp extends StatelessWidget {
const MyApp({super.key});

// This widget is the root of your application.
@override
Widget build(BuildContext context) {

return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}

class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
var arrNames =['Cashify','Abhinav','Aftab','Sahim','Ankit','Sohail','Shivam','Vikash','Altaf'];
return Scaffold(
appBar: AppBar(title: Text('Profile')),
body: ListView.separated(itemBuilder: (context,index){
return ListTile(
leading: Text('${index+1}'),
title:Text(arrNames[index]) ,
subtitle:Text('Number') ,
trailing: Icon(Icons.info_outline_rounded),
);
},
itemCount: arrNames.length,
separatorBuilder: (context,index){
return Divider(height: 40,thickness: 2);
},
)



);
}
}

Comments

Popular posts from this blog

swapping the alternate values in given array's element ! 17/11/2022

Learning stage | c++ programs

c++ basic question