Flutter for Android developers
Table of contents
- Overview of Flutter
- Installing Flutter
- Working with an editor
- Learning Dart
- Flutter introductory resources
- Architecture and state management
- Dependency Injection
- Navigation & routing
- Network requests and Serialization
- Android functionality and corresponding plugins
- Orientation change?
- Declarative vs Imperative
- Android views and their corresponding Flutter widgets
- Hint on an EditText
- Custom Views/Canvas drawing
- Gesture and click listeners
- Glide/Picasso/Fresco(Image loading)?
- Resource management
- Local notifications
- Communicating with native platform
- Background processing
- Testing and profiling
- Flavors and deployment
- Samples and tutorials
Overview of Flutter
Working with an editor
Flutter introductory resources
Tensor Programming excellent programming videos, regularly posts Flutter tutorials
Architecture and state management
While there's no Dagger 2 in Flutter, there's inject.dart.
Navigation & routing
Flutter uses Navigator for navigation.
Handling incoming intents
Network requests and Serialization
No, there's no Retrofit or Gson/Moshi in Flutter.
Android functionality and corresponding plugins
Both activities and fragments are represented as a Widget in Flutter.
Declarative vs Imperative
In the imperative style, you would typically go to ViewB’s owner and retrieve the instance b using selectors or with findViewById or similar, and invoke mutations on it (and implicitly invalidate it). For example:
// Imperative style b.setColor(red) b.clearChildren() ViewC c3 = new ViewC(...) b.add(c3)
In the declarative style, view configurations (such as Flutter’s Widgets) are immutable and are only lightweight “blueprints”. To change the UI, a Widget triggers a rebuild on itself (most commonly by calling setState() on StatefulWidgets in Flutter) and constructs a new Widget subtree.
// Declarative style return ViewB( color: red, child: ViewC(...), )
Android views and their corresponding Flutter widgets
The most common Android views and their corresponding Flutter widgets are here:
Hint on an EditText
body: Center( child: TextField( decoration: InputDecoration(hintText: "This is a hint"), ) )
Custom Views/Canvas drawing
Flutter has similar to Android Canvas API.
To create custom widgets you compose smaller widgets.
Gesture and click listeners
Image.network( 'https://raw.githubusercontent.com/flutter/website/master/src/_includes/code/layout/lakes/images/lake.jpg', )
It also supports gifs!
Unfortunately, Image.network does not support placeholders and/or caching. To achieve those, please see the following recipes:
Flutter uses Dart's own build system, and the Pub package manager. You can read more about here.
Packages allow you to use Flutter packages or access underlying platform features in a form of a library.
For local notifications you would have to rely on a 3rd party plugin.
To Log in with Facebook, use flutter_facebook_login plugin.
Communicating with native platform
- Offloading tasks to a background thread
- Background processes
- Executing Dart in the Background with Flutter Plugins and Geofencing