turn property

Provider<bool> turn
final

Provides whether it is the players turn for the current game of the client with the specified id

Implementation

static final turn = Provider<bool>((ref) {
  final pID = ref.watch(playerID);
  final _ = ref.watch(code); // Invalidate on change of gameCode
  final currentPlayer = ref.watch(game).asData?.value.currentPlayer?.id;
  // Null indicates that all players can go simulataneously
  return currentPlayer == null || currentPlayer == pID;
}, name: 'GameTurn', dependencies: [playerID, code, game]);