Flutter

[Flutter] TextField 높이 상위 위젯에 맞추기 / button 높이 넣기

ahleum 2023. 2. 7. 12:54
child: SizedBox(
  height: 50,
  child: TextFormField(
    expands: true,
    minLines: null,
    maxLines: null,
    style: const TextStyle(
      fontWeight: FontWeight.w600,
      fontSize: 16,
    ),
   ),
 ),

TextField를 사용할때 위아래 길이 맞추는 방법

 

expands :true 로 넣어주고 

이렇게 넣으면 무조건 minLines, maxLines 는 null로 같이 넣어줘야 한다. 

 

그럼 위 상위 위젯 높이와 일치하도록 들어가진다

 

 


 

 

TextButton등 Button 위젯들 높이 조정하기

높이를 조정해야 할때

 

ElevatedButton(
  onPressed: () {},
  style: ElevatedButton.styleFrom(
    fixedSize:const Size.fromHeight(48) ,
    minimumSize: const Size.fromHeight(50),
  ),
),

높이만 설정할때

fixedSize:const Size.fromHeight(48) ,

 

가로, 세로 길이 설정할때

fixedSize: const Size(width, height),