The Realtime 'interface' is an abstract class
which seems to be the correct way to do this in Dart - every class has an
'implicit interface' and then you make the
class abstract to present it as a more traditional interface as understood by the perhaps a Java programmer.
Dart libraries don't extend the Exception class, they implement its implicit interface. (see this comment).
For the moment it would not seem appropriate for our plugin to throw instances conforming to the implicit interface of the Error class, as this is perhaps more appropriate for programmer's failures on the Dart side of things. But time will tell.
The Android project does use AndroidX, which appears to be the default specified when Flutter created the plugin project, however Flutter's Java API for plugins (e.g. MethodChannel) appears to still use deprecated platform APIs like the UiThread annotation.
Once changes have been made to the platform code in the ios folder, especially if those changes involve changing the pod spec to add a dependency, then it may be necessary to force that build up stream with:
- Bump
s.versionin the pod spec - From example/ios run
pod install - Open Runner.xcworkspace in Xcode, clean and build
Otherwise, after making simple code changes to the platform code it will not get seen with a hot restart "R". Therefore if there's a current emulation running then use "q" to quit it and then re-run the emulator - e.g. with this if you've got both iOS and Android emulators open:
flutter run -d all
- Flutter plug-in package development, being a specialized package that includes platform-specific implementation code for Android and/or iOS.
- Flutter documentation, offering tutorials, samples, guidance on mobile development, and a full API reference.
Some files in the project are generated to maintain sync between
platform constants on both native and dart side.
Generated file paths are configured as values in bin/codegen.dart for toGenerate Map
Read about generation of platform specific constant files
- Add new type along with value in
_typeslist at bin/codegencontext.dart - Add an object definition with object name and its properties to
objectslist at bin/codegencontext.dart This will createTx<ObjectName>under which all properties are accessible.
Generate platform constants and continue
- update
getCodecTypein lib.src.codec.Codec so new codec type is returned based on runtime type - update
codecPairin lib.src.codec.Codec so new encoder/decoder is assigned for new type - update
writeValuein android.src.main.java.io.ably.flutter.plugin.AblyMessageCodec so new codec type is obtained from runtime type - update
codecMapin android.src.main.java.io.ably.flutter.plugin.AblyMessageCodec so new encoder/decoder is assigned for new type - add new codec encoder method in ios.Classes.codec.AblyFlutterWriter
and update
getTypeandgetEncoderso that new codec encoder is called - add new codec encoder method in ios.classes.codec.AblyFlutterReader
and update
getDecoderso that new codec decoder is called
- Add new method name in
_platformMethodslist at bin/codegencontext.dart
Generate platform constants and use wherever required
The new flutter analyzer does a great job at analyzing complete flutter package.
Running flutter analyze in project root will analyze dart files in complete project,
i.e., plugin code and example code
Or, use the good old dart analyzer
dartanalyzer --fatal-warnings lib/**/*.dart
dartanalyzer --fatal-warnings example/lib/**/*.dartWith just the Flutter tools installed, the following is observed:
ably-flutter % which dartdoc
dartdoc not found
?1 ably-flutter % which flutter
/Users/quintinwillison/flutter/bin/flutter
The dartdoc tool can be activated via the flutter command like this:
ably-flutter % flutter pub global activate dartdoc
Resolving dependencies...
Downloading...
Precompiling executables...
Precompiled dartdoc:dartdoc.
Installed executable dartdoc.
Warning: Pub installs executables into $HOME/flutter/.pub-cache/bin, which is not on your path.
You can fix that by adding this to your shell's config file (.bashrc, .bash_profile, etc.):
export PATH="$PATH":"$HOME/flutter/.pub-cache/bin"
Activated dartdoc 0.39.0.
And, indeed, on inspecting my path I could confirm that it wasn't present:
ably-flutter % echo $PATH
/Users/quintinwillison/.asdf/shims:/Users/quintinwillison/.asdf/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Users/quintinwillison/Library/Android/sdk/platform-tools:/Users/quintinwillison/flutter/bin
So I edited my configuration to add the PATH export suggested:
ably-flutter % vi ~/.zshrc
ably-flutter % source ~/.zshrc
ably-flutter % echo $PATH
/Users/quintinwillison/.asdf/shims:/Users/quintinwillison/.asdf/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Users/quintinwillison/Library/Android/sdk/platform-tools:/Users/quintinwillison/flutter/bin:/Users/quintinwillison/Library/Android/sdk/platform-tools:/Users/quintinwillison/flutter/bin:/Users/quintinwillison/flutter/.pub-cache/bin
And I was then able to find the dartdoc tool:
ably-flutter % which dartdoc
/Users/quintinwillison/flutter/.pub-cache/bin/dartdoc
And see that it had been installed globally in the Flutter context:
ably-flutter % flutter pub global list
dartdoc 0.39.0
ably-flutter % dartdoc
Documenting ably_flutter...
Initialized dartdoc with 195 libraries in 180.4 seconds
Generating docs for library ably_flutter from package:ably_flutter/ably_flutter.dart...
Validating docs...
warning: dartdoc generated a broken link to: DeveloperNotes.md, linked to from package-ably_flutter: file:///Users/quintinwillison/code/ably/ably-flutter
found 1 warning and 0 errors
Documented 1 public library in 5.6 seconds
Success! Docs generated into /Users/quintinwillison/code/ably/ably-flutter/doc/api
Releases should always be made through a release pull request (PR), which needs to bump the version number and add to the change log. For an example of a previous release PR, see #89.
The release process must include the following steps:
- Ensure that all work intended for this release has landed to
main - Create a release branch named like
release/1.2.3 - Add a commit to bump the version number
- Add a commit to update the change log
- Push the release branch to GitHub
- Open a PR for the release against the release branch you just pushed
- Gain approval(s) for the release PR from maintainer(s)
- Land the release PR to
main - Execute
flutter pub publishfrom the root of this repository - Create a tag named like
1.2.3and push it to GitHub
To check that everything is looking sensible to the Flutter tools, without publishing, you can use:
flutter pub publish --dry-run
We tend to use github_changelog_generator to collate the information required for a change log update.
Your mileage may vary, but it seems the most reliable method to invoke the generator is something like:
github_changelog_generator -u ably -p ably-flutter --since-tag v1.0.0 --output delta.md
and then manually merge the delta contents in to the main change log (where v1.0.0 in this case is the tag for the previous release).