[Newbie] Chapter 1. Flutter overview
Content
- Installation
- New project
- Convention
Installation
Some steps you need to follow, I assume on macOS and java already installed
- Download and install Android Studio: https://developer.android.com/studio/install
- Open Android Studio and create new Android emulator
- Install XCode of course: Open App Store and download XCode -> Install it
- Download Flutter at https://flutter.dev/docs/development/tools/sdk/releases
- Extract flutter zip and place it anywhere you like in your computer
- Update your path, point to
flutter/bin
to make sure you typeflutter
on the terminal and it works - Verify installation with:
flutter doctor --android-licenses
Full documentation at https://flutter.dev/docs/get-started/install
New project
Follow below steps
- Open Android Studio
- Start a new Flutter project
- Select Start a new Flutter project
- Select Flutter Application -> Next
- Fill Project name and Project location -> Next
- Confirm your package name -> Finish
- Select emulator and Run
That’s all
Convention
Next thing I suggest you guys need to read a basic convention before putting your hand to code.
- Dart: https://dart.dev/guides/language/effective-dart/style
- Flutter: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
The document to too rich for a newbie, I will highlight some points:
Naming
- DO name Classes, enums, typedefs, and types using UpperCamelCase.
- DO name import prefixes, libraries, packages, directories, and source files using lowercase_with_underscores.
- DO name constant names and other identifiers using lowerCamelCase.
- DON’T use prefix letters.
Ordering
- DO place “dart:” imports first
- DO place “package:” imports before relative imports.
- PREFER placing external “package:” imports before other imports.
- DO specify exports in a separate section after all imports.
- DO sort sections alphabetically.
import 'dart:async';
import 'dart:html';
import 'package:bar/bar.dart';
import 'package:foo/foo.dart';
import 'package:my_package/util.dart';
import 'util.dart';
export 'src/error.dart';
Formatting
- Using trailing commas
- Using flutter format or Cmd + Alt + L on Android Studio to format you code
Sample structure naming
assets/
+ fonts/
+ icons/
lib/
+ models/remote/
+ pages/login/
+ login_bloc.dart
+ login_screen.dart
+ provider/
+ store/
+ remote/
+ local/
+ global.dart