Created
July 26, 2019 03:20
-
-
Save drewpayment/08e963f8cf0fa715711408a2bf33d899 to your computer and use it in GitHub Desktop.
Hack to fix Flutter not scrolling TextField and TextFormField into view to take viewInset of keyboard into account.
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/material.dart'; | |
class CustomBottomSheet { | |
static Future<T> showScrollingModalBottomSheet<T>({ | |
@required BuildContext context, | |
bool isScrollControlled = true, | |
ShapeBorder shape, | |
double heightPercView = 0.95, | |
double topMargin = 65.0, | |
@required Widget appBar, | |
@required Widget child, | |
}) { | |
final br = BorderRadius.circular(50); | |
shape = shape != null ? shape | |
: RoundedRectangleBorder(borderRadius: br); | |
return showModalBottomSheet( | |
isScrollControlled: isScrollControlled, | |
context: context, | |
shape: shape, | |
builder: (ctx) { | |
return Container( | |
height: MediaQuery.of(ctx).size.height * heightPercView, | |
decoration: BoxDecoration(borderRadius: br), | |
child: Scaffold( | |
backgroundColor: Colors.transparent, | |
resizeToAvoidBottomInset: true, | |
appBar: PreferredSize( | |
preferredSize: Size.fromHeight(topMargin), | |
child: appBar, | |
), | |
body: child, | |
), | |
); | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment