diet-guard/app/test/widgets/day_status_calendar_test_support.dart
Krzysztof kuhy Rudnicki 49144a2c49 Move the app to material_ui for Flutter 3.50
Flutter 3.50 deprecates package:flutter/material.dart; 73 deprecation
infos failed flutter analyze --fatal-infos, and four Dart pins were
behind (crdt_sync_flutter 0.8.2, flutter_local_notifications 23.0.2,
github_device_auth 0.5.0, sync_settings_ui 0.8.2). Those UI packages
now sit on material_ui, so the app has to as well or their widgets lose
MaterialLocalizations.

Imports swap one-for-one and dart fix re-sorted the directives; no
behaviour change. analyze is clean and all six test shards pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 09:25:34 +01:00

34 lines
1.4 KiB
Dart

// Shared fixtures for the day_status_calendar widget tests.
//
// Split out of `day_status_calendar_test.dart` for the repo's 250-line cap.
// Public because the names now cross a file boundary -- a leading underscore
// is library-private in Dart.
import 'package:diet_guard_app/ui/theme.dart';
import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
// The real app theme, not a bare default MaterialApp -- the widget under
// test reads its colors from Theme.of(context), so asserting against the
// same theme the app actually ships is what makes these assertions mean
// anything (a bare MaterialApp's own default colors would be arbitrary).
/// The real app theme the widget under test reads its colors from.
final ThemeData appTheme = buildAppTheme();
/// The app's status-color extension, for asserting per-day cell colors.
final AppStatusColors statusColors = appTheme.extension<AppStatusColors>()!;
/// Wraps [child] in a MaterialApp carrying the real app theme.
Widget wrapInApp(Widget child) => MaterialApp(
theme: appTheme,
home: Scaffold(body: child),
);
/// Returns the background color of the calendar cell showing [day].
Color colorOfDay(WidgetTester tester, String day) {
final container = tester.widget<Container>(
find.ancestor(of: find.text(day), matching: find.byType(Container)).first,
);
final decoration = container.decoration! as BoxDecoration;
return decoration.color!;
}