lzhuor / my-awesome-flutter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My-Awesome-Flutter

Flutter

图1-1

Dart / Flutter Exception Capture

Dart: Single Thread

图2-12

Flutter:

  • FlutterError.reportError
void main() {
  FlutterError.onError = (FlutterErrorDetails details) {
    reportError(details);
  };
}
  • Sync: try/catch
try {
  // Execute build method  
  built = build();
} catch (e, stack) {
  // Alert when exception is captured 
  built = ErrorWidget.builder(_debugReportException('building $this', e, stack));
} 
  • Async: runZoned
try{
  Future.delayed(Duration(seconds: 1)).then((e) => Future.error("xxx"));
}catch (e){
  print(e)
}

Development Experiences

  • Setup
  • Debug / Inspection
  • Hot-reload (state is maintained due to JIT)

Package Management

  • pubspec.yaml
    • dev_dependences
    • dependencies
  • Dart Packages
  • Example
name: flutter_in_action
description: First Flutter application.

version: 1.0.0+1

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

Internationalisation

CI/CD and Distribution

  • Distribution of alpha, beta testing
    • Microsoft App Centre
  • CI/CD
    • Fastlane

Crash and Error tracking

Network / IO and API Client

State Management

Layout

  • Row
  • Column
  • Flex
  • Wrap / Flow
  • Stack / Positioned
  • Align

Forms

  • Form and Field concepts are natively implemented
    • Think about Formik
      • Context
      • Field
      • FormState

Widgets

  • Think about Component in React - declarative
  • Life Cycles

State

  • StatefulWidget
  • State

Button

Images / Icon

  • From assets, pubspec.yaml
  assets:
    - images/avatar.png
  • From Network
Image(
  image: NetworkImage(
      "https://xxx"),
  width: 100.0,
)

Font / TypoGraphy

  • Custom Font
 flutter:
   fonts:
     - family: Raleway
       fonts:
         - asset: assets/fonts/Raleway-Regular.ttf
         - asset: packages/my_package/fonts/Raleway-Medium.ttf
           weight: 500

Container

  • Padding
  • Constraints
  • DecoratedBox
  • Tranform
  • Scaffold / TabBar / BottomNavigation
  • Clip

Scrollable

  • SingleChildScrollView
  • ListView
  • GridView
  • CustomScrollView
  • ScrollController

Styling

  • WillPopScope
  • Provider / Theme
  • FutureBuilder / StreamBuilder

Charts / SVG

WebView

Animation (To be added)

File Organisation practices

  1. One common way
flutter_app
├── android
├── fonts
├── i10n-arb
├── imgs
├── ios
├── jsons
├── lib
└── test

lib
├── common
├── i10n
├── models
├── states
├── routes
└── widgets

About