After installing Flutter you will have on Windows:
C:\src\flutter
---> Git repository ---> ~964 MbC:\src\flutter\bin
---> ToolsC:\src\flutter\bin\cache\dart-sdk
----> DART ---> ~418 Mb
Maybe you will need the following paths on PATH environment variable:
C:\src\flutter\bin
---> containsdart.bat
andflutter.bat
C:\Users\miguel\AppData\Local\Android\Sdk\build-tools\29.0.2
C:\Users\miguel\AppData\Local\Android\Sdk\emulator
=====> Flutter Depends on Android SKD which in turn "may" depend of the Android Studio
C:\Users\migue\AppData\Local\Android\Sdk
===> 8.1 GbC:\Program Files\Android\Android Studio
===> 1.5 Gb
====> Flutter also requires Android SDK Command-line Tools
====> Android Studio then go to Tools
-> SDK Manager
-> SDK Tools
-> Android SDK Command-line Tools
##################################
dart migrate --apply-changes
// migrate code for null safety
flutter doctor # Check installation
flutter create <sample app name>
flutter devices # listing available devices
flutter run
flutter run -d chrome
>>>>>
Type r
on console for hot reload of the application
emulator -list-avds # To list and then choose your emulator to run
##################################
main.dart
filevoid main()
- entry pointrunApp(<Widget instance>)
- inflate given widget and attach it to the screen- Custom Widget extends
Widget
e.g.class MyApp extends StatelessWidget...
- An App is a Widget (e.g. StatelessWidget)
StatelessWidget
- does not require mutable state
- are immutable, meaning that their properties can't change (all values are
final
).
- In Flutter almost everything is a Widget
MyApp
---
build()
---->
MaterialApp
----->
Scaffold
build
:- method that describes how to display the widget in terms of other, lower-level widgets.
- runs each time the App requires rendering.
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) ----> MaterialApp
Scaffold
frompackage:flutter/material.dart
hasappBar
andbody
properties
-
Type keyword
stful
and TAB to generateStatefulWidget
boilerplate code on your visual code editor. -
StatefulWidget
:- is immutable and can be Thrown away and Regenerated.
- its
State
object persists over the lifetime of the widget. - the
State
object class as the name of itsWidget
beginning with_
and finishing withState
. - E.g.
RandomWords
widget has a corresponding State class_RandomWordsState
. - The State class relates with its Widget through the type parameter of the base class,
i.e.
... extends State<RandomWords>
SatefulWidget
---- createState()
----> State<SatefulWidget>
--- build()
---> another Widget
NOTICE !!!!! The build()
on Widget may be called Many types and thus generate (new words on RandomWords app on every reload)
!!!!! On the other hand, the createState()
is called once and the resulting State persists (the same word persists).
- Handlers may call
setState()
to notify the framework that state has changed. setState()
----- triggers-- -->
State::build()
--->
Update UI
ListView
:
- Static --
ListView(children: ...list of widgets ...)
- Dynamic --
ListView.builder(itemBuilder: (context, index) {..return widget...})
Navigation:
- A page is called a route in Flutter terminology.
Navigator
manages a stack of routes.- Pushing a route onto
Navigator
's stack updates the display to that route. - Popping a route from
Navigator
's stack returns the display to the previous route.
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Widget()),
);
DART:
final
- imutable at runtimeconst
- compile time evaluation (static)_
- use prefix underscore on naming to enforce privacy.<ElementType>[]
- Strongly typed List{ElementType}[]
- Strongly typed Set (no repetitions)
##################################
- https://pub.dev/ --> Repository for Dart packages
pubspec.yaml
------> project dependencies fileflutter packages get
---> update dependenciesdart pub get
--- is implicit in the previous command and updatespubspeck.lock
with further dependencies of dependencies.