width 에 맞게 font size 조절

Gong Kang·2023년 1월 8일
0

반응형 작업 중, width 의 크기가 줄어들면 text 사이즈도 줄어들게
만들고 싶었다

핵심은 Flexible 안에 FittedBox 를 넣는 것이다!

class SampleCode extends StatefulWidget {
  const SampleCode({super.key});

  @override
  State<SampleCode> createState() => _SampleCodeState();
}

class _SampleCodeState extends State<SampleCode> {
  @override
  Widget build(BuildContext context) {
    List<ZoneModel> testZoneList = [
      ZoneModel(type: 'Intro Zone', teacherName: 'kang', teacherImgPath: 'www')
    ];

    return Row(
      children: [
        Flexible(
          child: FittedBox(
            fit: BoxFit.scaleDown,
            child: Text(
              '작품 전시하기',
              style: TextStyle(
                fontSize: 20,
              ),
              maxLines: 1,
            ),
          ),
        ),
      ],
    );
  }
}
profile
꾸준히 하루에 한번씩..!

0개의 댓글