From 8625ac657466f4e22f9bb978f7c1a7be91862478 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sun, 4 Jan 2026 14:18:01 +0100 Subject: [PATCH] fix(build): ensure fresh Flutter build on each deploy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add flutter clean before build to prevent stale cached artifacts - Add VERSION build arg for explicit cache busting - Reorder build steps: clean → pub get → build_runner → health.json → build - Replace deprecated dart:html with package:web in iframe_view_web.dart - Add lint ignore to generate_health_json.dart Fixes issue where Docker layer caching kept old main.dart.js while regenerating health.json with new version number. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- CHANGELOG.md | 13 +++++++++++++ Dockerfile | 16 ++++++++++++---- .../presentation/widgets/iframe_view_web.dart | 19 ++++++++++--------- pubspec.yaml | 2 +- tool/generate_health_json.dart | 2 ++ 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f02e85..e80fb4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0] - 2026-01-04 + +### Changed +- **Dockerfile rebuild fix**: Added `flutter clean` before build to prevent stale cached artifacts + - VERSION build arg added for explicit cache busting + - Reordered build steps: clean → pub get → build_runner → health.json → flutter build + - Ensures deployed app always matches the version in health.json + +### Fixed +- Replaced deprecated `dart:html` with `package:web` in iframe_view_web.dart + - Uses `web.HTMLIFrameElement` instead of `html.IFrameElement` + - Fixes deprecation warnings for Flutter 3.x web builds + ## [1.0.12] - 2026-01-04 ### Changed diff --git a/Dockerfile b/Dockerfile index 989aa18..5ae4a84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,16 +3,24 @@ FROM ghcr.io/cirruslabs/flutter:stable AS builder WORKDIR /app -# Copy dependency files first for better caching -COPY pubspec.yaml ./ +# VERSION arg busts cache when version changes in pubspec.yaml +# Extract version: docker build --build-arg VERSION=$(grep '^version:' pubspec.yaml | cut -d' ' -f2) . +ARG VERSION=0.0.0 +RUN echo "Building version: $VERSION" -# Get dependencies (generates pubspec.lock) +# Copy dependency files first for better caching +COPY pubspec.yaml pubspec.lock* ./ + +# Get dependencies RUN flutter pub get # Copy the rest of the application COPY . . -# Generate code with build_runner +# Clean any cached build artifacts to ensure fresh build +RUN flutter clean && flutter pub get + +# Generate code with build_runner (after clean for fresh generation) RUN dart run build_runner build --delete-conflicting-outputs # Generate health.json with version info diff --git a/lib/features/front_hall/presentation/widgets/iframe_view_web.dart b/lib/features/front_hall/presentation/widgets/iframe_view_web.dart index 5f12d7e..c16d0fa 100644 --- a/lib/features/front_hall/presentation/widgets/iframe_view_web.dart +++ b/lib/features/front_hall/presentation/widgets/iframe_view_web.dart @@ -1,8 +1,8 @@ -import 'dart:html' as html; import 'dart:ui_web' as ui_web; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'package:web/web.dart' as web; /// Embedded iframe view for displaying external content (web only). /// @@ -31,7 +31,7 @@ class IframeView extends StatefulWidget { class _IframeViewState extends State { late final String _viewType; - late html.IFrameElement _iframe; + late web.HTMLIFrameElement _iframe; bool _isLoading = true; @override @@ -42,17 +42,18 @@ class _IframeViewState extends State { } void _createIframe() { - _iframe = html.IFrameElement() + _iframe = web.document.createElement('iframe') as web.HTMLIFrameElement ..src = widget.url ..style.border = 'none' ..style.width = '100%' ..style.height = '100%' - ..allow = 'fullscreen' - ..onLoad.listen((_) { - if (mounted) { - setState(() => _isLoading = false); - } - }); + ..allow = 'fullscreen'; + + _iframe.onLoad.listen((_) { + if (mounted) { + setState(() => _isLoading = false); + } + }); // Register the view factory ui_web.platformViewRegistry.registerViewFactory( diff --git a/pubspec.yaml b/pubspec.yaml index 878561e..17cdae6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.12+1 +version: 1.1.0+1 environment: sdk: ^3.10.4 diff --git a/tool/generate_health_json.dart b/tool/generate_health_json.dart index 25b2333..586c880 100644 --- a/tool/generate_health_json.dart +++ b/tool/generate_health_json.dart @@ -2,6 +2,8 @@ // Generates web/health.json from pubspec.yaml // Run: dart run tool/generate_health_json.dart +// ignore_for_file: avoid_print + import 'dart:convert'; import 'dart:io';