Stateful & Stateless Widgets, Container, Scaffold, Text - Expended, Sizebox, Row, Column, Button
Stateful & Stateless Widgets, Container, Scaffold, Text - Expended, Sizebox, Row, Column, Button
Scaffold(
body:widget,
bottomSheet: widget,
),
1-6 container
1. width: The width of the container (set to 200 pixels).
2. height: The height of the container (set to 200 pixels).
3. color: The background color of the container (set to blue).
4. alignment: Aligns the child widget within the container (set to center).
5. margin: The space outside the container (set to 20 pixels on all sides).
6. padding: The space inside the container (set to 15 pixels on all sides).
7. decoration: A BoxDecoration object that allows you to customize the container's appearance:
color: Background color (set to green).
border: Defines the border around the container, including color and width.
borderRadius: Rounds the corners of the container (set to 20 pixels).
boxShadow: A list of BoxShadow objects that create shadows for the container, allowing for
customization of color, blur radius, and offset.
8. transform: Applies a transformation matrix to the container, allowing for rotation, scaling, and
translation (set to a slight rotation).
1-6-1 Container Example
Container(
width: 200, height: 200, color: Colors.blue,
margin: EdgeInsets.all(20),padding: EdgeInsets.all(15),
decoration: BoxDecoration(
color: Colors.green,
border: Border.all(color: Colors.red, width: 5, ),
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.3),
blurRadius: 10,
offset: Offset(5, 5),
),],),
transform: Matrix4.rotationZ(0.1),
child:
),
1-7 Text widget Example
Text( 'Hello, Flutter!’,
style: TextStyle(
fontSize: 24, // Text size font
Weight: FontWeight.bold, // Bold text
fontStyle: FontStyle.italic, // Italic text
color: Colors.blue, // Text color
decoration: TextDecoration.underline, // Underline
text
decorationColor: Colors.red, // Color for text
decoration
decorationStyle: TextDecorationStyle.dashed, //
Decoration style
backgroundColor: Colors.yellow, // Text background
color
1-8 Expanded
This example demonstrates the versatility of the Column
widget in Flutter, allowing you to arrange child widgets
vertically with various alignment options. You can
customize the layout according to your application’s
needs using these properties.
Expanded(
flex: 2,
child: Container(
color: Colors.red,
child: Center(
child: Text('Expanded 1 (flex:
2)’,
style: TextStyle(color:
Colors.white)
1-9 Column
This example demonstrates the versatility of the Column
widget in Flutter, allowing you to arrange child widgets
vertically with various alignment options. You can customize
the layout according to your application’s needs using these
properties.
Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Container(
width: 100, height: 50, color: Colors.red,
child: Center(child: Text('Item 1')),
),
Container(
width: 100, height: 50, color: Colors.green,
child: Center(child: Text('Item 2')),
1-10 Row
This example illustrates the flexibility of the Row widget in
Flutter, allowing you to arrange child widgets horizontally with
various alignment options. You can customize the layout based
on your application's requirements using these properties.
Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Container(
width: 100, height: 50, color: Colors.red,
child: Center(child: Text('Item 1')),
),
Container(
width: 100, height: 50, color: Colors.green,
child: Center(child: Text('Item 2')),
1-11 ElevatedButton
ElevatedButton(
child: Text('Click Me',),
onPressed: () { print('Button clicked!'); },
onLongPress: () { print('Long press
triggered!’); },
style: ElevatedButton.styleFrom(
primary: Colors.blue,
onPrimary: Colors.white,
shadowColor: Colors.black,
elevation: 10,
padding: EdgeInsets.symmetric(horizontal: 30,
vertical: 15),
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(30.0))
side: BorderSide( color: Colors.red , width: 2),
), ),
1-11 Custome Button
InkWell(
onTap: (){},
onLongPress: (){ },
child: widget
),
GestureDetector(
onTap: (){},
onLongPress: (){ },
child: widget
),
Thanks
Do you have any
questions?
!
Resources
https://flutter.dev