Professional Documents
Culture Documents
Robel M
z
Flutter File Structure
▪ This directory is on the root level will contain all the static assets that are
used in the application, for example, fonts, icons, logos, background
images, demo videos, etc. It is very much recommended that we should
have different directories for a different type of data for example images,
videos & logos, should have a different folder of their own so that it
becomes easier to maintain and access them.
z
B. lib: Entire code of the Application
▪ Screens
▪ Providers
▪ Service
▪ Theme
▪ Models
▪ Blocs
…
z
C: test
▪ Testing codes
z
D: Android
- build.gradle
- AndroidManifest.xml
z
E. ios
- Runner
- pods
z
G. Pubspec.yaml
▪ The foundation of any Flutter app, the main.dart file, should hold very little
code and only serve as an overview to an app.
▪ The widget being run by runApp should be a StatelessWidget, and the itself
should be no more complicated than a simple MaterialApp.
▪ The MaterialApp itself should have no heavy code in it, instead pulling the
Theme and the widget screens from other files.
z void main() {
runApp(ExampleApp());
@override
return MaterialApp(
title: 'ExampleApp’,
initialRoute: '/',
▪ Widgets describe what their view should look like given their current
configuration and state. When a widget’s state changes, the widget rebuilds
its description, which the framework diffs against the previous description in
order to determine the minimal changes needed in the underlying render tree
to transition from one state to the next.
z
Stateless widget
@override
return Container();
}
z
Stateful Widget
}
class _Employee State extends State< Employee > {
@override
return Container();
}
z
import
'package:flutter/material.dart';
),
);}
z
▪ Elements
✓ AppBar
✓ BottomAppBar
✓ FloatingActionButton
✓ BottomSheet
✓ Drawer
▪ App bars typically expose one or more common actions with IconButtons
which are optionally followed by a PopupMenuButton for less common
operations (sometimes called the "overflow menu").
appBar: AppBar(
leading:Text('') ,
title: Text('') ,
actions: [],
),.
z
Drawer
▪ A panel displayed to the side of the body, often hidden
on mobile devices.
drawer: Drawer(
child: ListView()
),
z
Text
▪ The Text widget lets you create a run of styled
text within your application.
Attributes:
Text(“HELLO!”, style: TextStyle(fontSize: 14, fontweight:
FontWeight.bold))
z
)
z
Icon
Icon(
child: Icons.home,
color:Colors.red,
size: 10,
▪ Icon widget have on tap functionality, but you can wrap this widget with other
widgets
z
IconButton
IconButton(
onPressed: () {
setState(() {
// do somthing
});
},
),
z Image
TextButton(
style: TextButton.styleFrom(
),
onPressed: () {},
),
z Inkwell
❖ Inkwell is A rectangular area of a Material that responds
to touch.
InkWell(
onTap: () {},
onDoubleTap: () {},
onLongPress: () {},
),
z Gesture Detector
▪ A widget that detects gestures.
child: Text(“check”),
onLongPress: () {},
onLongPressStart: () {},
onLongPressUp: () {},
onLongPressDown: () {},
onLongDoubleTap () {},
),
z
Center
)
z
Card
child: ListView(
)
z
Reading Assignments
▪ Flexible
▪ Expanded
▪ SizedBox
z
])
z
Row
▪ To cause a child to expand to fill the available horizontal space, wrap the
child in an Expanded widget.
Row(
children:<Widget> [
Text(“Hello”),
Container()
])
z
Wrap
▪ A Wrap lays out each child and attempts to place the child adjacent to the previous
child in the main axis, given by direction, leaving spacing space in between. If there is
not enough space to fit the child, Wrap creates a new run adjacent to the existing
children in the cross axis.
Wrap(
direction: Axis.horizontal,
children: <Widget>[ ]
)
z
▪ ListView is the most commonly used
Listview
scrolling widget. It displays its
children one after another in the
scroll direction. In the cross axis, the
children are required to fill
the ListView.
ListView(
children: <Widget>[
Container( height: 50, color: Colors.blue),
])
z
Stack
▪ Instead of being linearly oriented (either horizontally or
vertically), a Stack widget lets you place widgets on top of
each other in paint order. You can then use
the Positioned widget on children of a Stack to position them
relative to the top, right, bottom, or left edge of the stack.
Stacks are based on the web’s absolute positioning
layout model.
z GridView
crossAxisCount: 2, // Generate 100 widgets that display their index in the List.
return Center(
);
}),
);
z
Listview Builder
ListView.builder(
itemCount: entries.length,
itemBuilder: (BuildContext context, int index) {
return Container(
child: Text('Entry ‘),
);
} );
Related: GridView.builder
z
▪ Navigator.pushNamed(context, “/path”)
▪ Navitor.pop(context)
z
MaterialApp(
title: 'Named Routes Demo’,
initialRoute: ‘/’,
routes: {
‘/': (context) => const FirstScreen(),
‘/second': (context) => const SecondScreen(), },
)
z
THANK YOU!