OpenContacts/lib/widgets/default_error_widget.dart

41 lines
No EOL
1.2 KiB
Dart

import 'package:flutter/material.dart';
class DefaultErrorWidget extends StatelessWidget {
const DefaultErrorWidget({required this.message, this.onRetry, super.key});
final String message;
final void Function()? onRetry;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 64, vertical: 128,),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text("Something went wrong: ", style: Theme
.of(context)
.textTheme
.titleMedium,),
Padding(
padding: const EdgeInsets.all(16),
child: Text(message),
),
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"),
),
],
),
),
);
}
}