ADF Unit 3 ScrollingListandLayouts
ADF Unit 3 ScrollingListandLayouts
01CE0610
Unit 3
Scrolling List and Layouts
● In Flutter, ListView is a widget that provides a scrollable list of children, allowing users to scroll
through a potentially long list of items.
● It's commonly used to display a large amount of data that might not fit entirely on the screen at once.
Property Description
scrollDirection Determines the axis along which the list scrolls. Axis.vertical or Axis.horizontal.
physics Controls the scroll physics, such as how the scrolling behaves when reaching the edge.
shrinkWrap Adapts the size of the list to fit its children's size.
Widget to be displayed before the title and subtitle. Typically used for icons, avatars, or
leading
images.
ListTile( ),
leading: Icon(Icons.star), ),
title: Text('Item 2'), );
), }
ListTile( }
leading: Icon(Icons.star),
title: Text('Item 3'),
),
// Add more list items as needed
],
List View →Example 2
ListTile( ),
leading: CircleAvatar( );
child: }
Icon(Icons.account_circle_rounded,color: }
Colors.blue,),
),
title: Text('Item 2'),
subtitle: Text('Subtitle for Item 2'),
onTap: () {
// Handle tap
},
),
// Add more ListTiles with different
content
],
),
Grid View
Property Description
Defines the layout of the grid, including the number of columns (crossAxisCount),
gridDelegate
spacing, and size.
shrinkWrap Indicates whether the grid should be sized to fit its children's size.
Property Description
controller: _tabController,
@override children: [
Widget build(BuildContext context) { Center(child: Text('Tab 1 Content')),
return Scaffold( Center(child: Text('Tab 2 Content')),
appBar: AppBar( Center(child: Text('Tab 3 Content')),
title: Text('Tab Bar Example'), ],
bottom: TabBar( ),
controller: _tabController, );
tabs: [ }
Tab(text: 'Tab 1'),
Tab(text: 'Tab 2'), @override
Tab(text: 'Tab 3'), void dispose() {
], _tabController.dispose();
), super.dispose();
), }
body: TabBarView( }
Navigation Bar
● In the context of user interfaces, a navigation bar is a graphical control element typically found at
the top or bottom of a screen in a mobile application.
● It provides users with access to different sections, features, or views within the application or
website, allowing them to navigate between various pages or sections.
●
Property Description
Items Defines the navigation items displayed within the navigation bar.
Selected Index Indicates the index of the currently selected navigation item.
OnTap Callback function triggered when a navigation item is tapped.
Icon / Text Representation of each navigation item, often containing an icon and/or text.
Elevation Elevation or shadow applied to the navigation bar, providing a sense of depth.
Boolean property indicating whether the navigation bar is placed at the bottom of the
Bottom Navigation Bar
screen.
Title Text or widget displayed as the title of the navigation bar.
Navigation Bar→ Example 1
import 'package:flutter/material.dart';
class _NavigationExampleState extends
void main() { State<NavigationExample> {
runApp(NavigationExample()); int _currentIndex = 0;
}
final List<Widget> _pages = [
class NavigationExample extends StatefulWidget { FirstPage(),
const NavigationExample({super.key}); SecondPage(),
ThirdPage(),
@override ];
State<NavigationExample> createState() =>
_NavigationExampleState();
}
Navigation Bar→ Example 1