Skip to content

Add flutterflow_live_activity: Live Activities from a typed spec - #2

Merged
ayushflow merged 4 commits into
mainfrom
ayush/live-activity-package
Nov 27, 2026
Merged

ayushflow merged 4 commits into
mainfrom
ayush/live-activity-package

Conversation

@ayushflow

@ayushflow ayushflow commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Follows #1. This PR adds only the new package.

What this does

Adds flutterflow_live_activity under packages/flutterflow_live_activity/. It generates every file an app needs for Live Activities (iOS) and Live Updates (Android) from a typed Dart spec, built on flutterflow_native_layout the same way this repo's home widget package is.

  • Spec (lib/src/spec.dart): LiveActivityApp holds LiveActivityDefinitions. Each one has a key, name, description, template, accent colour, icon, Android channel name, values, one layout per surface, and the Android presentation and slots.
    • Templates: the four fixed ones (progress, etaTimer, score, queueStatus) are presets with hand-written SwiftUI and Kotlin. custom draws a layout per surface.
    • Value types: the home widget types plus image.
    • Surfaces: Lock Screen, expanded island, compact leading and trailing, and minimal.
    • androidDefaults: an optional override, because Android shows some default values differently from iOS today.
  • Generators:
    • iOS: the ActivityKit widget extension, custom card views, the image store, Info.plist entries and the Xcode project fragments.
    • Android: the Live Update service, the notification layouts and drawables for custom cards, and the standard presentation's slots.
    • Dart: the app-side plugin package.
  • lib/flutterflow_live_activity.dart exports the spec, the channel contract, generateLiveActivityFiles and the per-platform generators, and re-exports the core. native_layout.dart re-exports just the core.
  • CI gets and tests the package; the changelog notes it under Unreleased.

A JSON form of the spec with validate, generate and apply commands, plus a typed app API, comes in a follow-up PR.

How it was tested

Check Result
flutterflow_live_activity tests 80 pass
flutterflow_native_layout and flutterflow_home_widget tests 45 and 26 pass
Generated native files for 58 sample apps (Live Activity cards of every template and surface, home widgets, both in one app), 3,745 files Identical to the code this replaces, apart from #1's carriage-return escape
dart analyze No issues

Question

With this package in place, a consumer that only needs the core API can import it from flutterflow_live_activity/native_layout.dart. That makes flutterflow_home_widget/native_layout.dart from #1 (the 68-name show list) optional. Keep it for people who use only the home widget package, or drop it?

🤖 Generated with Claude Code

ayushflow and others added 3 commits November 26, 2026 12:53
A new package next to flutterflow_native_layout. LiveActivityApp lists an
app's Live Activities: fixed templates (progress, ETA timer, score, queue
status) and Custom cards with their own values and one NativeLayoutModel
per surface. generateLiveActivityFiles writes the ff_live_activity plugin
(Dart, Swift, Kotlin), the iOS widget extension and, for Custom cards,
their SwiftUI views, Android card specs and RemoteViews drawing. The
pbxproj fragments and Info.plist entries add the extension to an app.

The spec carries specVersion so a JSON form can map onto it later.
native_layout.dart re-exports the layout core for code that reaches it
through this package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spec getters (Android slots, defaults, image fallbacks, keychain groups),
the channel contract in the generated Swift and Dart, the source checks
that no contract name is retyped, Custom card views, pictures, Android
card specs and drawing, and the Xcode project fragments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ayushflow
ayushflow requested a review from sbis04 November 26, 2026 09:00
@ayushflow
ayushflow changed the base branch from ayush/native-layout-core to main November 26, 2026 09:08

@sbis04 sbis04 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Compared every generator file against flutterflow_codegen/lib/components/live_activities/ on main: the changes are the ProjectInfo to spec swap and doc wording. Wire names and the pbxproj device family come out the same. CI steps pass locally for all three packages.

Non-blocking, mostly for the codegen adapter that builds the spec:

  1. The expanded island no longer falls back to the Lock Screen layout here. The adapter must put that (dark-read) copy in surfaces[islandExpanded], or the island renders empty.
  2. The generator clears the root fill and refits stage label colours on the caller's expanded model. If that model were shared with lockScreen, Android (generated after iOS) would lose the card background. A copy or an identical() assert would make the "must not be shared" note safe.
  3. The old Android code skipped Image values with an empty default. imageFallbacks keeps '', so the adapter should pass null for "no default".

On the question: I'd keep flutterflow_home_widget/native_layout.dart, so home-widget-only consumers don't need the Live Activity package to reach the core.

Question: where does the codegen adapter that builds LiveActivityApp from the project live? The 58-app identical-output check depends on it, and it isn't in this PR. Can you link the branch, so points 1 to 3 can be checked against it before codegen switches over?

The generator drops the top fill of the expanded island's model in place,
so a model shared with the Lock Screen would lose its fill there too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ayushflow

Copy link
Copy Markdown
Contributor Author

Thanks, all three checked.

The code that builds LiveActivityApp from a FlutterFlow project is in FlutterFlow/flutterflow#9192 (draft until a tag has both packages), file packages/flutterflow_codegen/lib/components/live_activities/util/live_activity_app.dart.

  1. Expanded island fallback: _surfaces reads the Lock Screen layout a second time with island: true when a card has no expanded island layout, and puts that model in surfaces[islandExpanded]. It's a separate, dark-read model, not the Lock Screen one.
  2. Shared model: added a check in 7e9359d. Generating now throws an ArgumentError if the expanded island model is the same object as another surface's, and the doc on surfaces says so. There's a test for it.
  3. Empty image default: _defaultValue returns null for an Image value whose default is empty, so Android skips it as before.

Keeping flutterflow_home_widget/native_layout.dart as you suggested.

@ayushflow
ayushflow merged commit 7d0a3eb into main Nov 27, 2026
1 check passed
@ayushflow
ayushflow deleted the ayush/live-activity-package branch November 30, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants