본문 바로가기

Flutter

[Flutter] ScrollView

화면 스크롤이 필요한 경우 및 TextField 에 커서를 댈 때 키보드가 올라와서 UI 에러가 발생하는 경우,

 

SingleChildScrollView를 이용하면 된다.

 

단, scroll glow를 삭제하고 싶으면, ScrollConfiguration으로 감싸서, behavior 설정해준다.

 

child: ScrollConfiguration(
  behavior: RemoveScrollGlowBehavior(),
  child: SingleChildScrollView(
    child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
      ]
    ),
  ),
),
//scroll glow 삭제
import 'package:flutter/material.dart';

class RemoveScrollGlowBehavior extends ScrollBehavior {
  @override
  Widget buildViewportChrome(
      BuildContext context, Widget child, AxisDirection axisDirection) {
    return child;
  }
}
반응형