69 lines
1.6 KiB
Dart
69 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// A customizable loading widget
|
|
class LoadingWidget extends StatelessWidget {
|
|
final String? message;
|
|
final double size;
|
|
final Color? color;
|
|
|
|
const LoadingWidget({
|
|
super.key,
|
|
this.message,
|
|
this.size = 24.0,
|
|
this.color,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
SizedBox(
|
|
width: size,
|
|
height: size,
|
|
child: CircularProgressIndicator(
|
|
color: color ?? Theme.of(context).colorScheme.primary,
|
|
strokeWidth: 3.0,
|
|
),
|
|
),
|
|
if (message != null) ...[
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
message!,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
|
|
),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// A small loading indicator for buttons
|
|
class SmallLoadingIndicator extends StatelessWidget {
|
|
final Color? color;
|
|
final double size;
|
|
|
|
const SmallLoadingIndicator({
|
|
super.key,
|
|
this.color,
|
|
this.size = 16.0,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SizedBox(
|
|
width: size,
|
|
height: size,
|
|
child: CircularProgressIndicator(
|
|
color: color ?? Theme.of(context).colorScheme.onPrimary,
|
|
strokeWidth: 2.0,
|
|
),
|
|
);
|
|
}
|
|
} |