Flutter Basics๐Ÿš€

February 12, 2021

Core Basics

Flutter includes a modern react-style framework, a 2D rendering engine, ready-made widgets, and development tools. These components work together to help design, build, test, and debug apps. Everything is organised around a few core principles.

๐Ÿ‘‰ Widgets are the basic building blocks of a Flutter appโ€™s user interface. Unlike other frameworks that separate views, view controllers, layouts, and other properties, Flutter has a consistent, unified object model: the widget that works across the app. ๐Ÿค”

๐Ÿ›‘ Widgets form a hierarchy based on the composition they work with. Each widget can be nested inside, and inherits properties from its parent. There is no separate โ€œapplicationโ€ object. Instead, the root widget serves this role & handles the state of the app.

๐Ÿ‘‰ Flutter and Chrome use the same rendering engine โ€” SKIA. Instead of interacting with native APIs, it controls every pixel on the screen, which gives it the much necessary freedom from the legacy baggage as well as the performance it has.

Some commands I run while setting up Android studio and Flutter on my machine:

echo 'export ANDROID_HOME=/Users/$USER/Library/Android/sdk' >> ~/.bash_profile
 echo 'export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools' >> ~/.bash_profile

Supported Commands for update on macOS:

update sdk -u

Supported commands are:
android list target
android list avd
android list device
android create avd
android move avd
android delete avd
android list sdk
android update sdk
flutter doctor --android-licenses  

๐Ÿ‘‰ In case you face this error run ๐Ÿ‘‰

flutter doctor --android-licenses                                

ERROR: JAVA_HOME is set to an invalid directory: /usr/libexec/java_home

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

run the commands: ๐Ÿ‘‡

export JAVA_HOME=`/usr/libexec/java_home` 

echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile 
brew install android-platform-tools 

Installing Flutter with Homebrew

brew install --cask flutter
flutter upgrade 

create a flutter app

step 1: ๐Ÿ‘‰ Navigate to desired folder where you want to locate your app;

cd development/

step 2: ๐Ÿ‘‰ Run the command:

flutter create first_app
In order to run your application, type:

 $ cd first_app
 $ flutter run

Your application code is in first_app/lib/main.dart.
Flutter run key commands.

r Hot reload. ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ
R Hot restart.
h Repeat this help message.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

XCode

$ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
$ sudo xcodebuild -license
$ open -a Simulator

Up next