To create new Flutter APP
flutter create ProjectName1
Flutter Project Files
pubspec.yaml : contains project dependency like fonts, images, packages,...
lib: a folder that contains flutter code
In Any Flutter Application
- start from function "main()"
- main() functions calls State Widget class using "runApp()" function.
- State Widget can be StatelessWidget or StatefulWidget
- State Widget should implement "Build()" function and take "BuildContext" as parameter and return "Widget"
- Flutter consists of Widgets inside each others and on top it is common to use "MaterialApp" widget which contains definitions for the common material design settings
- "MaterialApp" widget take the child widget inside it using parameter "home"
"main()" function can be updated using fat arrow like this
- "MaterialApp" widget can contains "Scaffold" widget which apply the default material design colors
- "Scaffold" widget contains two common used parameters "appBar", "body"
- "Scaffold" widget "body" normally be a list of widgets under each others using "Column" widget
if we define variable X and view this variable on screen then change this variable, should it update too on screen? in stateless widget data will not updated after viewed but in stateful we will update its value using "setState" function and it will be reflected to the screen!
Shortcuts
Type stless to create a Stateless Widget Or stful to create Stateful widget
for more shortcut visit
https://medium.com/flutter-community/flutter-ide-shortcuts-for-faster-development-2ef45c51085b
Notes: any data entry component should be inside stateful widget
Text Widget
use it to display text on the screen, by default its size limited to its content, and to allow Text widget to take the full screen width, we should put it inside "container" widget that take the full width
Container Widget
contains the next properties
- Width
- Margin
- child
Private Class, Private Variable
to make any item private, just start it with underscore _
we can make parameters one mandatory and one optional with default value like this
class Child1 extends StatelessWidget {
String info1,info2;
Child1(String this.info1,{String this.info2=''});
}
you can call private function from another file or class by pass the function name as a parameter
No comments:
Post a Comment