project types
application
-
a whole new application
plugin
-
exposing an android or ios api for developers
package
-
creating a pure dart component, like a new widget
module
-
creating a flutter component to add to an android app
commonly used commands
flutter for web (in progress)
for details, check article
flutter for desktop
-
by google
-
by a 3rd party company, commercial license, check article
problem notes
debug app with blank screen
One possible reason is your environment variable http_proxy/https_proxy has block the communication between flutter compiler and flutter vm on the remote device. If this is the case, we just set an environment variable no_proxy with 127.0.0.1 included to solve this problem.
Memo
Releationships between Widget, Element and RenderObject
[todo] - refer to
Cocoapods
You can install Cocoapods via two ways: homebrew and rubygems
by homebrew
$ brew install cocoapods
by rubygems
$ sudo gem install cocoapods
for details, refer to
rubygems
replace source with chinese mirror
$ gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
$ gem sources -l
Json and Serialization
- For small project - decode manually
- or, you can use the following online tool to help you generate the serialization logic
- For medium to large projects - code generation
-
- add a dev dependency -
build_runner: ^1.0.0 - one-time code generation -
$ flutter pub run build_runner build - generating code continuously -
$ flutter pub run build_runner watch - this lib will generate a new file named xxx.g.dart with all generated utility functions, however, you’ll need to write the below boilerplate functions
factory XXX.fromJson(Map<String, dynamic> json) => _$XXXFromJson(json);Map<String, dynamic> toJson() => _$XXXToJson(this);
- Flutter does not support runtime reflection, that is why you cannot find a GSON/Jackson/Moshi equivalent in flutter.
- Runtime reflection interferes with tree shaking. With tree shaking, you can “shake off” unused code from your release builds. This optimizes the app’s size significantly.
For details, refer to
Hot restart/reload and debugging dart code for flutter module
Execute the following command under flutter module root directory,
$ flutter attach
Then, launch your application in debug mode from Android Studio or Xcode.
it seems there’s a problem in attaching a ios emulator, refer to
resolved in new version (1.7.8+hotfix.3)
References
study resources