Skip to content

flutterflow_live_activity: JSON spec, validate/generate/apply and a typed app API - #3

Merged
ayushflow merged 9 commits into
mainfrom
ayush/live-activity-cli
Nov 27, 2026
Merged

ayushflow merged 9 commits into
mainfrom
ayush/live-activity-cli

Conversation

@ayushflow

@ayushflow ayushflow commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #2; review that first. This PR adds the JSON spec, the commands and the typed app API on top of it.

What this does

Makes flutterflow_live_activity usable from any Flutter project the way flutterflow_home_widget is: describe Live Activities in JSON, then validate, generate or apply them.

  • Layout JSON in the core (flutterflow_native_layout, lib/src/layout/layout_json.dart): reads and writes the layout node JSON, including the nodes only Live Activity cards use (count-up text, Image values, timed bars, stages, root mode). The home widget package now reads and writes its layouts through it.
  • JSON spec for LiveActivityApp, with specVersion from the start:
    • Fixed templates are presets: "template": "progress" with no values or surfaces.
    • custom activities hold one layout per surface. If islandExpanded is left out, it is filled from lockScreen.
    • Optional overrides: androidDefaults and stagesSpecs, for specs that need Android defaults or stage colours different from what the package derives. The writer leaves them out when they equal the derived values.
  • validate: limits (24 values, 4 images, 80 layout nodes, 2 to 6 stages, defined once in the package), taps (a card can only open a page), value types, surfaces, Android slots and presets.
  • Commands (dart run flutterflow_live_activity <validate|generate|apply>):
    • generate writes the files to a folder.
    • apply writes them into a Flutter project: the widget extension target and files in Xcode, the Android module, the Dart plugin package and the Info.plist entries. A second run changes nothing.
  • Typed app API: for each activity, a generated Dart class with typed start, update and end. It fills the accent colour, icon and channel name from the spec. The platform channel is unchanged.
  • Bundle id check in apply: iosBundleId is the app's id (the extension is <id>.LiveActivity). apply reads the Runner's PRODUCT_BUNDLE_IDENTIFIER in every build configuration before writing anything and refuses, naming both ids, when the spec's does not match (iOS rejects an embedded extension whose id is not prefixed with the app's). A Runner id that is a build setting ($(...)) is a warning. The example spec and README say the id must start with the app's own.
  • Narrower core API: SpecJsonReader, NativeLayoutJsonException and the layout JSON functions are in package:flutterflow_native_layout/layout_json.dart, no longer exported from the main library.
  • example/live_activities.json, README sections, and changelog entries under Unreleased.

Changes to existing behaviour

How it was tested

Check Result
flutterflow_live_activity tests 141 pass
flutterflow_native_layout / flutterflow_home_widget tests 52 / 26 pass
JSON round trip: 41 activities from 57 sample apps (25 custom cards, every template and surface). Each spec is turned into JSON and back, then generated Byte-identical to generating from the spec directly
Generated native files for 58 sample apps, 3,745 files Identical to #2
Home widget example Identical to v0.2.0
apply into a fresh flutter create app Run 1 writes 28 files, run 2 changes nothing. flutter analyze is clean with the app calling the typed API. flutter build apk --debug builds
apply with a mismatching bundle id Refuses with both ids; the app's files are unchanged
dart analyze --fatal-infos, dart format Clean

Review questions, answered

  1. Overrides: keep androidDefaults and stagesSpecs until codegen moves onto the package.
  2. Expanded island: keep the fallback; it matches the editor.
  3. Removed activities (manifest): a follow-up, low priority.
  4. Core API: narrowed. SpecJsonReader stays under src/, exported from layout_json.dart only.
  5. Card height and limits: codegen imports them from here once it depends on the package.
  6. Home widget reader using SpecJsonReader: a follow-up.
  7. SDK floors: fine as they are.

🤖 Generated with Claude Code

@ayushflow
ayushflow requested a review from sbis04 November 26, 2026 09:40

@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. Checked: CI steps pass locally (135 / 52 / 26), home widget output is byte-identical to #1, and apply into a fresh flutter create app is idempotent (28 files, then 0). flutter analyze is clean with the typed API called, and flutter build ios --simulator builds with LiveActivity.appex embedded. The expanded-island fallback is a separate model and empty image defaults are rejected, so my #2 notes are covered for JSON specs. Limits match ff_protos/live_activity_layouts.dart.

One suggestion: apply doesn't check iosBundleId against the Runner's PRODUCT_BUNDLE_IDENTIFIER. Applying the example spec as-is to an app with another id succeeds, then flutter build ios fails with "Embedded binary's bundle identifier is not prefixed with the parent app's bundle identifier" (and the keychain group is wrong too). It already parses the pbxproj, so it could refuse on a mismatch.

