Created
February 25, 2023 01:59
-
-
Save Davidnadejdin/50bc711210be8aa37f2186c0bd753ea0 to your computer and use it in GitHub Desktop.
showPopup
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
import 'package:flutter/material.dart'; | |
showPopup({ | |
required BuildContext context, | |
double? height, | |
Color? backdropColor, | |
Widget? child, | |
}) { | |
showGeneralDialog( | |
transitionDuration: const Duration(milliseconds: 500), | |
transitionBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) { | |
return SlideTransition( | |
position: Tween<Offset>( | |
begin: const Offset(0.0, 1.0), | |
end: Offset.zero, | |
).animate(animation), | |
child: child, | |
); | |
}, | |
barrierColor: backdropColor ?? Colors.black54, | |
context: context, | |
useRootNavigator: false, | |
barrierDismissible: true, | |
pageBuilder: (_, __, ___) { | |
return Column( | |
children: [ | |
Expanded( | |
child: Align( | |
alignment: Alignment.bottomCenter, | |
child: SizedBox( | |
height: height ?? 10, | |
width: MediaQuery.of(context).size.width, | |
child: Container( | |
decoration: const BoxDecoration( | |
color: Colors.white, | |
borderRadius: BorderRadius.only( | |
topLeft: Radius.circular(30), | |
topRight: Radius.circular(30), | |
), | |
), | |
child: child, | |
), | |
), | |
), | |
), | |
], | |
); | |
}); | |
} | |
Future<T?> showGeneralDialog<T extends Object?>({ | |
required BuildContext context, | |
required RoutePageBuilder pageBuilder, | |
bool barrierDismissible = false, | |
String? barrierLabel, | |
Color barrierColor = const Color(0x80000000), | |
Duration transitionDuration = const Duration(milliseconds: 200), | |
RouteTransitionsBuilder? transitionBuilder, | |
bool useRootNavigator = true, | |
RouteSettings? routeSettings, | |
Offset? anchorPoint, | |
}) { | |
return Navigator.of(context, rootNavigator: useRootNavigator).push<T>(RawDialogRoute<T>( | |
pageBuilder: pageBuilder, | |
barrierDismissible: barrierDismissible, | |
barrierLabel: barrierLabel, | |
barrierColor: barrierColor, | |
transitionDuration: transitionDuration, | |
transitionBuilder: transitionBuilder, | |
settings: routeSettings, | |
anchorPoint: anchorPoint, | |
)); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment