fix: Add BoxFit.cover support for video backgrounds to fill entire screen#2
fix: Add BoxFit.cover support for video backgrounds to fill entire screen#2aliNassef wants to merge 2 commits into
Conversation
- replace deprecate code in main.dart 'in Example' withOpacity
WalkthroughThe changes update deprecated Flutter color APIs from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 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: 0
🧹 Nitpick comments (1)
example/lib/main.dart (1)
61-74: UpdatedfillColorfor text fields is consistent and clearUsing
Colors.white.withValues(alpha: 0.5)for bothTextFormFieldinstances gives a consistent semi‑transparent look and matches the surrounding card style.If this example grows, you could eventually centralize this into an
InputDecorationThemeor a shared variable, but for a small demo file duplication is acceptable.Please quickly verify contrast/readability of the text fields over bright video frames; if readability ever suffers, consider slightly increasing the alpha or adding a subtle border.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
example/pubspec.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
example/lib/main.dart(3 hunks)lib/background.dart(1 hunks)
🔇 Additional comments (3)
example/lib/main.dart (2)
41-43: Switch towithValues(alpha: ...)for card background looks fineUsing
Colors.white.withValues(alpha: 0.2)keeps the same translucent effect while aligning with the newer Color API. No behavioral issues from this change in the example.Please verify on a real device/emulator that the card translucency still matches your design intent, as Flutter rendering nuances can vary slightly by platform.
55-55: FlutterLogo formatting change is purely cosmeticCollapsing
FlutterLogoto a single-line constructor (FlutterLogo(size: 75)) is a no-op behavior-wise and improves readability a bit.lib/background.dart (1)
88-95: FittedBox + SizedBox pattern correctly achievesBoxFit.coverfor video backgroundWrapping the
VideoPlayerin:
- a
SizedBoxusing_videoController!.value.size.width/height, then- a
FittedBox(fit: BoxFit.cover, ...)that is itself stretched viaPositioned.fillis a solid pattern to make the video fill the available background while preserving aspect ratio. This should remove letterboxing/pillarboxing and align video behavior with the image
BoxFit.coverbranch.Be aware this will crop content at the edges for mismatched aspect ratios (which is usually what “cover” implies). That looks aligned with the PR goal, but it’s worth validating across a few device sizes/orientations and very wide/tall videos to confirm the cropping is acceptable for your assets.
Please verify visually with:
- At least one 16:9 video on a tall phone,
- One near‑square or vertical video,
to confirm the background fully fills the screen and cropping is acceptable in all cases.
🐛 Problem
Video backgrounds were not covering the full screen area, unlike image backgrounds which use BoxFit.cover. The VideoPlayer widget displays videos at their native dimensions by default, resulting in letterboxing or pillarboxing when the video aspect ratio doesn't match the screen.
✅ Solution
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.