Flutter Learning at a StatelessWidget

flutter is programming language developed by google. It is a run on android and ios both device.
now starting flutter .a code is appbar
Scaffold(
appBar: AppBar(
title: Text('My First App'),
centerTitle: true,
backgroundColor: Colors.red[600],
),
body: Center(
child: Image(
image: AssetImage('assets/paguine.png'),
)
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Text('Click'),
backgroundColor: Colors.red[600],
),
);
}
appbar inside many property like title title is a app title and if you are take a title in a center use centerTitle property and do property true,and if choose backgroundcolor you can use backGroundColor property,
in abody section you do what inside body and child property use and in exammple you take some text or some thing new like image,in image property i use assetImage property for asset property i use and i insert image from my device
FloatingActionButton is a right side small button you can change color text and also add on in a button onPressed property use for click button
void main() => runApp(MaterialApp(
home: Home(),
main method call and a run MaterialApp,and call home property inside Home() function
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('My First App'),
centerTitle: true,
backgroundColor: Colors.red[600],
),
body: Center(
child: Image(
image: AssetImage('assets/paguine.png'),
)
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Text('Click'),
backgroundColor: Colors.red[600],
),
);
}
}
you type stless end click anter end then all class code is coming and statelesswidget is a very useful widget it is a fast load a application .when you click and click ctrl+s program are save and then after instant load application i realiy shocked when i first time run a application using a statelesswidget.
Full code:
import 'dart:ui';

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(
home: Home(),
));

class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('My First App'),
centerTitle: true,
backgroundColor: Colors.red[600],
),
body: Center(
child: Image(
image: AssetImage('assets/paguine.png'),
)
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Text('Click'),
backgroundColor: Colors.red[600],
),
);
}
}
I see Output like this..

Comments

Popular posts from this blog

Python Datetime Module - How to work with Dates, Times, Timedeltas, and Timezones