show method
Show the snackbar
Implementation
void show(BuildContext context) {
OverlayState? overlay = Overlay.of(context);
late OverlayEntry overlayEntry;
overlayEntry = OverlayEntry(
builder: (context) => Positioned(
top: 32,
left: 16,
right: 16,
child: Material(
color: Colors.transparent,
child: TweenAnimationBuilder<double>(
tween: Tween(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 500),
curve: Curves.easeOutBack,
onEnd: () {
Future.delayed(const Duration(seconds: 2), () {
overlayEntry.remove();
onDismissed?.call();
});
},
builder: (context, value, child) {
return Transform.translate(
offset: Offset(0, -50 * (1 - value)),
child: Opacity(
opacity: value.clamp(0.0, 1.0),
child: Container(
padding:
const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
decoration: BoxDecoration(
color: AppColors.blue200,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: AppColors.blue300, width: 2),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 10,
offset: const Offset(0, 4),
),
],
),
child: Row(
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
TweenAnimationBuilder<double>(
tween: Tween(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 700),
curve: Curves.elasticOut,
builder: (context, value, child) {
return Transform.scale(
scale: value.clamp(0.0, 1.0),
child: const Text(
"Connexion à l'application",
style: TextStyle(
fontFamily: 'Poppins',
fontSize: 14,
fontWeight: FontWeight.w600,
color: AppColors.black,
),
),
);
},
),
const SizedBox(height: 8),
TweenAnimationBuilder<double>(
tween: Tween(begin: 0.0, end: 1.0),
duration: const Duration(milliseconds: 600),
curve: Curves.easeOut,
builder: (context, value, child) {
return Opacity(
opacity: value.clamp(0.0, 1.0),
child: SizedBox(
height: 4,
child: ClipRRect(
borderRadius: BorderRadius.circular(2),
child: const LinearProgressIndicator(
value: null, // Indeterminate progress
backgroundColor: AppColors.blue100,
valueColor:
AlwaysStoppedAnimation<Color>(
AppColors.blue700,
),
),
),
),
);
},
),
],
),
),
],
),
),
),
);
},
),
),
),
);
overlay.insert(overlayEntry);
}