I am new to flutter. I would like a long title to appear in the appbar and I want to put it in the flexibleSpace. So, I enlarged the appbar but I don’t understand why it appears at the very top?
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(200),
child: AppBar(
bottom: const TabBar(
tabs: [
Tab(icon: Icon(Icons.view_carousel)),
Tab(icon: Icon(Icons.grid_view))
],
),
flexibleSpace: const Text('SubTitle very long..........................'),
title: const Text('Title',
textAlign: TextAlign.start,
style: TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.bold,
))),
),
body: const TabBarView(
children: [AttendanceCarousel(), AttendanceGrid()],
),
),
);
}
I followed the Flutter doc but it looks like that ?
2
Answers
happy coding…
You must align the
Text
Widget withAlign
Widget and set its align property according to your need.Sample Code : –
Full Code : –
Output : –