Created
February 9, 2022 20:10
-
-
Save RockinPaul/4880cc199bdda5e6fc815694e3a41c88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Based on the answer of Przemek Broda: | |
/// https://stackoverflow.com/questions/51825779/blur-background-behind-dialog-flutter/62361699#62361699 | |
import 'dart:ui'; | |
import 'package:flutter/material.dart'; | |
void showProgressView(BuildContext context, {bool dismissible = false}) { | |
showGeneralDialog( | |
context: context, | |
barrierColor: Theme.of(context).colorScheme.surface.withOpacity(0.5), | |
barrierDismissible: dismissible, | |
barrierLabel: '', | |
pageBuilder: (_, __, ___) => const CustomProgressView(), | |
transitionBuilder: (_, anim1, __, child) { | |
return BackdropFilter( | |
filter: ImageFilter.blur( | |
sigmaX: 6 * anim1.value, | |
sigmaY: 6 * anim1.value, | |
), | |
child: FadeTransition( | |
child: child, | |
opacity: anim1, | |
), | |
); | |
}, | |
); | |
} | |
class CustomProgressView extends StatelessWidget { | |
final AnimationController? animationController; | |
const CustomProgressView({Key? key, this.animationController}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Dialog( | |
shape: const CircleBorder(), | |
elevation: 0, | |
child: Container( | |
width: 149.0, | |
height: 149.0, | |
alignment: Alignment.center, | |
decoration: BoxDecoration( | |
gradient: LinearGradient( | |
begin: Alignment.centerLeft, | |
end: Alignment.centerRight, | |
colors: [ | |
Theme.of(context).colorScheme.surfaceVariant, | |
Theme.of(context).colorScheme.surface, | |
], | |
), | |
shape: BoxShape.circle, | |
), | |
child: Container( | |
width: 148.0, | |
height: 148.0, | |
decoration: BoxDecoration( | |
color: Theme.of(context).colorScheme.surfaceVariant, | |
shape: BoxShape.circle, | |
), | |
child: Container( | |
alignment: FractionalOffset.center, | |
height: 51.0, | |
child: const CircularProgressIndicator( | |
strokeWidth: 5, | |
color: Colors.red, | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment