일모도원(日暮途遠) 개발자
[Flame] 폰트색상이 빨간색에 노랑 밑줄이 발생하는 경우 본문
Flame으로 게임 개발하는중에 Overlay로 뷰를 띄우니 아래처럼 빨간 색에 노란 밑줄이 보인다.

class GameOverPopup extends StatelessWidget {
  final RogueShooterGame game;
  const GameOverPopup({super.key, required this.game});
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        width: 300,
        padding: const EdgeInsets.all(24),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(16),
          boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.5), blurRadius: 10)],
        ),
        child: const Text('Game Over', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
      ),
    );
  }
}
이는 Flame은 main의 runapp에서 MaterialApp으로 감싸지 않고 바로 GameWidget을 사용하기 때문이다.
void main() {
  final MyGame game = MyGame();
  runApp(GameWidget(
    game: game,
    overlayBuilderMap: {
      'GameOver': (context, MyGame game) => GameOverOverlay(game: game),
    },
    initialActiveOverlays: const ['Title'],
  ));
}
이런 경우 Material로 감싸주면 된다.

class GameOverPopup extends StatelessWidget {
  final RogueShooterGame game;
  const GameOverPopup({super.key, required this.game});
  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.black.withOpacity(0.5), // 반투명 배경
      child: Center(
        child: Container(
          width: 300,
          padding: const EdgeInsets.all(24),
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(16),
            boxShadow: [BoxShadow(color: Colors.black.withOpacity(0.5), blurRadius: 10)],
          ),
          child: const Text('Game Over', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
        ),
      ),
    );
  }
}
'Flutter > Flutter개발' 카테고리의 다른 글
| [Flutter개발] Flavor만들기 (3) | 2025.07.18 | 
|---|---|
| [Flutter Flame] 오디오 재생시 점점 느려지는 버그 (1) | 2025.07.08 | 
| [Flame] Flame의 Route에러 (0) | 2025.05.15 | 
| [Flutter개발] 화면에 표시되는 언어 변경하기. (1) | 2025.02.02 | 
| [플러터 개발] 위젯 2개를 한개는 정가운데 두고 하나는 오른쪽에 배치하기. (0) | 2025.01.18 | 
 
           
                  