fix: Bunc of uncaught exceptions

This commit is contained in:
PartyDonut 2025-08-30 09:32:20 +02:00
parent 9c964e7b41
commit 9f6aa1e489
6 changed files with 34 additions and 23 deletions

View file

@ -88,10 +88,12 @@ class _PhotoViewerScreenState extends ConsumerState<PhotoViewerScreen> with Widg
final newItems = await Future.value(widget.loadingItems);
setState(() {
photos = {...photos, ...newItems}.toList();
loadingItems = false;
});
if (context.mounted) {
setState(() {
photos = {...photos, ...newItems}.toList();
loadingItems = false;
});
}
}
},
);

View file

@ -2,9 +2,11 @@ import 'package:flutter/material.dart';
import 'package:fladder/util/adaptive_layout/adaptive_layout.dart';
Future<void> showDialogAdaptive(
{required BuildContext context, required Widget Function(BuildContext context) builder}) {
if (AdaptiveLayout.of(context).inputDevice == InputDevice.pointer) {
Future<void> showDialogAdaptive({
required BuildContext context,
required Widget Function(BuildContext context) builder,
}) {
if (AdaptiveLayout.viewSizeOf(context) >= ViewSize.tablet) {
return showDialog(
context: context,
useSafeArea: false,

View file

@ -58,7 +58,7 @@ class _PosterImageState extends ConsumerState<PosterImage> {
late String currentTag = widget.heroTag == true ? widget.poster.id : UniqueKey().toString();
bool hover = false;
void pressedWidget() async {
void pressedWidget(BuildContext context) async {
if (widget.heroTag == false) {
setState(() {
currentTag = widget.poster.id;
@ -67,15 +67,12 @@ class _PosterImageState extends ConsumerState<PosterImage> {
if (widget.onPressed != null) {
widget.onPressed?.call(() async {
await navigateToDetails();
if (context.mounted) {
context.refreshData();
}
context.refreshData();
}, widget.poster);
} else {
await navigateToDetails();
if (context.mounted) {
context.refreshData();
}
if (!context.mounted) return;
context.refreshData();
}
}
@ -319,7 +316,7 @@ class _PosterImageState extends ConsumerState<PosterImage> {
Focus(
onFocusChange: (value) => setState(() => hover = value),
child: FlatButton(
onTap: pressedWidget,
onTap: () => pressedWidget(context),
onSecondaryTapDown: (details) async {
Offset localPosition = details.globalPosition;
RelativeRect position = RelativeRect.fromLTRB(
@ -391,7 +388,7 @@ class _PosterImageState extends ConsumerState<PosterImage> {
Material(
color: Colors.transparent,
child: InkWell(
onTap: pressedWidget,
onTap: () => pressedWidget(context),
onLongPress: () {
showBottomSheetPill(
context: context,