Flutter 글자길어지면 다음줄로 넘어가게 하기

서희찬·2023년 9월 30일

이와 같이 글이 길어질때 overflow문제가 발생했다..

어떻게하면 화면 크기에 맞춰 자동으로 개행될까해서 flexible도하고 했지만... 찾기어렵다가 stackoverflow에서 하나 찾아서 Container로 감싸고 Width를 주면 된다고 되어 있어서 해봤다.

            Text(
              content,
              style: const TextStyle(fontSize: 16),
            ),

이와 같이 되어있던 코드를

            Container(
              width: MediaQuery.of(context).size.width * 0.7,
              child: Text(
                content,
                style: const TextStyle(fontSize: 16),
              ),
            ),

이와 같이 바꾸니
내가 원하는 사이즈만큼 적절히 자동으로 개행되는것을 확인할 수 있다

참고


https://stackoverflow.com/questions/51930754/flutter-wrapping-text

profile
Carnegie Mellon University Robotics Institute | Research Associate | Developing For Our Lives, 세상에 기여하는 삶을 살고자 개발하고 있습니다

0개의 댓글