Created
September 21, 2020 20:21
-
-
Save dsrenesanse/0979346f721394f7c136b93587baf1cd to your computer and use it in GitHub Desktop.
custom_back_drop
This file contains 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/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
const horizontalPadding = 16.0; | |
const controllerBorderRadius = BorderRadius.all(Radius.circular(2.0)); | |
const controllerHeight = 4.0; | |
const controllerWidth = 32.0; | |
const systemAppBarHeight = 48.0; | |
const keyboardHeight = 282; | |
Future<T> showCustomModalBottomSheet<T>({BuildContext context, Widget child, Color backgroundColor, double | |
topPadding}) { | |
return showModalBottomSheet<T>( | |
backgroundColor: Colors.transparent, | |
isScrollControlled: true, | |
context: context, | |
builder: (ctx) { | |
return _BackDropBody(child: child, topPadding: MediaQuery.of(context).padding.top); | |
}); | |
} | |
class _BackDropBody extends StatefulWidget { | |
final Widget child; | |
final double topPadding; | |
const _BackDropBody({Key key, this.child, this.topPadding}) : super(key: key); | |
@override | |
__BackDropBodyState createState() => __BackDropBodyState(); | |
} | |
class __BackDropBodyState extends State<_BackDropBody> { | |
@override | |
Widget build(BuildContext context) { | |
return ConstrainedBox( | |
constraints: BoxConstraints(maxHeight: MediaQuery.of(context).size.height - widget.topPadding), | |
child: DraggableScrollableSheet( | |
expand: false, | |
maxChildSize: 1, | |
initialChildSize: 0.9999, | |
minChildSize: 0.9999, | |
builder: (context, sc) { | |
return AnimatedContainer( | |
curve: Curves.easeInOutQuart, | |
duration: const Duration(milliseconds: 300), | |
padding: EdgeInsets.only( | |
top: MediaQuery.of(context).padding.top, bottom: MediaQuery.of(context).viewInsets.bottom), | |
child: Stack( | |
children: <Widget>[ | |
Container( | |
decoration: BoxDecoration( | |
color: OzonColors.ozWhite1, | |
borderRadius: | |
BorderRadius.only(topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0))), | |
child: SingleChildScrollView( | |
controller: sc, | |
child: widget.child, | |
physics: const BouncingScrollPhysics(), | |
), | |
), | |
Container( | |
height: 20, | |
color: Colors.transparent, | |
alignment: Alignment.center, | |
child: Container( | |
decoration: BoxDecoration( | |
color: OzonColors.ozGray70, | |
borderRadius: controllerBorderRadius, | |
), | |
height: controllerHeight, | |
width: controllerWidth, | |
), | |
), | |
], | |
), | |
); | |
}), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment