abhi3700 / My_Learning_Flutter

Learn Dart + Flutter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My_Learning-Dart

Learn everything about dart lang for Flutter to build cross-platform apps

Description

Objective: To learn how to create flutter apps so that I can plugin Rust code behind via C FFI. I actually didn't find any such platform like Flutter other than Qt.

Installation

CLI | dart

For macOS M1.

  • Install via package manager:
brew tap dart-lang/dart
brew install dart
  • To upgrade:
brew upgrade dart
  • To install a specific version:
brew install dart@3.1
  • List installed dart versions:
brew info dart
  • Switch to a specific version:
# unlink the current version
brew unlink dart@2.1

# link the desired version
brew link dart@3.1

VSCode extension

  1. Install Flutter extension.
  2. Cmd+Shift+P to open command palette and choose "Flutter: New Project".
  3. Now, it searches for flutter SDK. If not installed, then it will install on CLI seeking your permission via dialog prompt.

Quickstart

Dart App

This is to learn dart lang.

# create project
$ dart create -t console my_dart_app

# change to directory
$ cd my_dart_app

# run app
$ dart run
Building package executable... 
Built my_dart_app:my_dart_app.
Hello world: 42!

Now, you can write dart code and practice πŸ§‘β€πŸ’»πŸŽ‰.

Flutter App

This is to build Flutter apps for any platform.

  1. Choose "Flutter: New Project" in VSCode Command Palette.
  2. It then asks for choosing a template:

Suppose, you select 'Application'.

  1. And then it asks for destination folder.
  2. Finally, it asks for project name.
  3. Now, it will create a Flutter project in your desired folder.
  4. Then, it will open the project in VSCode in a new window.
  5. Now, you can build your Flutter app and practice πŸ§‘β€πŸ’»πŸŽ‰.
flutter run 
Downloading Web SDK...                                              5.9s
Downloading darwin-x64/FlutterMacOS.framework tools...              4.9s
Downloading darwin-x64/gen_snapshot tools...                       843ms
Downloading darwin-x64-profile/FlutterMacOS.framework tools...         3.6s
Downloading darwin-x64-profile tools...                            553ms
Downloading darwin-x64-profile/gen_snapshot tools...               843ms
Downloading darwin-x64-release/FlutterMacOS.framework tools...         3.2s
Downloading darwin-x64-release tools...                            522ms
Downloading darwin-x64-release/gen_snapshot tools...               933ms
Connected devices:
macOS (desktop) β€’ macos  β€’ darwin-arm64   β€’ macOS 14.4.1 23E224 darwin-arm64
Chrome (web)    β€’ chrome β€’ web-javascript β€’ Google Chrome 124.0.6367.62

No wireless devices were found.

[1]: macOS (macos)
[2]: Chrome (chrome)
Please choose one (or "q" to quit): 2
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...              9.9s
This app is linked to the debug service: ws://127.0.0.1:64137/72GU810bCOE=/ws
Debug service listening on ws://127.0.0.1:64137/72GU810bCOE=/ws

πŸ”₯  To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".

A Dart VM Service on Chrome is available at: http://127.0.0.1:64137/72GU810bCOE=
The Flutter DevTools debugger and profiler on Chrome is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:64137/72GU810bCOE=
Application finished.

It installs all the dependencies and runs the app that looks like this:

Congrats! πŸŽ‰

Likewise, you can also select "macOS" for desktop app that looks like this:

dart

CLI

Analyze

Analyze Dart code just like cargo check in rust.

dart analyze
Analyzing my_dart_app...               0.5s

warning β€’ bin/my_dart_app.dart:6:7 β€’ The value of the local variable 'name' isn't used. Try removing the variable or using it. β€’ unused_local_variable
warning β€’ bin/my_dart_app.dart:7:7 β€’ The value of the local variable 'year' isn't used. Try removing the variable or using it. β€’ unused_local_variable
warning β€’ bin/my_dart_app.dart:8:7 β€’ The value of the local variable 'antennaDiameter' isn't used. Try removing the variable or using it. β€’ unused_local_variable
warning β€’ bin/my_dart_app.dart:9:7 β€’ The value of the local variable 'flybyObjects' isn't used. Try removing the variable or using it. β€’ unused_local_variable
warning β€’ bin/my_dart_app.dart:10:7 β€’ The value of the local variable 'image' isn't used. Try removing the variable or using it. β€’ unused_local_variable

5 issues found.

for code:

  var name = 'Abhi';
  var year = 2024;
  var antennaDiameter = 3.7;
  var flybyObjects = ['Jupiter', 'Saturn', 'Uranus', 'Neptune'];
  var image = {
    'tags': ['saturn'],
    'url': '//path/to/saturn.jpg',
  };

doc

# doesn't create any output folder
dart doc --dry-run

# creates output folder
dart doc

# creates output folde to specified path
dart doc --output=docs

Language

  • var used like let mut in rust, let in typescript for auto type inference.

References

About

Learn Dart + Flutter

License:MIT License


Languages

Language:JavaScript 74.8%Language:C++ 6.3%Language:CSS 5.6%Language:HTML 5.5%Language:CMake 5.2%Language:Dart 1.8%Language:Swift 0.5%Language:C 0.4%Language:Kotlin 0.0%Language:Objective-C 0.0%