0% found this document useful (0 votes)
17 views

Flutter Component

The document shows examples of different Flutter widgets like buttons, images, rows and columns, scroll views, list views. It demonstrates TextButton, ElevatedButton, OutlinedButton, InkWell, containers, singlechildscrollview, listviewbuilder and listviewseparated.

Uploaded by

xijasab439
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Flutter Component

The document shows examples of different Flutter widgets like buttons, images, rows and columns, scroll views, list views. It demonstrates TextButton, ElevatedButton, OutlinedButton, InkWell, containers, singlechildscrollview, listviewbuilder and listviewseparated.

Uploaded by

xijasab439
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Text Button

body: TextButton(
child: Text('Click hare!'),
onPressed: (){
print('The Button is Tapped!');
},
onLongPress: (){
print('This is long press!!');
},
)
);

Elevated Button

ElevatedButton(
child: Text('Button'),
onPressed: (){
print('Button Pressed!');
},
)

Outlined Button

OutlinedButton(
child: Text('Button'),
onPressed: (){
print('Button Pressed!');
},
)

Add Images

Center(
child: Container(
width: 100,
height: 100,
child: Image.asset('assets/images/new.jpg')) ,
)

Row & Column

Container(
//width: 300,
// height: 300,
color: Colors.yellow,
child: Column(

// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// mainAxisAlignment: MainAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.start,

// crossAxisAlignment: CrossAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text('R1', style: TextStyle(fontSize: 30),),
Text('R2', style: TextStyle(fontSize: 30),),
Text('R3', style: TextStyle(fontSize: 30),),
Text('R4', style: TextStyle(fontSize: 30),),
Text('R4', style: TextStyle(fontSize: 30),)
],
),
Text('A', style: TextStyle(fontSize: 30),),
Text('B', style: TextStyle(fontSize: 30),),
Text('C', style: TextStyle(fontSize: 30),),
Text('D', style: TextStyle(fontSize: 30),),
Text('E', style: TextStyle(fontSize: 30),),
ElevatedButton(onPressed: (){

}, child: Text('Roshan'))
],
),
)

InkWell

Center(
child: InkWell(
onTap: (){
print('Hello World');
},
onDoubleTap: (){
print('Double Tap');
},
onLongPress: (){
print('Long press');
},
child: Container(
width: 200,
height: 200,
color: Colors.yellow,
child: Center(child: InkWell(
onTap: (){
print('text tapped');
},
child: Text('Tap Me',style: TextStyle(fontSize: 30,fontWeight:
FontWeight.w500),))),

),
),
)

Scroll
Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: SingleChildScrollView(
child: Column(
children: [
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Padding(
padding: const EdgeInsets.only(bottom: 11),
child: Row(
children: [
Container(
margin: EdgeInsets.only(left: 11),
width: 200,
height: 200,
color: Colors.red,
),
Container(
margin: EdgeInsets.only(left: 11),
width: 200,
height: 200,
color: Colors.yellow,
),
Container(
margin: EdgeInsets.only(left: 11),
height: 200,
width: 200,
color: Colors.blue,
),
Container(
margin: EdgeInsets.only(left: 11),
height: 200,
width: 200,
color: Colors.grey,
),
],

),
),
),
Container(
margin: EdgeInsets.only(bottom: 11),
height: 200,
color: Colors.yellow,
),
Container(
margin: EdgeInsets.only(bottom: 11),
height: 200,
color: Colors.green,
),
Container(
margin: EdgeInsets.only(bottom: 11),
height: 200,
color: Colors.grey,
),
Container(
margin: EdgeInsets.only(bottom: 11),
height: 200,
color: Colors.blue,
)
],
),
),
),
)

List view

Widget build(BuildContext context) {


var arrNames = ['Roshan','Sonje','Jethalal','Bhide','Mehta'];
ListView.builder(itemBuilder:(context,index){
return Text(arrNames[index]);
},
itemCount: arrNames.length,
)

List view Separated

ListView.separated(itemBuilder:(context,index){
return Text(arrNames[index],);
},
itemCount: arrNames.length,
separatorBuilder: (context,index){
return Divider(height: 100,thickness: 2,);
},
)

You might also like