Skip to content

Commit

Permalink
fix(firebase_ui_auth): preserve UI form state when device rotates (#9993
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lesnitsky committed Dec 1, 2022
1 parent 6c90b6b commit 55dcd32
Showing 1 changed file with 9 additions and 5 deletions.
Expand Up @@ -119,6 +119,7 @@ class ResponsivePage extends StatefulWidget {
class _ResponsivePageState extends State<ResponsivePage> {
final ctrl = ScrollController();
final paddingListenable = ValueNotifier<double>(0);
final key = GlobalKey();

void _onKeyboardPositionChanged(double position) {
if (!ctrl.hasClients) {
Expand All @@ -138,6 +139,11 @@ class _ResponsivePageState extends State<ResponsivePage> {
Widget build(BuildContext context) {
final breakpoint = widget.breakpoint;

final content = KeyedSubtree(
key: key,
child: widget.child,
);

return LayoutBuilder(
builder: (context, constraints) {
if (constraints.biggest.width > breakpoint) {
Expand Down Expand Up @@ -166,9 +172,7 @@ class _ResponsivePageState extends State<ResponsivePage> {
Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: breakpoint),
child: IntrinsicHeight(
child: widget.child,
),
child: IntrinsicHeight(child: content),
),
),
],
Expand Down Expand Up @@ -198,7 +202,7 @@ class _ResponsivePageState extends State<ResponsivePage> {
SliverList(
delegate: SliverChildListDelegate.fixed(
[
widget.child,
content,
ValueListenableBuilder<double>(
valueListenable: paddingListenable,
builder: (context, value, _) {
Expand All @@ -217,7 +221,7 @@ class _ResponsivePageState extends State<ResponsivePage> {
child: ListView(
shrinkWrap: true,
children: [
widget.child,
content,
],
),
);
Expand Down

0 comments on commit 55dcd32

Please sign in to comment.