Skip to content

Commit be1bcf5

Browse files
authored
Problem: Flutter 3.50 deprecates the Material library the app imports, so analysis fails on the new SDK (#153)
## Summary Flutter 3.50 deprecates `package:flutter/material.dart` and `package:flutter/cupertino.dart` in favour of the `material_ui` and `cupertino_ui` packages. On the new SDK, `dart analyze --fatal-infos` reports 175 infos, so CI fails until the app moves over. This PR upgrades to Flutter 3.50.0 / Dart 3.14.0, moves the app to `material_ui`, and takes the fixes the new releases unlock. **The migration is more than imports.** `material_ui` is a separate copy of Material with its own `Theme`, `Scaffold` and `MaterialLocalizations` types, and lookups are keyed by type: - gen-l10n in 3.50 still emits the deprecated `flutter_localizations` delegates (flutter/flutter#191072), which `material_ui` widgets cannot read. With the imports rewritten and nothing else, 14 `zh_TW`/`zh_CN` tests failed with no `MaterialLocalizations`. Every `MaterialApp` now uses `appLocalizationsDelegates` (`lib/core/l10n/`), and the generated `lib/l10n` is excluded from analysis until gen-l10n catches up. - `flutter_slidable` 4.0.3 was still on the framework copy, so swipe actions could not see the app theme (a `zh_TW` label lost the app's typography). 5.2.0 moves to `material_ui`. - `go_router` 18 already detected `material_ui`'s `MaterialApp`, which is why `_materialPage` existed. With the app on `material_ui`, it goes. Dart 3.14 brings no language features or formatter changes worth adopting here. The one new Flutter 3.50 widget with a real use is `SliverClipRRect`. ## Commits 1. `build(deps): move to Flutter 3.50.0, Dart 3.14.0 and material_ui`: the SDK bump, the scoped `dart fix --code=migrate_design_widgets` import rewrite, the delegates const, and the docs (`AGENTS.md`, `PRD.md`, `README.md`, `dependencies.md`). One commit because neither the bump nor the rewrite analyses on its own, and the rewrite and the delegate swap cannot test apart. 2. `build(deps): bump material_ui to 1.11.0 and cupertino_ui to 1.1.6`: bottom-sheet listener leak, `Switch` first-paint crash, `InputDecorator` fixes. 3. `build(deps): bump flutter_slidable to 5.2.0`: on `material_ui`; diagonal scrolls no longer open a row. A new test fails on 4.0.3. 4. `fix(shopping-list): clip rows to the card's rounded corners`: d52c902 lost the clip; restored with `SliverClipRRect` and `clipOverlap: ClipOverlapBehavior.none` (the default cuts a notch into the top row while scrolled). 5. `fix(app,deps): let system back leave the app after switching tabs with a sub-route open`: `go_router` 18.1.4. Regression test fails on 18.1.2. 6. `fix(data): delete the iOS CSV export copy that file_picker 13.3.3 leaves behind`: `file_picker_darwin` 2.5.1 moved the temp copy to `tmp/flutter_file_picker/<UUID>/`; without this, an unencrypted export would stay in `tmp/`. 7. `docs: update the toolchain facts for Flutter 3.50.0`: Gradle/AGP/KGP thresholds, the `flutter analyze --suggestions` false positive, and why `android.newDsl=false` stays (`android_file_picker`, not Flutter, now). 8. `refactor(app): let go_router build the MaterialPage for non-modal routes`: deletes `_materialPage` (−38 lines in `router.dart`). 9. `build(deps): bump the Riverpod stack to 3.5.0 and riverpod_lint to 3.2.0`: the six deprecated `exists` calls become `read(provider.exists)`. 10. `ci: fail when riverpod_lint is not running`: a `riverpod_lint` version that cannot resolve is skipped silently, and `dart analyze --fatal-infos` still prints "No issues found!". `tool/check_riverpod_lint.sh` adds a deliberate violation and fails unless it is reported. 11. `build(deps): bump build_runner to 2.17.1`: the hold is lifted; generated files are unchanged. 12. `feat(home,analysis): skip the day and period slide when Reduce Motion is on`: Flutter 3.50's `MediaQuery.reduceMotionOf` (iOS). New PRD Accessibility rule. ## Verification - Every commit passed the full CI sequence on its own in a fresh clone: `pub get --enforce-lockfile`, `build_runner` with no diff, `dart format`, `dart analyze --fatal-infos`, the riverpod_lint check (from commit 10), the 23 architecture tests and the full suite. The tip passes 2,353 tests. - Each fix has a test that was watched failing without it: the `zh` delegate tests, the slidable typography test (4.0.3), the shopping-list corner and scrolled-row hit tests, the back-button test (`go_router` 18.1.2), the CSV temp tests (including one that catches deleting more than the plugin's folder), and the Reduce Motion tests. `tool/check_riverpod_lint.sh` fails with `riverpod_lint: 3.1.2` and passes with 3.2.0. - An independent review covered correctness, project standards, tests and release risk, and a skeptic tried to refute each finding. It confirmed three minor findings; two are fixed in commits 10 and 12, and the third is the device list below. - The release arm64 APK is 196,632 bytes (+0.75%) larger than `main`'s. ## Before merging (devices) - [ ] `ios-nightly` passes: no `ios/Podfile`, `sqlite3.framework` embedded. The local iOS build cannot run (Xcode lacks the iOS 26.2 platform). - [ ] Swipe rows on all 7 Slidable lists; vertical and diagonal scrolls no longer open a row; the 4 s undo flows still work. - [ ] Shopping list: swiping the first and last rows stays inside the rounded corners; the card shadow still shows; a half-scrolled top row has no notch. - [ ] Undo snackbar at 2× font on a screen under about 342dp wide: "Undo" moves to its own row (Material's intended layout) and can still be tapped. - [ ] Android: push and pop Settings → About (WebView) and the Settings sub-pages in light and dark; no flicker or frozen frames. - [ ] Android back: Settings → Categories, switch to Home, press back, and the app exits. - [ ] iOS: export a CSV once saved and once cancelled; the app's `tmp/` has no `flutter_file_picker` folder afterwards. - [ ] iOS with Reduce Motion on: the Home day switch and the Analysis period switch appear without sliding. ## Not changed - `fl_chart` 1.3.1 is not taken: its rendering change applies only with a `transformationConfig`, which the app never sets. - Primary constructors (a Dart 3.13 feature) could remove about 1,000 lines but need a curated pass; that is a separate cleanup.
2 parents c3b7d81 + b6c302f commit be1bcf5

198 files changed

Lines changed: 835 additions & 499 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/android-release.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
uses: subosito/flutter-action@v2
4141
with:
4242
channel: stable
43-
flutter-version: 3.47.9
43+
flutter-version: 3.50.0
4444
cache: true
4545

4646
- name: Fetch packages

‎.github/workflows/check.yml‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
uses: subosito/flutter-action@v2
3838
with:
3939
channel: stable
40-
flutter-version: 3.47.9
40+
flutter-version: 3.50.0
4141
cache: true
4242

4343
- run: flutter --version
@@ -62,17 +62,22 @@ jobs:
6262
# (configured under `plugins:` in analysis_options.yaml), so its
6363
# warnings are reported every run. `flutter analyze` does not wait
6464
# for it and reports them only some of the time. `--fatal-infos`
65-
# keeps infos fatal, as `flutter analyze` does. A plugin that fails
66-
# to load is skipped without failing the run, so fail on that
67-
# message too rather than silently losing riverpod_lint.
65+
# keeps infos fatal, as `flutter analyze` does. A plugin that loads
66+
# but then fails prints that message, so fail on it too.
6867
run: |
6968
set -o pipefail
7069
dart analyze --fatal-infos 2>&1 | tee analyze.log
7170
if grep -q 'error occurred while executing an analyzer plugin' analyze.log; then
72-
echo '::error::riverpod_lint plugin failed to load'
71+
echo '::error::An analyzer plugin (riverpod_lint) failed while running; see the dart analyze output above.'
7372
exit 1
7473
fi
7574
75+
- name: Check riverpod_lint runs
76+
# A riverpod_lint version that cannot resolve on this Dart SDK is
77+
# skipped silently, so the step above passes without it. This fails
78+
# unless riverpod_lint reports a deliberate violation.
79+
run: tool/check_riverpod_lint.sh
80+
7681
test:
7782
name: Test
7883
runs-on: ubuntu-latest
@@ -84,7 +89,7 @@ jobs:
8489
uses: subosito/flutter-action@v2
8590
with:
8691
channel: stable
87-
flutter-version: 3.47.9
92+
flutter-version: 3.50.0
8893
cache: true
8994

9095
- name: Fetch packages
@@ -120,7 +125,7 @@ jobs:
120125
uses: subosito/flutter-action@v2
121126
with:
122127
channel: stable
123-
flutter-version: 3.47.9
128+
flutter-version: 3.50.0
124129
cache: true
125130

126131
- run: flutter pub get --enforce-lockfile

‎.github/workflows/ios-nightly.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
uses: subosito/flutter-action@v2
2929
with:
3030
channel: stable
31-
flutter-version: 3.47.9
31+
flutter-version: 3.50.0
3232
cache: true
3333

3434
- run: flutter pub get --enforce-lockfile

‎AGENTS.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ PR #135 removed 2,831 lines (1,614 hand-written `lib/` lines) without changing b
3030
- `DateTime.parse`, not substring parsing
3131
- `Locale.toString()`
3232
- Freezed `==` instead of revision counters
33-
- `AppLocalizations.localizationsDelegates` instead of listing the delegates by hand
33+
- `appLocalizationsDelegates` (`lib/core/l10n/`) instead of listing the delegates by hand. `AppLocalizations.localizationsDelegates` still lists the deprecated framework Material delegates, which `material_ui` widgets cannot read.
3434

3535
Don't pass `ThemeData` arguments that equal the defaults.
3636
- **Code only tests call.** No public method, parameter or mode in `lib/` should exist only so a test can reach it. Test through the production path.
@@ -112,7 +112,7 @@ l10n: the ARBs are in `l10n/` and the config is in `l10n.yaml`. `flutter pub get
112112
### CI workflows
113113

114114
- **`check.yml`** runs on PRs and pushes to `main`, except changes only under `docs/**`, `**/*.md`, `site/**` or the two site workflows. It runs three parallel jobs, all on `flutter pub get --enforce-lockfile`:
115-
- **Analyse:** `build_runner`, failing if the committed generated files change → `dart format --set-exit-if-changed .` → `dart analyze --fatal-infos`, which also fails if the riverpod_lint plugin doesn't load.
115+
- **Analyse:** `build_runner`, failing if the committed generated files change → `dart format --set-exit-if-changed .` → `dart analyze --fatal-infos`, which also fails if the output reports an analyzer-plugin error → `tool/check_riverpod_lint.sh`, which fails unless riverpod_lint reports a deliberate violation (a version that fails to resolve is otherwise skipped silently).
116116
- **Test:** `flutter test test/unit/architecture/` → `flutter test`.
117117
- **Android:** an arm64 APK, signed release if the signing secrets exist and debug otherwise, built with `--dart-define=FOREX_API_URL`.
118118
- **`android-release.yml`** runs on a `vX.Y.Z` tag. It fails unless the tag matches `version:` in `pubspec.yaml`, so bump that first. It then builds split signed APKs with SHA-256 checksums and uploads them to the GitHub Release.
@@ -164,7 +164,7 @@ The rules live in [`PRD.md` → *Security & Privacy*](PRD.md#security--privacy).
164164

165165
## Skills Available
166166

167-
Four Flutter skills from `flutter/agent-plugins` live in `.agents/skills/`, symlinked into `.claude/skills/` and pinned in `skills-lock.json`. They target a generic Flutter app, so read each one with its notes below. Where a skill disagrees with `PRD.md` or `docs/architecture/`, those win.
167+
Four Flutter skills from `flutter/agent-plugins` live in `.agents/skills/`, symlinked into `.claude/skills/` and pinned in `skills-lock.json`. They target a generic Flutter app, so read each one with its notes below. Their samples import `package:flutter/material.dart`, which Flutter 3.50 deprecates; Ledgerly code imports `package:material_ui/material_ui.dart` (and `package:cupertino_ui/cupertino_ui.dart`). Where a skill disagrees with `PRD.md` or `docs/architecture/`, those win.
168168

169169
### `flutter-apply-architecture-best-practices` (structuring a feature)
170170

@@ -198,7 +198,7 @@ Take its advice on measuring space (`MediaQuery.sizeOf`, `LayoutBuilder`), on `E
198198
Take its `WidgetTester`, `Finder` and pump workflow, and skip its setup step: `flutter_test` and `mocktail` are already dev dependencies. Then:
199199

200200
- **Location** → `test/widget/features/<feature>/`, or `test/widget/app/` for `lib/app/` and `lib/ui/core/widgets/`. Never the root of `test/`.
201-
- **Host** → a `MaterialApp` with `localizationsDelegates` and `supportedLocales` from `AppLocalizations`. Without `supportedLocales`, a `zh_TW` test silently renders English. If the widget navigates, use `MaterialApp.router` with a local `GoRouter` whose other routes are stubs (`home_screen_test.dart`). For the whole shell, use `test/support/test_app.dart`.
201+
- **Host** → a `MaterialApp` with `localizationsDelegates: appLocalizationsDelegates` and `supportedLocales: AppLocalizations.supportedLocales`. Without `supportedLocales`, a `zh_TW` test silently renders English; with `AppLocalizations.localizationsDelegates`, it fails with no `MaterialLocalizations`. If the widget navigates, use `MaterialApp.router` with a local `GoRouter` whose other routes are stubs (`home_screen_test.dart`). For the whole shell, use `test/support/test_app.dart`.
202202
- **Providers** → an `UncontrolledProviderScope` with `addTearDown(container.dispose)`; otherwise Drift's stream timers fail the teardown. Mock repositories with `mocktail` or fake the controller. Pass `retry: noProviderRetry` when a provider is meant to fail.
203203
- **`@Dependencies`** → required on `main()` and on any helper or test-only widget that pumps a scoped widget or reads a scoped provider, which covers most feature screens. Copy the names from the lint's "Missing dependencies" message ([`testing.md` → *Patterns*](docs/architecture/testing.md#patterns)). CI fails without them.
204204
- **Drift** → run every Drift query inside `tester.runAsync(...)`: the seed, inserts, lookups and reads after the flow. Creating the database and the container can stay outside.

0 commit comments

Comments
 (0)