On the questions:

  1. Keep the overrides until codegen moves onto the package.
  2. Keep the fallback, it matches the editor.
  3. Manifest: nice to have, low priority.
  4. Narrower: keep SpecJsonReader under src/ behind a JSON-specific export.
  5. Yes, codegen should import the limits from here once it depends on the package (they're duplicated in ff_protos today).
  6. Yes, worth a follow-up.
  7. Fine as is.

@ayushflow

Copy link
Copy Markdown
Contributor Author

Thanks for checking all of that. I'll add both to this PR before it merges, since the second one changes public API:

  • apply will refuse when iosBundleId isn't prefixed with the Runner's PRODUCT_BUNDLE_IDENTIFIER.
  • SpecJsonReader and NativeLayoutJsonException move under src/, behind a JSON-specific export.

The manifest (3) and the home widget reader using SpecJsonReader (6) can be follow-ups. I'll comment here when they're pushed.

@ayushflow

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Two changes, pushed to this branch:

  • 0675111 apply checks the bundle id. It reads the Runner's PRODUCT_BUNDLE_IDENTIFIER in every build configuration before writing anything, and refuses with both ids and the spec field when iosBundleId does not match (the extension is <iosBundleId>.LiveActivity, so the spec's id must be the app's or start with it and a dot; with an Image value it must be the app's, as the keychain group is built from it). A Runner id that is a build setting ($(...)) is a warning. applyLiveActivities takes an onWarning callback. The example spec's id is now com.example.courier and the quick start creates the app as courier. Tests: match, nested id, mismatch (tree unchanged), one configuration mismatching, an unresolvable variable.
  • 218f5d2 the layout JSON API is in package:flutterflow_native_layout/layout_json.dart (SpecJsonReader, NativeLayoutJsonException, nativeLayoutFromJson, nativeLayoutToJson, the color helpers). The main library no longer exports them; the home widget and Live Activity packages import it from there.
  • 4221ec0 changelog entries.

Your answers are in the PR description. Tests: LA 141, core 52, home widget 26 pass; analyze and format are clean; generated output for the sample apps is unchanged.

ayushflow and others added 8 commits November 27, 2026 08:00
nativeLayoutFromJson and nativeLayoutToJson move here from the home widget
package's json.dart, so Live Activity cards share one layout format. With
card: true the reader also takes what only a card draws: a count-up text,
an image showing an Image value, a bar timed between two dates, a Stages
bar, and the layout's stagesSpecs. darkColors and behind read a layout for
the Dynamic Island (dark colours, labels fitted on black). The writer
leaves out stagesSpecs that are what the bars draw.

SpecJsonReader and NativeLayoutJsonException give readers of other
spec JSON the same paths and messages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The layout reader and writer in json.dart are the core's now. The format
is unchanged, except that the forms only a Live Activity card draws are an
error in a widget's layout instead of being ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
liveActivityAppFromJson and liveActivityAppToJson read and write the spec
with specVersion 1. Layouts are the core's layout JSON with the card
forms. A fixed template is a preset with no values, layouts or Android
settings. Without an islandExpanded layout the Lock Screen one is read for
the island; null means none. The writer leaves out what the reader fills
in the same way (that island, Android defaults that are the values' own),
so read, write and read again generates the same files. Unknown fields are
errors, with their path.

validateLiveActivityApp lists the spec's problems with paths: limits (24
values, 4 Image values, 80 nodes, 2 to 6 stages, kept in spec.dart), value
types and defaults, surfaces, bindings, Stages bars, taps, card heights
and Android slots and defaults; and warnings that do not stop generation.

liveActivityTypedApiFiles writes package:ff_live_activity/live_activities.dart:
a class per activity with typed start, update and end over FFLiveActivity,
filling template, accent colour, icon, channel name and defaults from the
spec. It is not part of generateLiveActivityFiles, whose output is
unchanged.

example/live_activities.json is a complete spec.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
applyLiveActivities (io.dart) adds an app's Live Activities to a flutter
create app: the generated files and typed API, the plugin in pubspec.yaml,
the extension target in project.pbxproj (signed with the Runner's
development team per configuration), NSSupportsLiveActivities in the
Runner's Info.plist and, for an Image value, the keychain group in
Info.plist and Runner.entitlements. It works everything out before
writing, writes only what changed, and a second run changes nothing. A
target added for a spec with other files is an error rather than being
rewritten.

bin/flutterflow_live_activity.dart runs validate, generate and apply;
problems stop generate and apply, warnings do not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tch the Runner's

iosBundleId is the app's id (the extension is <id>.LiveActivity). apply now
reads the Runner's PRODUCT_BUNDLE_IDENTIFIER in every build configuration
before writing anything, and refuses with both ids when the spec's does not
match: iOS rejects an embedded extension whose id is not prefixed with the
app's. A Runner id that is a build setting is reported as a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SpecJsonReader and NativeLayoutJsonException are no longer exported from
flutterflow_native_layout.dart. package:flutterflow_native_layout/layout_json.dart
exports them with nativeLayoutFromJson, nativeLayoutToJson and the color
helpers; the home widget and Live Activity packages import it from there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ayushflow
ayushflow force-pushed the ayush/live-activity-cli branch from 4221ec0 to 650e2e1 Compare November 27, 2026 04:01
@ayushflow
ayushflow changed the base branch from ayush/live-activity-package to main November 27, 2026 04:01
All three packages move to 0.3.0 together. The README shows how to depend
on the Live Activity package from the same tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ayushflow
ayushflow merged commit f28e0bc into main Nov 27, 2026
1 check passed
@ayushflow
ayushflow deleted the ayush/live-activity-cli 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