This commit is contained in:
2025-11-19 11:17:33 +09:00
parent 3b053530f5
commit 2008c377f4
17 changed files with 1416 additions and 966 deletions
@@ -32,12 +32,13 @@ class SpiderGameController with ChangeNotifier {
List<SpiderCard> _cardsToDealAnimate = [];
List<SpiderCard> get cardsToDealAnimate => _cardsToDealAnimate;
void clearDealAnimationTrigger() {
debugPrint("[LOG] clearDealAnimationTrigger: CALLED. Clearing animation queue (Current count: ${_cardsToDealAnimate.length}).");
debugPrint(
"[LOG] clearDealAnimationTrigger: CALLED. Clearing animation queue (Current count: ${_cardsToDealAnimate.length}).");
_cardsToDealAnimate.clear();
}
List<SpiderCard> _cardsToAnimateStack = [];
List<SpiderCard> get cardsToAnimateStack => _cardsToAnimateStack;
int _animationSourcePileIndex = -1;
@@ -47,8 +48,8 @@ class SpiderGameController with ChangeNotifier {
bool get canUndo {
return _undoHistory.isNotEmpty &&
!_isGameCompleted &&
_undoCount < maxUndoCount;
!_isGameCompleted &&
_undoCount < maxUndoCount;
}
void setUserInfo(String userId, String? userName) {
@@ -99,6 +100,7 @@ class SpiderGameController with ChangeNotifier {
}
return deck;
}
(List<List<SpiderCard>>, List<SpiderCard>) _dealCards(
List<SpiderCard> shuffledDeck, String distribution) {
final List<List<SpiderCard>> tableau = List.generate(10, (_) => []);
@@ -118,6 +120,7 @@ class SpiderGameController with ChangeNotifier {
}
return (tableau, stock);
}
void _startTimer() {
_timer?.cancel();
_secondsElapsed = 0;
@@ -126,6 +129,7 @@ class SpiderGameController with ChangeNotifier {
notifyListeners();
});
}
void stopTimer() {
_timer?.cancel();
}
@@ -133,7 +137,7 @@ class SpiderGameController with ChangeNotifier {
/// 🔽 덱 분배 (애니메이션 트리거)
void dealFromStock() {
debugPrint("[LOG] dealFromStock: CALLED. Checking conditions...");
if (_currentState.stock.isEmpty) {
debugPrint("[LOG] dealFromStock: FAILED (Stock is empty)");
return;
@@ -152,8 +156,9 @@ class SpiderGameController with ChangeNotifier {
}
final bool hasEmptyPile = _currentState.tableau.any((pile) => pile.isEmpty);
debugPrint("[LOG] dealFromStock: Checking for empty piles... Result: $hasEmptyPile");
debugPrint(
"[LOG] dealFromStock: Checking for empty piles... Result: $hasEmptyPile");
if (hasEmptyPile) {
debugPrint("[LOG] dealFromStock: FAILED (Empty pile found)");
return;
@@ -163,52 +168,66 @@ class SpiderGameController with ChangeNotifier {
_saveUndoState();
final int cardsToDealCount = min(10, _currentState.stock.length);
debugPrint("[LOG] dealFromStock: Preparing ${cardsToDealCount} cards for animation.");
debugPrint(
"[LOG] dealFromStock: Preparing ${cardsToDealCount} cards for animation.");
for (int i = 0; i < cardsToDealCount; i++) {
_cardsToDealAnimate.add(_currentState.stock.removeLast());
}
debugPrint("[LOG] dealFromStock: Cards moved to _cardsToDealAnimate queue (Total: ${_cardsToDealAnimate.length}). Notifying listeners...");
debugPrint(
"[LOG] dealFromStock: Cards moved to _cardsToDealAnimate queue (Total: ${_cardsToDealAnimate.length}). Notifying listeners...");
notifyListeners();
}
/// 🔽 덱 분배 애니메이션이 끝난 후 UI가 호출
void finalizeDealFromStock(List<SpiderCard> dealtCards) {
debugPrint("[LOG] finalizeDealFromStock: CALLED. Finalizing ${dealtCards.length} cards.");
debugPrint(
"[LOG] finalizeDealFromStock: CALLED. Finalizing ${dealtCards.length} cards.");
for (int i = 0; i < dealtCards.length; i++) {
final card = dealtCards[i];
card.isFaceUp = true;
_currentState.tableau[i].add(card);
}
_currentState = _currentState.copyWith(moves: _currentState.moves + 1);
debugPrint("[LOG] finalizeDealFromStock: FINISHED. Calling _checkCompletedStacks...");
debugPrint(
"[LOG] finalizeDealFromStock: FINISHED. Calling _checkCompletedStacks...");
_checkCompletedStacks();
}
// ( onDragStarted, onDragCancelled, onCardsDropped, _moveCards 는 동일 )
void onDragStarted(List<SpiderCard> cards) {
_draggedCards = cards;
for (var card in cards) { card.isBeingDragged = true; }
for (var card in cards) {
card.isBeingDragged = true;
}
notifyListeners();
}
void onDragCancelled() {
for (var card in _draggedCards) { card.isBeingDragged = false; }
for (var card in _draggedCards) {
card.isBeingDragged = false;
}
_draggedCards = [];
notifyListeners();
}
void onCardsDropped(List<SpiderCard> cards, int targetPileIndex) {
final int sourcePileIndex = _findPileIndexForCard(cards.first);
for (var card in cards) { card.isBeingDragged = false; }
for (var card in cards) {
card.isBeingDragged = false;
}
_draggedCards = [];
_moveCards(cards, sourcePileIndex, targetPileIndex);
}
void _moveCards(List<SpiderCard> cards, int fromIndex, int toIndex) {
if (fromIndex == toIndex) {
notifyListeners(); return;
notifyListeners();
return;
}
_saveUndoState();
final sourcePile = _currentState.tableau[fromIndex];
@@ -221,17 +240,17 @@ class SpiderGameController with ChangeNotifier {
_currentState = _currentState.copyWith(moves: _currentState.moves + 1);
_checkCompletedStacks();
}
int undo() {
if (!canUndo) return _undoCount;
final prevState = _undoHistory.removeLast();
_currentState = SpiderGameState.fromHistory(prevState);
_undoCount++;
notifyListeners();
return _undoCount;
}
// ( canPickUpCard, getDraggableStack, isValidMove 는 동일 )
bool canPickUpCard(SpiderCard card) {
for (final pile in _currentState.tableau) {
@@ -239,6 +258,7 @@ class SpiderGameController with ChangeNotifier {
}
return false;
}
List<SpiderCard> getDraggableStack(SpiderCard tappedCard) {
final int pileIndex = _findPileIndexForCard(tappedCard);
if (pileIndex == -1) return [];
@@ -251,15 +271,15 @@ class SpiderGameController with ChangeNotifier {
final currentCard = pile[i];
if (currentCard.isFaceUp &&
prevCard.rank == currentCard.rank + 1 &&
prevCard.suit == currentCard.suit)
{
prevCard.suit == currentCard.suit) {
draggableStack.add(currentCard);
} else {
return [];
return [];
}
}
return draggableStack;
}
bool isValidMove(List<SpiderCard> cardsToMove, int targetPileIndex) {
if (cardsToMove.isEmpty) return false;
final targetPile = _currentState.tableau[targetPileIndex];
@@ -272,7 +292,7 @@ class SpiderGameController with ChangeNotifier {
/// 🔽 _checkCompletedStacks (애니메이션 트리거)
void _checkCompletedStacks() {
// 🔽 [수정] 애니메이션이 실행 중이면 중복 검사 방지
if (_cardsToAnimateStack.isNotEmpty) return;
if (_cardsToAnimateStack.isNotEmpty) return;
bool stackCompleted = false;
for (int i = 0; i < _currentState.tableau.length; i++) {
@@ -295,12 +315,12 @@ class SpiderGameController with ChangeNotifier {
_cardsToAnimateStack = last13Cards;
_animationSourcePileIndex = i;
_animationTargetFoundationIndex = _currentState.foundation.length;
stackCompleted = true;
break;
break;
}
}
if (stackCompleted) {
notifyListeners(); // 👈 UI에 애니메이션을 그리라고 알림
} else {
@@ -309,38 +329,43 @@ class SpiderGameController with ChangeNotifier {
}
/// 🔽 [수정] 스택 완성 애니메이션이 끝난 후 UI가 호출 (인자 받도록 변경)
void finalizeStackCompletion(List<SpiderCard> cardsToAnimate, int sourceIndex) {
debugPrint("[LOG] finalizeStackCompletion: CALLED. Source Index: $sourceIndex");
void finalizeStackCompletion(
List<SpiderCard> cardsToAnimate, int sourceIndex) {
debugPrint(
"[LOG] finalizeStackCompletion: CALLED. Source Index: $sourceIndex");
// 🔽 [수정] 크래시 방지
if (sourceIndex < 0 || sourceIndex >= _currentState.tableau.length) {
debugPrint("[LOG] finalizeStackCompletion: FAILED. Invalid Source Index: $sourceIndex");
debugPrint(
"[LOG] finalizeStackCompletion: FAILED. Invalid Source Index: $sourceIndex");
return;
}
_currentState.foundation.add(cardsToAnimate);
final pile = _currentState.tableau[sourceIndex];
if (pile.length >= cardsToAnimate.length) {
pile.removeRange(pile.length - cardsToAnimate.length, pile.length);
} else {
debugPrint("[LOG] finalizeStackCompletion: WARNING. Pile length was ${pile.length}, expected >= ${cardsToAnimate.length}.");
debugPrint(
"[LOG] finalizeStackCompletion: WARNING. Pile length was ${pile.length}, expected >= ${cardsToAnimate.length}.");
}
if (pile.isNotEmpty && !pile.last.isFaceUp) {
pile.last.isFaceUp = true;
}
// 🔽 [삭제] 인덱스 리셋 불필요 (지역 변수로 처리됨)
// _animationSourcePileIndex = -1;
// _animationTargetFoundationIndex = -1;
_checkGameCompletion(); // 👈 [핵심] 게임 완료 검사
}
// 🔽 [복원됨]
void clearStackAnimationTrigger() {
debugPrint("[LOG] clearStackAnimationTrigger: CALLED. Clearing animation queue (Current count: ${_cardsToAnimateStack.length}).");
debugPrint(
"[LOG] clearStackAnimationTrigger: CALLED. Clearing animation queue (Current count: ${_cardsToAnimateStack.length}).");
_cardsToAnimateStack.clear();
}
@@ -348,7 +373,8 @@ class SpiderGameController with ChangeNotifier {
if (_currentState.foundation.length == 8 && !_isGameCompleted) {
_isGameCompleted = true;
stopTimer();
debugPrint("게임 완료! 이동: ${_currentState.moves}, 시간: $_secondsElapsed");
debugPrint(
"게임 완료! 이동: ${_currentState.moves}, 시간: $_secondsElapsed");
notifyListeners(); // 👈 [수정] 게임이 '완료'되었을 때만 notify
} else if (!_isGameCompleted) {
// 🔽 [수정] 게임이 완료되지 '않았을' 때도 notify (카드 이동 등을 반영하기 위해)
@@ -357,42 +383,21 @@ class SpiderGameController with ChangeNotifier {
// (게임이 완료된 후에는 더 이상 notify하지 않음)
}
// ( _saveUndoState, _findPileIndexForCard, submitRank, dispose 는 동일 )
// ( _saveUndoState, _findPileIndexForCard 는 동일 )
void _saveUndoState() {
_undoHistory.add(SpiderGameHistory.fromState(_currentState));
if (_undoHistory.length > 20) {
_undoHistory.removeAt(0);
}
}
int _findPileIndexForCard(SpiderCard card) {
return _currentState.tableau.indexWhere((pile) => pile.contains(card));
}
Future<RankSubmissionResult> submitRank(String playerName) async {
final puzzleService = PuzzleService();
final identityService = IdentityService();
final rankDto = UnifiedRankDto(
userId: userId,
gameType: 'SPIDER',
contextId: difficulty.contextId,
playerName: playerName,
primaryScore: _currentState.moves,
secondaryScore: _secondsElapsed,
);
final result = await puzzleService.submitRank(rankDto);
await identityService.saveUserName(playerName);
final int currentMaxLevel = await identityService.getMaxUnlockedLevel(gameType: 'SPIDER');
if (currentMaxLevel < 99) {
if (difficulty.levelIndex >= currentMaxLevel) {
int nextLevel = difficulty.levelIndex + 1;
if (nextLevel > SpiderDifficulties.allDifficulties.length) {
await identityService.saveMaxUnlockedLevel(99, gameType: 'SPIDER');
} else {
await identityService.saveMaxUnlockedLevel(nextLevel, gameType: 'SPIDER');
}
}
}
return result;
}
// ❌ [삭제] submitRank 메서드 (약 20줄) 삭제
// Future<RankSubmissionResult> submitRank(String playerName) async { ... }
@override
void dispose() {
_timer?.cancel();
@@ -3,7 +3,7 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:service_api/service_api.dart';
import 'package:feature_common/feature_common.dart';
import 'package:feature_common/feature_common.dart';
import '../controllers/spider_game_controller.dart';
import '../models/spider_difficulty.dart';
import '../models/spider_card.dart';
@@ -2,146 +2,147 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:service_api/service_api.dart'; // 👈 SessionNotifier 포함
import 'package:service_api/service_api.dart';
import 'package:feature_common/feature_common.dart';
import 'spider_game_screen.dart';
import '../models/spider_difficulty.dart';
import '../controllers/spider_game_controller.dart';
import '../controllers/spider_game_controller.dart';
class SpiderLobbyScreen extends StatefulWidget {
const SpiderLobbyScreen({ super.key });
const SpiderLobbyScreen({super.key});
@override
State<SpiderLobbyScreen> createState() => _SpiderLobbyScreenState();
}
class _SpiderLobbyScreenState extends State<SpiderLobbyScreen> {
int _maxUnlockedLevel = 1;
int _maxUnlockedLevel = 1;
Map<int, (int, int)> _rankHistory = {};
// ❌ String? _userName; (SessionNotifier가 관리)
bool _isLoading = false;
// 🔽 [수정] SessionNotifier를 사용하기 위해 IdentityService 대신 추가
late final SessionNotifier _sessionNotifier;
late final LobbyHelperService _lobbyHelper;
// [🔥 수정] 서비스를 직접 생성 (Provider로 읽지 않음)
final PuzzleService _puzzleService = PuzzleService();
final IdentityService _identityService = IdentityService(); // 👈 (save/load progress를 위해 유지)
final IdentityService _identityService = IdentityService();
@override
void initState() {
super.initState();
// 🔽 [수정] initState에서 SessionNotifier를 read
// SessionNotifier의 loadSession()이 먼저 완료되었다고 가정
_sessionNotifier = context.read<SessionNotifier>();
// 🔽 [수정] _loadProgress가 랭킹까지 모두 새로고침 (최초 1회)
// [🔥 수정] 헬퍼 서비스 초기화 (직접 생성한 서비스 주입)
_lobbyHelper = LobbyHelperService(
identityService: _identityService,
puzzleService: _puzzleService,
);
_loadProgress(forceRefreshRanks: true);
}
/// 🔽 [수정] _loadProgress 메서드 (SessionNotifier 사용 및 로직 분리)
/// [수정] 공통 헬퍼를 사용
Future<void> _loadProgress({bool forceRefreshRanks = false}) async {
// 1. (가벼움) 레벨 정보 새로고침
final maxLevel = await _identityService.getMaxUnlockedLevel(gameType: 'SPIDER');
if (mounted) {
setState(() {
_maxUnlockedLevel = maxLevel;
});
final maxLevel = await _lobbyHelper.loadMaxLevel('SPIDER');
if (mounted) {
setState(() {
_maxUnlockedLevel = maxLevel;
});
}
// 2. (무거움) 랭킹 정보 새로고침 (필요할 때만)
if (!forceRefreshRanks) return;
// 🔽 [수정] _sessionNotifier에서 유저 이름을 가져옴
final String? myName = _sessionNotifier.session?.userName;
if (myName == null) return; // 게스트이거나 아직 이름 저장을 안 함
if (myName == null) return;
try {
final Map<int, int> oldRankMap = await _identityService.getLastSavedRankMap(gameType: 'SPIDER');
List<Future<List<GameRankDto>>> rankFutures = [];
for (final level in SpiderDifficulties.allDifficulties) {
rankFutures.add(_puzzleService.fetchRanks('SPIDER', level.contextId));
final rankHistory = await _lobbyHelper.loadRankHistory<SpiderDifficulty>(
gameType: 'SPIDER',
myName: myName,
allLevels: SpiderDifficulties.allDifficulties,
getLevelIndex: (level) => level.levelIndex,
);
if (mounted) {
setState(() {
_rankHistory = rankHistory;
});
}
final List<List<GameRankDto>> allRankResults = await Future.wait(rankFutures);
Map<int, int> newRankMapForStorage = {};
Map<int, (int, int)> newRankHistoryForState = {};
for (int i = 0; i < SpiderDifficulties.allDifficulties.length; i++) {
final level = SpiderDifficulties.allDifficulties[i];
final currentRanks = allRankResults[i];
final int levelIndex = level.levelIndex;
final int oldRank = oldRankMap[levelIndex] ?? 0;
int currentRank = 0;
int myRankIndex = currentRanks.indexWhere((r) => r.playerName == myName);
if (myRankIndex != -1) { currentRank = myRankIndex + 1; }
newRankMapForStorage[levelIndex] = currentRank;
newRankHistoryForState[levelIndex] = (oldRank, currentRank);
}
await _identityService.saveLastRankMap(newRankMapForStorage, gameType: 'SPIDER');
if (mounted) { setState(() { _rankHistory = newRankHistoryForState; }); }
log("스파이더 랭킹 변동 확인 완료. (유저: $myName)");
} catch (e) {
log("SpiderLobbyScreen: 랭킹 확인 실패: $e");
}
}
/// 🔽 [수정] _startGame 메서드 (SessionNotifier 사용)
/// 🔽 [수정 없음] _startGame 메서드
Future<void> _startGame(SpiderDifficulty level) async {
setState(() { _isLoading = true; });
setState(() {
_isLoading = true;
});
// 1. [수정] SessionNotifier에서 유저 정보 가져오기
final session = _sessionNotifier.session;
if (session == null) {
log("세션이 로드되지 않아 게임을 시작할 수 없습니다.");
setState(() { _isLoading = false; });
setState(() {
_isLoading = false;
});
return;
}
final String userId = session.userId;
final String? userName = session.userName;
// 2. 컨트롤러 생성 및 새 게임 시작
final gameController = SpiderGameController();
gameController.setUserInfo(userId, userName); // 👈 유저 정보 주입
gameController.setUserInfo(userId, userName);
gameController.startNewGame(level);
setState(() { _isLoading = false; });
setState(() {
_isLoading = false;
});
if (!mounted) return;
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
ChangeNotifierProvider.value(
value: gameController,
child: const SpiderGameScreen(),
),
builder: (context) => ChangeNotifierProvider.value(
value: gameController,
child: const SpiderGameScreen(),
),
),
);
// 🔽 [핵심 수정]
// 랭킹(forceRefreshRanks: true)은 새로고침하지 않고,
// 레벨 잠금 상태(forceRefreshRanks: false)만 새로고침합니다.
_loadProgress(forceRefreshRanks: false);
}
@override
Widget build(BuildContext context) {
// 🔽 [수정] ThemeNotifier와 SessionNotifier를 모두 watch
context.watch<ThemeNotifier>();
context.watch<SessionNotifier>(); // 👈 세션 변경(로그인/로그아웃) 감지
final bool allLevelsUnlocked = _maxUnlockedLevel >= 9;
context.watch<SessionNotifier>();
final bool allLevelsUnlocked =
_maxUnlockedLevel >= SpiderDifficulties.allDifficulties.length;
final theme = Theme.of(context);
return CommonGameShell(
title: '스파이더 솔리테어',
onRankingPressed: () {
// ... (랭킹 버튼 로직 동일)
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RankingScreen(
gameType: 'SPIDER',
difficulties: SpiderDifficulties.allDifficulties,
initialDifficultyName:
SpiderDifficulties.getLevel(_maxUnlockedLevel).name,
),
),
);
},
// 🔽 [수정] RefreshIndicator 추가 (당겨서 랭킹 새로고침)
body: LayoutBuilder(
builder: (context, constraints) {
const double maxContentRatio = 0.6;
final double constrainedWidth = (constraints.maxHeight * maxContentRatio) > 500
? 500 : (constraints.maxHeight * maxContentRatio);
final double constrainedWidth =
(constraints.maxHeight * maxContentRatio) > 500
? 500
: (constraints.maxHeight * maxContentRatio);
return Center(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: constrainedWidth),
@@ -153,11 +154,15 @@ class _SpiderLobbyScreenState extends State<SpiderLobbyScreen> {
child: ListView.builder(
itemCount: SpiderDifficulties.allDifficulties.length,
itemBuilder: (context, index) {
// ... (이하 ListTile 로직은 모두 동일)
final SpiderDifficulty level = SpiderDifficulties.allDifficulties[index];
final bool isUnlocked = allLevelsUnlocked || level.levelIndex <= _maxUnlockedLevel;
final (int oldRank, int currentRank) = _rankHistory[level.levelIndex] ?? (0, 0);
Widget? trailingWidget = isUnlocked ? const Icon(Icons.play_arrow_rounded) : null;
final SpiderDifficulty level =
SpiderDifficulties.allDifficulties[index];
final bool isUnlocked = allLevelsUnlocked ||
level.levelIndex <= _maxUnlockedLevel;
final (int oldRank, int currentRank) =
_rankHistory[level.levelIndex] ?? (0, 0);
Widget? trailingWidget = isUnlocked
? const Icon(Icons.play_arrow_rounded)
: null;
String? subtitleText;
Color? subtitleColor;
if (currentRank > 0) {
@@ -167,44 +172,70 @@ class _SpiderLobbyScreenState extends State<SpiderLobbyScreen> {
if (change > 0) {
subtitleText = "$rankStr (▲ $change)";
subtitleColor = Colors.green;
trailingWidget = const Icon(Icons.arrow_circle_up_rounded, color: Colors.green, size: 28);
trailingWidget = const Icon(
Icons.arrow_circle_up_rounded,
color: Colors.green,
size: 28);
} else if (change < 0) {
subtitleText = "$rankStr (▼ ${change.abs()})";
subtitleColor = Colors.red;
trailingWidget = const Icon(Icons.arrow_circle_down_rounded, color: Colors.red, size: 28);
trailingWidget = const Icon(
Icons.arrow_circle_down_rounded,
color: Colors.red,
size: 28);
} else {
subtitleText = "$rankStr (유지)";
subtitleColor = Colors.grey;
trailingWidget = const Icon(Icons.check_circle_outline_rounded, color: Colors.grey, size: 28);
trailingWidget = const Icon(
Icons.check_circle_outline_rounded,
color: Colors.grey,
size: 28);
}
} else {
subtitleText = "$rankStr (신규 진입)";
subtitleColor = Colors.blue;
trailingWidget = const Icon(Icons.new_releases_rounded, color: Colors.blue, size: 28);
trailingWidget = const Icon(
Icons.new_releases_rounded,
color: Colors.blue,
size: 28);
}
} else {
if (oldRank > 0) {
subtitleText = "랭킹 이탈 (이전 ${oldRank}위)";
subtitleColor = Colors.orange;
trailingWidget = const Icon(Icons.warning_amber_rounded, color: Colors.orange, size: 28);
trailingWidget = const Icon(
Icons.warning_amber_rounded,
color: Colors.orange,
size: 28);
}
}
return Card(
margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0),
margin: const EdgeInsets.symmetric(
horizontal: 16.0, vertical: 4.0),
child: ListTile(
leading: Icon(
isUnlocked ? Icons.lock_open_rounded : Icons.lock_rounded,
isUnlocked
? Icons.lock_open_rounded
: Icons.lock_rounded,
color: isUnlocked ? theme.primaryColor : Colors.grey,
),
title: Text(level.name, style: TextStyle(
fontSize: 18,
fontWeight: isUnlocked ? FontWeight.bold : FontWeight.normal,
color: isUnlocked ? theme.textTheme.bodyLarge?.color : Colors.grey,
)),
title: Text(level.name,
style: TextStyle(
fontSize: 18,
fontWeight: isUnlocked
? FontWeight.bold
: FontWeight.normal,
color: isUnlocked
? theme.textTheme.bodyLarge?.color
: Colors.grey,
)),
subtitle: subtitleText != null
? Text(subtitleText, style: TextStyle(color: subtitleColor, fontWeight: FontWeight.bold))
: null,
trailing: trailingWidget,
? Text(subtitleText,
style: TextStyle(
color: subtitleColor,
fontWeight: FontWeight.bold))
: null,
trailing: trailingWidget,
onTap: isUnlocked && !_isLoading
? () => _startGame(level)
: null,