mirror of https://github.com/flutter/pinball.git
commit
2177f7707a
@ -0,0 +1,69 @@
|
|||||||
|
/// {@template leaderboard_exception}
|
||||||
|
/// Base exception for leaderboard repository failures.
|
||||||
|
/// {@endtemplate}
|
||||||
|
abstract class LeaderboardException implements Exception {
|
||||||
|
/// {@macro leaderboard_exception}
|
||||||
|
const LeaderboardException(this.error, this.stackTrace);
|
||||||
|
|
||||||
|
/// The error that was caught.
|
||||||
|
final Object error;
|
||||||
|
|
||||||
|
/// The Stacktrace associated with the [error].
|
||||||
|
final StackTrace stackTrace;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// {@template leaderboard_deserialization_exception}
|
||||||
|
/// Exception thrown when leaderboard data cannot be deserialized in the
|
||||||
|
/// expected way.
|
||||||
|
/// {@endtemplate}
|
||||||
|
class LeaderboardDeserializationException extends LeaderboardException {
|
||||||
|
/// {@macro leaderboard_deserialization_exception}
|
||||||
|
const LeaderboardDeserializationException(Object error, StackTrace stackTrace)
|
||||||
|
: super(error, stackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// {@template fetch_top_10_leaderboard_exception}
|
||||||
|
/// Exception thrown when failure occurs while fetching top 10 leaderboard.
|
||||||
|
/// {@endtemplate}
|
||||||
|
class FetchTop10LeaderboardException extends LeaderboardException {
|
||||||
|
/// {@macro fetch_top_10_leaderboard_exception}
|
||||||
|
const FetchTop10LeaderboardException(Object error, StackTrace stackTrace)
|
||||||
|
: super(error, stackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// {@template fetch_leaderboard_exception}
|
||||||
|
/// Exception thrown when failure occurs while fetching the leaderboard.
|
||||||
|
/// {@endtemplate}
|
||||||
|
class FetchLeaderboardException extends LeaderboardException {
|
||||||
|
/// {@macro fetch_top_10_leaderboard_exception}
|
||||||
|
const FetchLeaderboardException(Object error, StackTrace stackTrace)
|
||||||
|
: super(error, stackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// {@template delete_leaderboard_exception}
|
||||||
|
/// Exception thrown when failure occurs while deleting the leaderboard under
|
||||||
|
/// the tenth position.
|
||||||
|
/// {@endtemplate}
|
||||||
|
class DeleteLeaderboardException extends LeaderboardException {
|
||||||
|
/// {@macro fetch_top_10_leaderboard_exception}
|
||||||
|
const DeleteLeaderboardException(Object error, StackTrace stackTrace)
|
||||||
|
: super(error, stackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// {@template add_leaderboard_entry_exception}
|
||||||
|
/// Exception thrown when failure occurs while adding entry to leaderboard.
|
||||||
|
/// {@endtemplate}
|
||||||
|
class AddLeaderboardEntryException extends LeaderboardException {
|
||||||
|
/// {@macro add_leaderboard_entry_exception}
|
||||||
|
const AddLeaderboardEntryException(Object error, StackTrace stackTrace)
|
||||||
|
: super(error, stackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// {@template fetch_prohibited_initials_exception}
|
||||||
|
/// Exception thrown when failure occurs while fetching prohibited initials.
|
||||||
|
/// {@endtemplate}
|
||||||
|
class FetchProhibitedInitialsException extends LeaderboardException {
|
||||||
|
/// {@macro fetch_prohibited_initials_exception}
|
||||||
|
const FetchProhibitedInitialsException(Object error, StackTrace stackTrace)
|
||||||
|
: super(error, stackTrace);
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:leaderboard_repository/leaderboard_repository.dart';
|
|
||||||
|
|
||||||
/// {@template leaderboard_ranking}
|
|
||||||
/// Contains [ranking] for a single [LeaderboardEntryData] and the number of
|
|
||||||
/// players the [ranking] is [outOf].
|
|
||||||
/// {@endtemplate}
|
|
||||||
class LeaderboardRanking extends Equatable {
|
|
||||||
/// {@macro leaderboard_ranking}
|
|
||||||
const LeaderboardRanking({required this.ranking, required this.outOf});
|
|
||||||
|
|
||||||
/// Place ranking by score for a [LeaderboardEntryData].
|
|
||||||
final int ranking;
|
|
||||||
|
|
||||||
/// Number of [LeaderboardEntryData]s at the time of score entry.
|
|
||||||
final int outOf;
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [ranking, outOf];
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
import 'package:leaderboard_repository/leaderboard_repository.dart';
|
|
||||||
import 'package:test/test.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
group('LeaderboardRanking', () {
|
|
||||||
test('can be instantiated', () {
|
|
||||||
const leaderboardRanking = LeaderboardRanking(ranking: 1, outOf: 1);
|
|
||||||
|
|
||||||
expect(leaderboardRanking, isNotNull);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('supports value equality.', () {
|
|
||||||
const leaderboardRanking = LeaderboardRanking(ranking: 1, outOf: 1);
|
|
||||||
const leaderboardRanking2 = LeaderboardRanking(ranking: 1, outOf: 1);
|
|
||||||
|
|
||||||
expect(leaderboardRanking, equals(leaderboardRanking2));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
Loading…
Reference in new issue