refactored landing page with initialization errors
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
|
||||
AsyncSnapshot<T> useCachedFuture<T>(
|
||||
Future<T> Function() valueBuilder,
|
||||
) {
|
||||
// ignore: discarded_futures
|
||||
final cachedFuture = useMemoized(
|
||||
valueBuilder,
|
||||
);
|
||||
return useFuture(cachedFuture);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ class FailureWidget extends StatelessWidget {
|
||||
});
|
||||
|
||||
final String? title;
|
||||
final Object? exception;
|
||||
final dynamic exception;
|
||||
final VoidCallback? onRetry;
|
||||
final bool compact;
|
||||
|
||||
@@ -23,7 +23,10 @@ class FailureWidget extends StatelessWidget {
|
||||
ListTile(
|
||||
title: Text(title ?? 'Something went wrong'),
|
||||
subtitle: exception != null
|
||||
? Text(exception.runtimeType.toString())
|
||||
? switch (exception) {
|
||||
final String string => Text(string),
|
||||
_ => Text(exception.runtimeType.toString())
|
||||
}
|
||||
: null,
|
||||
trailing: compact && onRetry != null
|
||||
? IconButton.outlined(
|
||||
|
||||
Reference in New Issue
Block a user