1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00
Files
samples/add_to_app/books
dependabot[bot] 63a716671b Bump pigeon from 21.2.0 to 22.0.0 in /add_to_app/books/flutter_module_books (#2392)
Bumps [pigeon](https://github.com/flutter/packages/tree/main/packages)
from 21.2.0 to 22.0.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="6dd3e4e442"><code>6dd3e4e</code></a>
[pigeon] simplifies int handling across the codec, verifies ints in
collectio...</li>
<li><a
href="f63faf3c38"><code>f63faf3</code></a>
[interactive_media_ads]: Bump androidx.annotation:annotation from 1.8.1
to 1....</li>
<li><a
href="7c95aa6a3e"><code>7c95aa6</code></a>
[interactive_media_ads] Adds a contribution doc (<a
href="https://github.com/flutter/packages/tree/main/packages/issues/7460">#7460</a>)</li>
<li><a
href="ee0ad75fa2"><code>ee0ad75</code></a>
[webview]: Bump androidx.annotation:annotation from 1.8.1 to 1.8.2 in
/packag...</li>
<li><a
href="c5d03ee2f2"><code>c5d03ee</code></a>
[many] Remove dependency on <code>kotlin-bom</code> (<a
href="https://github.com/flutter/packages/tree/main/packages/issues/7088">#7088</a>)</li>
<li><a
href="2703d10608"><code>2703d10</code></a>
Remove unnecessary breaks in default clauses of switch statements (<a
href="https://github.com/flutter/packages/tree/main/packages/issues/7462">#7462</a>)</li>
<li><a
href="4e5d47e8f0"><code>4e5d47e</code></a>
[webview_flutter] Endorse macOS (<a
href="https://github.com/flutter/packages/tree/main/packages/issues/7457">#7457</a>)</li>
<li><a
href="89154b32c0"><code>89154b3</code></a>
[flutter_adaptive_scaffold] Fix landscape not showing in andUp (<a
href="https://github.com/flutter/packages/tree/main/packages/issues/7425">#7425</a>)</li>
<li><a
href="1ab1a712e5"><code>1ab1a71</code></a>
[go_router] Fixes replace and pushReplacement uri when only one route…
(<a
href="https://github.com/flutter/packages/tree/main/packages/issues/7433">#7433</a>)</li>
<li><a
href="871cd471ba"><code>871cd47</code></a>
[go_router] Fixes an issue where android back button pops wrong page.
(<a
href="https://github.com/flutter/packages/tree/main/packages/issues/7348">#7348</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/flutter/packages/commits/pigeon-v22.0.0/packages">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pigeon&package-manager=pub&previous-version=21.2.0&new-version=22.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-23 10:23:06 -04:00
..
2021-11-03 21:12:41 +10:00

books

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.

Description

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.

  • Similar to fullscreen.
  • 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.
    • On iOS, the Swift app does a similar fetch and parse of the Google Books API using iOS's built-in libraries.
  • 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.
    • On iOS, Storyboards are used to design the presentation of the books, just as one might do in a full UIKit app.
  • 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. 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

      flutter pub 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.

tl;dr

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

Requirements

  • Flutter
  • Android Studio
  • Cocoapods (iOS)

Questions/issues

See add_to_app/README.md for further help.