adding packages
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
Future<T> showMobilePopup<T>({
|
||||
@required BuildContext context,
|
||||
bool barrierDismissible = true,
|
||||
bool mobilePush = false,
|
||||
WidgetBuilder builder,
|
||||
}) {
|
||||
if (mobilePush && (Platform.isIOS || Platform.isAndroid)) {
|
||||
return Navigator.of(context).push<T>(
|
||||
MaterialPageRoute(builder: builder),
|
||||
);
|
||||
}
|
||||
|
||||
assert(debugCheckHasMaterialLocalizations(context));
|
||||
|
||||
final ThemeData theme = Theme.of(context, shadowThemeOnly: true);
|
||||
return showGeneralDialog(
|
||||
context: context,
|
||||
pageBuilder: (BuildContext buildContext, Animation<double> animation,
|
||||
Animation<double> secondaryAnimation) {
|
||||
final Widget pageChild = Builder(builder: builder);
|
||||
return Builder(builder: (BuildContext context) {
|
||||
return theme != null ? Theme(data: theme, child: pageChild) : pageChild;
|
||||
});
|
||||
},
|
||||
barrierDismissible: barrierDismissible,
|
||||
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
|
||||
barrierColor: Colors.black54,
|
||||
transitionDuration: const Duration(milliseconds: 150),
|
||||
transitionBuilder: _buildMaterialDialogTransitions,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMaterialDialogTransitions(
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child) {
|
||||
return FadeTransition(
|
||||
opacity: CurvedAnimation(
|
||||
parent: animation,
|
||||
curve: Curves.easeOut,
|
||||
),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user