Repository navigation
perf: optimize Flutter web portfolio - #13
Conversation
📝 WalkthroughWalkthroughThe project updates Flutter tooling and dependencies, migrates widget APIs and rendering, improves asset loading and tests, and adds Flutter web bootstrap, Nginx, Docker Compose, and deployment configuration. ChangesFlutter web modernization
Estimated code review effort: 4 (Complex) | ~45 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docker-compose.hosting.yml (1)
3-3: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winPin Nginx to an immutable digest.
nginx:latestmakes deployments non-reproducible and can change server behavior without a code change. Pin a tested Nginx release by digest.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docker-compose.hosting.yml` at line 3, Update the Nginx image reference in the compose configuration from the mutable nginx:latest tag to a tested Nginx release pinned by its immutable image digest.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/fluttter_to_github_pages.yml:
- Line 14: Set persist-credentials to false on the actions/checkout steps in
.github/workflows/fluttter_to_github_pages.yml (line 14),
.github/workflows/dart_score.yml (line 9), and
.github/workflows/firebase-hosting-merge.yml (line 14), preserving each
workflow’s existing explicit deployment or analyzer credentials.
---
Nitpick comments:
In `@docker-compose.hosting.yml`:
- Line 3: Update the Nginx image reference in the compose configuration from the
mutable nginx:latest tag to a tested Nginx release pinned by its immutable image
digest.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 25ec5c35-e58d-4c67-afc5-3b464384f880
⛔ Files ignored due to path filters (1)
pubspec.lockis excluded by!**/*.lock
📒 Files selected for processing (24)
.github/workflows/dart_analyze.yml.github/workflows/dart_score.yml.github/workflows/firebase-hosting-merge.yml.github/workflows/fluttter_to_github_pages.yml.gitignoredeploy/nginx.confdocker-compose.hosting.ymllib/app/data/information_data/info_projects.dartlib/app/ui/global_widgets/animated_background.dartlib/app/ui/global_widgets/appbar.dartlib/app/ui/global_widgets/projects_grid_widget.dartlib/app/ui/main_page/main_page.dartlib/app/ui/main_page/sections/certificates/widgets/certificate_widget.dartlib/app/ui/main_page/sections/contact_me/widgets/social_network_button.dartlib/app/ui/main_page/sections/diplomas/widgets/diploma_diploma_widget.dartlib/app/ui/main_page/sections/top_section/widgets/left_text_column.dartlib/app/ui/main_page/sections/work_instruments/widgets/small_icons_wrap_widget.dartlib/app/ui/project_page/widgets/project_images.dartlib/app/ui/projects_page/sections/top_section/widgets/projects_title.dartpubspec.yamltest/small_icons_wrap_widget_test.darttest/widget_test.dartweb/flutter_bootstrap.jsweb/index.html
💤 Files with no reviewable changes (2)
- lib/app/ui/global_widgets/projects_grid_widget.dart
- .gitignore
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/flutter_bootstrap.js`:
- Around line 10-25: Make the cleanup marker access in the service-worker
cleanup IIFE best-effort: guard both sessionStorage.getItem and
sessionStorage.setItem in try/catch so storage exceptions do not abort startup
or prevent _flutter.loader.load(). Preserve the existing cleanup and marker
behavior when storage is available, using cleanupKey and the current cleanup
flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 97adb441-acb0-4f48-a9ac-6c7200b9f466
⛔ Files ignored due to path filters (1)
pubspec.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
.github/workflows/dart_analyze.yml.github/workflows/dart_score.yml.github/workflows/firebase-hosting-merge.yml.github/workflows/fluttter_to_github_pages.ymlpubspec.yamlweb/flutter_bootstrap.js
💤 Files with no reviewable changes (4)
- .github/workflows/firebase-hosting-merge.yml
- .github/workflows/fluttter_to_github_pages.yml
- .github/workflows/dart_score.yml
- .github/workflows/dart_analyze.yml
🚧 Files skipped from review as they are similar to previous changes (1)
- pubspec.yaml
| if (sessionStorage.getItem(cleanupKey) === 'done') { | ||
| return true; | ||
| } | ||
|
|
||
| const registrations = await navigator.serviceWorker.getRegistrations(); | ||
| const currentUrl = window.location.href; | ||
| let removedController = false; | ||
|
|
||
| for (const registration of registrations) { | ||
| if (currentUrl.startsWith(registration.scope)) { | ||
| const removed = await registration.unregister(); | ||
| removedController = removedController || removed; | ||
| } | ||
| } | ||
|
|
||
| sessionStorage.setItem(cleanupKey, 'done'); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Repository files matching flutter_bootstrap.js:"
fd -a 'flutter_bootstrap\.js$' . | sed 's#^\./##'
file="$(fd 'flutter_bootstrap\.js$' . | head -n 1 || true)"
if [ -n "${file:-}" ]; then
echo
echo "Line count:"
wc -l "$file"
echo
echo "Relevant source:"
cat -n "$file" | sed -n '1,120p'
echo
echo "Search for retireLegacyServiceWorker / flutter.loader.load:"
rg -n "retireLegacyServiceWorker|_flutter\.loader\.load|sessionStorage|serviceWorker" "$file" || true
fi
echo
echo "Check package/index references (if any) to web/flutter_bootstrap.js:"
rg -n 'flutter_bootstrap\.js|retireLegacyServiceWorker|_flutter\.loader\.load' . -g '!build/**' -g '!dist/**' || trueRepository: mentoster/portfolio_flutter_web
Length of output: 3008
🌐 Web query:
MDN ServiceWorkerContainer unregister navigator.serviceWorker.controller
💡 Result:
To unregister a service worker, you must call the unregister method on a ServiceWorkerRegistration object, not on the ServiceWorkerContainer or the navigator.serviceWorker.controller property [1][2]. The navigator.serviceWorker.controller property is a read-only reference to the active ServiceWorker object controlling the current page [3]. It does not have an unregister method [4][3]. To programmatically unregister a service worker, follow these steps: 1. Retrieve the registration(s): Use navigator.serviceWorker.getRegistrations to get a list of all active registrations for the current origin [5][6]. 2. Call unregister: Iterate through the returned registrations and call the unregister method on each one [5][6]. Example code: if ('serviceWorker' in navigator) { navigator.serviceWorker.getRegistrations.then((registrations) => { for (const registration of registrations) { registration.unregister.then((boolean) => { if (boolean) { console.log('Service worker unregistered successfully.'); } }); } }); } The unregister method returns a Promise that resolves to true if the service worker was unregistered, or false if no registration was found [1]. Note that unregistering a service worker does not immediately stop it; it will finish any ongoing operations before it is removed [1][2]. Additionally, the change will not affect the current page until it is reloaded [5].
Citations:
- 1: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration/unregister
- 2: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration
- 3: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller
- 4: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer
- 5: https://stackoverflow.com/questions/33704791/how-do-i-uninstall-a-service-worker
- 6: https://stackoverflow.com/questions/49740931/unregistering-removing-a-service-worker
Do not let storage access block application startup.
sessionStorage.getItem or setItem can throw when browser storage is unavailable or blocked. Since that exception is not caught before the async IIFE reaches _flutter.loader.load(), the app can remain stuck on the loading screen. Treat the cleanup marker as best-effort: wrap storage access and continue bootstrapping if it fails.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/flutter_bootstrap.js` around lines 10 - 25, Make the cleanup marker
access in the service-worker cleanup IIFE best-effort: guard both
sessionStorage.getItem and sessionStorage.setItem in try/catch so storage
exceptions do not abort startup or prevent _flutter.loader.load(). Preserve the
existing cleanup and marker behavior when storage is available, using cleanupKey
and the current cleanup flow.
Summary
AssetManifestAPI instead of legacyAssetManifest.jsonparsingPerformance
build/web: ~63 MB -> ~53 MBmain.dart.jsgzip: 980,589 -> 978,871 bytesPlasmaRendererrepaint workloadVerification
flutter analyze --no-fatal-infos: 0 errors, 0 warnings; 59 pre-existing info-level noticesflutter test: 3/3 passedflutter build web --release: passed.github/workflowsCloudflared and nginx1-nginx6 were not modified. nginx7 remains on host port 4077. This PR is intentionally left open and unmerged.
Summary by CodeRabbit
New Features
Improvements