mirror of https://github.com/flutter/samples.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Brett Morgan
d88f131982
|
4 years ago | |
---|---|---|
.. | ||
lib | 5 years ago | |
pigeon | 5 years ago | |
test | 5 years ago | |
.gitignore | 5 years ago | |
.metadata | 5 years ago | |
README.md | 5 years ago | |
pubspec.lock | 4 years ago | |
pubspec.yaml | 5 years ago |
README.md
Books add-to-app sample
This application simulates a mock scenario where an existing app with business logic and middleware already exists. This sample demonstrates how to do an add-to-app Flutter integration into existing conventions.
This application also utilizes the Pigeon plugin to avoid manual platform channel wiring. Pigeon autogenerates the platform channel code in Dart/Java/Objective-C to allow interop using higher order functions and data classes instead of string-encoded methods and serialized primitives.
The Pigeon autogenerated code is checked-in and ready to use. If the schema
in pigeon/schema.dart
is updated, the generated classes can also be re-
generated using:
flutter pub run pigeon \
--input pigeon/schema.dart \
--java_out ../android_books/app/src/main/java/dev/flutter/example/books/Api.java \
--java_package "dev.flutter.example.books"
Demonstrated concepts
- An existing books catalog app is already implemented in Kotlin and Swift.
- The platform-side app has existing middleware constraints that should also
be the middleware foundation for the additional Flutter screen.
- On Android, the Kotlin app already uses GSON and OkHttp for networking and references the Google Books API as a data source. These same libraries also underpin the data fetched and shown in the Flutter screen.
- iOS TODO.
- The platform application interfaces with the Flutter book details page using
idiomatic platform API conventions rather than Flutter conventions.
- On Android, the Flutter activity receives the book to show via activity intent and returns the edited book by setting the result intent on the activity. No Flutter concepts are leaked into the consumer activity.
- iOS TODO.
- The pigeon plugin is used to generate
interop APIs and data classes. The same
Book
model class is used within the Kotlin/Swift program, the Dart program and in the interop between Kotlin/Swift and Dart.