OpenContacts/lib/widgets/default_error_widget.dart

49 lines
1.5 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
class DefaultErrorWidget extends StatelessWidget {
2023-05-04 12:16:19 -04:00
const DefaultErrorWidget({this.title, this.message, this.onRetry, this.iconOverride, super.key});
2023-05-04 12:16:19 -04:00
final String? title;
final String? message;
final void Function()? onRetry;
2023-05-04 12:16:19 -04:00
final IconData? iconOverride;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(64),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
2023-05-04 12:16:19 -04:00
Icon(iconOverride ?? Icons.warning, size: 32,),
const SizedBox(height: 16,),
Text(title ?? "Something went wrong: ",
textAlign: TextAlign.center,
style: Theme
.of(context)
.textTheme
.titleMedium,),
2023-05-04 12:16:19 -04:00
if (message != null) Padding(
padding: const EdgeInsets.all(16),
2023-05-04 12:16:19 -04:00
child: Text(message ?? "",
textAlign: TextAlign.center,
),
),
if (onRetry != null) TextButton.icon(
onPressed: onRetry,
style: TextButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 16),
),
icon: const Icon(Icons.refresh),
label: const Text("Retry"),
),
],
),
),
);
}
}