Flutter/Dart Scrolling textfield above keyboard

后端 未结 3 1326
伪装坚强ぢ
伪装坚强ぢ 2021-01-06 11:44

I am using textfields, how can I make it so it scrolls up a bit when entering email and password?

Here is a preview of the code

https://pastebin.com/4EngQDV

3条回答
  •  北海茫月
    2021-01-06 11:52

    I actually had the same problem. Figured that you need to wrap the TextForms into a ListView to make it work.

    import 'package:flutter/material.dart';
    
    class ScrollView extends StatefulWidget {
    @override
    State createState() {
    // TODO: implement createState
    return _ScrollViewState();
    }
    }
    
    class _ScrollViewState extends State{
    @override
    Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: userInputBackgroundColor,
        body: ListView(
                  padding: EdgeInsets.all(0.0),
                  shrinkWrap: true,
                  children: [
                   TextForm(),
                   TextForm()
                  ]
              ),
            )
        }
    }
    

提交回复
热议问题