Dart / Flutter Exception Capture
void main () {
FlutterError .onError = (FlutterErrorDetails details) {
reportError (details);
};
}
try {
// Execute build method
built = build ();
} catch (e, stack) {
// Alert when exception is captured
built = ErrorWidget .builder (_debugReportException ('building $this ' , e, stack));
}
try {
Future .delayed (Duration (seconds: 1 )).then ((e) => Future .error ("xxx" ));
}catch (e){
print (e)
}
Setup
Debug / Inspection
Hot-reload (state is maintained due to JIT)
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
Distribution of alpha, beta testing
CI/CD
Network / IO and API Client
Row
Column
Flex
Wrap / Flow
Stack / Positioned
Align
Form and Field concepts are natively implemented
Think about Component in React - declarative
Life Cycles
From assets, pubspec.yaml
assets:
- images/avatar.png
Image(
image: NetworkImage(
"https://xxx"),
width: 100.0,
)
flutter:
fonts:
- family: Raleway
fonts:
- asset: assets/fonts/Raleway-Regular.ttf
- asset: packages/my_package/fonts/Raleway-Medium.ttf
weight: 500
Padding
Constraints
DecoratedBox
Tranform
Scaffold / TabBar / BottomNavigation
Clip
SingleChildScrollView
ListView
GridView
CustomScrollView
ScrollController
WillPopScope
Provider / Theme
FutureBuilder / StreamBuilder
Flutter SVG
Charts Flutter (Google)
Syncfusion Flutter Chart
Official WebView (experimental)
Community WebView
File Organisation practices
One common way
flutter_app
├── android
├── fonts
├── i10n-arb
├── imgs
├── ios
├── jsons
├── lib
└── test
lib
├── common
├── i10n
├── models
├── states
├── routes
└── widgets