feat: Fix framework assertion when adding an item

This commit is contained in:
2026-07-26 18:55:42 +02:00
parent 58ea71e694
commit 39cc9b8d7c
3 changed files with 52 additions and 44 deletions

View File

@@ -122,9 +122,13 @@ class MyApp extends StatelessWidget {
if (state is NoopNavigationState) { if (state is NoopNavigationState) {
// NOOP // NOOP
} else if (state is PushNavigationState) { } else if (state is PushNavigationState) {
_router.go(state.destination);
} else if (state is GoNavigationState) {
_router.push(state.destination); _router.push(state.destination);
} else if (state is GoNavigationState) {
if (_router.canPop()) {
_router.replace(state.destination);
} else {
_router.go(state.destination);
}
} else if (state is PoppedNavigationState) { } else if (state is PoppedNavigationState) {
_router.pop(); _router.pop();
} }

View File

@@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
class AnimeCoverImage extends StatelessWidget { class AnimeCoverImage extends StatelessWidget {
const AnimeCoverImage({ const AnimeCoverImage({
required this.url, required this.url,
required this.hero, this.hero,
this.cached = true, this.cached = true,
this.extra, this.extra,
this.onTap, this.onTap,
@@ -18,7 +18,7 @@ class AnimeCoverImage extends StatelessWidget {
final bool cached; final bool cached;
/// The hero tag of the image. /// The hero tag of the image.
final String hero; final String? hero;
/// An extra widget with a translucent backdrop. /// An extra widget with a translucent backdrop.
final Widget? extra; final Widget? extra;
@@ -28,53 +28,59 @@ class AnimeCoverImage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Hero( final image = ClipRRect(
tag: hero, borderRadius: BorderRadius.circular(8),
child: ClipRRect( child: Material(
borderRadius: BorderRadius.circular(8), child: SizedBox(
child: Material( height: 100 * (16 / 9),
child: SizedBox( width: 120,
height: 100 * (16 / 9), child: InkWell(
width: 120, onTap: onTap ?? () {},
child: InkWell( child: Stack(
onTap: onTap ?? () {}, children: [
child: Stack( Positioned(
children: [ left: 0,
Positioned( right: 0,
left: 0, top: 0,
right: 0, bottom: 0,
top: 0, child: DecoratedBox(
bottom: 0, decoration: BoxDecoration(
child: DecoratedBox( image: DecorationImage(
decoration: BoxDecoration( image: cached
image: DecorationImage( ? CachedNetworkImageProvider(url) as ImageProvider
image: cached : NetworkImage(url),
? CachedNetworkImageProvider(url) as ImageProvider fit: BoxFit.cover,
: NetworkImage(url),
fit: BoxFit.cover,
),
), ),
), ),
), ),
if (extra != null) ),
Positioned( if (extra != null)
left: 0, Positioned(
bottom: 0, left: 0,
right: 0, bottom: 0,
child: SizedBox( right: 0,
height: 40, child: SizedBox(
child: ColoredBox( height: 40,
color: Colors.black54, child: ColoredBox(
child: extra, color: Colors.black54,
), child: extra,
), ),
), ),
], ),
), ],
), ),
), ),
), ),
), ),
); );
if (hero != null) {
return Hero(
tag: hero!,
child: image,
);
}
return image;
} }
} }

View File

@@ -76,8 +76,6 @@ class ListItem extends StatelessWidget {
children: [ children: [
AnimeCoverImage( AnimeCoverImage(
cached: cached, cached: cached,
// TODO(Unknown): Have the ID here
hero: thumbnailUrl,
extra: imageExtra, extra: imageExtra,
url: thumbnailUrl, url: thumbnailUrl,
), ),