add_to_app/books/README.md
Mimics a real world use-case of embedding Flutter into an existing Android app and demonstrates using Pigeon to communicate between Flutter and the host application.
These apps integrate the flutter_books module using the simpler build-together
project setup. They simulate a mock scenario where an existing book catalog
list app already exists. Flutter is used to implement an additional book details
page.
fullscreen.Book model class is used within the
Kotlin/Swift program, the Dart program and in the interop between Kotlin/Swift
and Dart. No manual platform channel plumbing needed for interop.
The api.dart/java/mm files generated from the
flutter_module_books/pigeon/schema.dart file are checked into source
control. Therefore pigeon is only a dev dependency with no runtime
requirements.
If the schema.dart is modified, the generated classes can be updated with
dart run pigeon --input pigeon/schema.dart \
--dart_out lib/api.dart \
--objc_header_out ../ios_books/IosBooks/api.h \
--objc_source_out ../ios_books/IosBooks/api.m \
--objc_prefix BK \
--java_out ../android_books/app/src/main/java/dev/flutter/example/books/Api.java \
--java_package "dev.flutter.example.books"
in the flutter_module_books directory.
Once you've understood the basics of add-to-app with android_fullscreen and
ios_fullscreen, this is a good sample to demonstrate how to integrate Flutter
in a slightly more realistic setting with existing business logic.
If you're just looking to get up and running quickly, these bash commands will fetch packages and set up dependencies (note that the above commands assume you're building for both iOS and Android, with both toolchains installed):
#!/bin/bash
set -e
cd flutter_module_books/
flutter pub get
# For Android builds:
open -a "Android Studio" ../android_books # macOS only
# Or open the ../android_books folder in Android Studio for other platforms.
# For iOS builds:
cd ../ios_books
pod install
open IosBooks.xcworkspace
See add_to_app/README.md for further help.