Reputation: 80
I want to reduce the space between Tabbar
and listtile
. I wrote them in two different files so i'll add both the codes. tried adding padding
but no use.
main.dart
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
themeMode: ThemeMode.system,
home: DefaultTabController(
length: 4,
child: NestedScrollView(
headerSliverBuilder: (context, innerBoxIsScrolled) => [
SliverAppBar(
pinned: true,
floating: true,
systemOverlayStyle: SystemUiOverlayStyle.dark,
title: const Text(
"WhatsApp",
style: TextStyle(letterSpacing: 1.0),
),
backgroundColor: colour,
actions: [
MaterialButton(
minWidth: 1.0,
onPressed: () {},
child: const Icon(
Icons.search,
color: Colors.white,
)),
MaterialButton(
minWidth: 1.0,
onPressed: () {},
child: const Icon(
Icons.more_vert,
color: Colors.white,
))
],
bottom: const TabBar(
dragStartBehavior: DragStartBehavior.start,
indicatorColor: Colors.white,
tabs: [
Tab(
iconMargin: EdgeInsets.only(left: 1.0, right: 1.0),
icon: Icon(Icons.photo_camera),
),
Tab(child: Text("CHATS")),
Tab(child: Text("STATUS")),
Tab(child: Text("CALLS"))
]))
],
body: const TabBarView(
dragStartBehavior: DragStartBehavior.start,
children: [Camera(), Chats(), Status(), Calls()]),
),
));
}
}
chats.dart
class _ChatsState extends State<Chats> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.only(top: 1.0),
child: ListView.separated(
itemBuilder: (context, index) => ListTile(
title: Text("Person $index"),
subtitle: Text("your message is this"),
trailing: Text("$hr:$mi $ti"),
leading: MaterialButton(
padding: EdgeInsets.all(1.0),
height: 1.0,
minWidth: 1.0,
elevation: 0,
onPressed: () {},
shape: CircleBorder(),
child: CircleAvatar(
radius: 25.0,
backgroundImage: AssetImage('assets/images/images.jfif'),
),
),
),
separatorBuilder: (context, index) {
return Divider();
},
itemCount: 50),
),
floatingActionButton: FloatingActionButton(
backgroundColor: colour,
onPressed: () {},
child: Icon(Icons.chat_rounded),
),
);
}
}
Upvotes: 0
Views: 152
Reputation: 390
try padding: EdgeInsets.zero inside ListView.separated, not inside ListTile
Upvotes: 1