mirror of
https://github.com/lichess-org/mobile.git
synced 2026-05-26 13:50:52 +00:00
Fix new lint rules
This commit is contained in:
@@ -52,7 +52,7 @@ Future<int> getDbSizeInBytes(Ref ref) async {
|
||||
}
|
||||
|
||||
/// Opens the app database.
|
||||
Future<Database> openAppDatabase(DatabaseFactory dbFactory, String path) async {
|
||||
Future<Database> openAppDatabase(DatabaseFactory dbFactory, String path) {
|
||||
return dbFactory.openDatabase(
|
||||
path,
|
||||
options: OpenDatabaseOptions(
|
||||
|
||||
@@ -38,7 +38,7 @@ Future<Database> _openDb(String path) async {
|
||||
} catch (_) {}
|
||||
|
||||
// Delete existing previous if any
|
||||
directory.list().forEach((file) async {
|
||||
directory.list().forEach((file) {
|
||||
if (file.path.startsWith('chess_openings')) {
|
||||
deleteDatabase(file.path);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class BroadcastPreferences extends _$BroadcastPreferences with PreferencesStorag
|
||||
return fetch();
|
||||
}
|
||||
|
||||
Future<void> toggleEvaluationBar() async {
|
||||
Future<void> toggleEvaluationBar() {
|
||||
return save(state.copyWith(showEvaluationBar: !state.showEvaluationBar));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ BroadcastImageWorkerFactory broadcastImageWorkerFactory(Ref ref) {
|
||||
class BroadcastImageWorkerFactory {
|
||||
const BroadcastImageWorkerFactory();
|
||||
|
||||
Future<ImageColorWorker> spawn() async {
|
||||
Future<ImageColorWorker> spawn() {
|
||||
return ImageColorWorker.spawn();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class ChallengeRepository {
|
||||
|
||||
final LichessClient client;
|
||||
|
||||
Future<ChallengesList> list() async {
|
||||
Future<ChallengesList> list() {
|
||||
final uri = Uri(path: '/api/challenge');
|
||||
return client.readJson(
|
||||
uri,
|
||||
@@ -37,12 +37,12 @@ class ChallengeRepository {
|
||||
);
|
||||
}
|
||||
|
||||
Future<Challenge> show(ChallengeId id) async {
|
||||
Future<Challenge> show(ChallengeId id) {
|
||||
final uri = Uri(path: '/api/challenge/$id/show');
|
||||
return client.readJson(uri, mapper: Challenge.fromServerJson);
|
||||
}
|
||||
|
||||
Future<Challenge> create(ChallengeRequest challenge) async {
|
||||
Future<Challenge> create(ChallengeRequest challenge) {
|
||||
final uri = Uri(path: '/api/challenge/${challenge.destUser.id}');
|
||||
return client.postReadJson(
|
||||
uri,
|
||||
|
||||
@@ -14,7 +14,7 @@ class Challenges extends _$Challenges {
|
||||
StreamSubscription<ChallengesList>? _subscription;
|
||||
|
||||
@override
|
||||
Future<ChallengesList> build() async {
|
||||
Future<ChallengesList> build() {
|
||||
_subscription = ChallengeService.stream.listen((list) => state = AsyncValue.data(list));
|
||||
|
||||
ref.onDispose(() {
|
||||
|
||||
@@ -188,7 +188,7 @@ class CreateGameService {
|
||||
///
|
||||
/// Returns the created challenge immediately. If the challenge is accepted,
|
||||
/// a notification will be sent to the user when the game starts.
|
||||
Future<Challenge> newCorrespondenceChallenge(ChallengeRequest challenge) async {
|
||||
Future<Challenge> newCorrespondenceChallenge(ChallengeRequest challenge) {
|
||||
assert(challenge.timeControl == ChallengeTimeControlType.correspondence);
|
||||
|
||||
_log.info('Creating new correspondence challenge');
|
||||
|
||||
@@ -172,7 +172,7 @@ class NotificationService {
|
||||
}
|
||||
|
||||
/// Cancels/removes a notification.
|
||||
Future<void> cancel(int id) async {
|
||||
Future<void> cancel(int id) {
|
||||
_logger.info('canceled notification id: [$id]');
|
||||
return _notificationDisplay.cancel(id);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ Future<IList<PuzzleHistoryEntry>?> puzzleRecentActivity(Ref ref) async {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<StormDashboard?> stormDashboard(Ref ref, UserId id) async {
|
||||
Future<StormDashboard?> stormDashboard(Ref ref, UserId id) {
|
||||
return ref.withClient((client) => PuzzleRepository(client).stormDashboard(id));
|
||||
}
|
||||
|
||||
|
||||
@@ -191,7 +191,7 @@ class PuzzleService {
|
||||
)),
|
||||
|
||||
// we don't need to save the batch if the request failed
|
||||
(_, __) => Result.value((data, null, null, false)),
|
||||
(_, _) => Result.value((data, null, null, false)),
|
||||
)
|
||||
.flatMap((tuple) async {
|
||||
final (newBatch, glicko, rounds, shouldSave) = tuple;
|
||||
|
||||
@@ -157,7 +157,7 @@ class StormController extends _$StormController {
|
||||
state = newState;
|
||||
}
|
||||
},
|
||||
onError: (_, __) {
|
||||
onError: (_, _) {
|
||||
state = newState;
|
||||
},
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@ class RelationRepository {
|
||||
|
||||
final LichessClient client;
|
||||
|
||||
Future<IList<User>> getFollowing() async {
|
||||
Future<IList<User>> getFollowing() {
|
||||
return client.readNdJsonList(
|
||||
Uri(path: '/api/rel/following'),
|
||||
headers: {'Accept': 'application/x-ndjson'},
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'relation_repository_providers.g.dart';
|
||||
|
||||
@riverpod
|
||||
Future<IList<User>> following(Ref ref) async {
|
||||
Future<IList<User>> following(Ref ref) {
|
||||
return ref.withClientCacheFor(
|
||||
(client) => RelationRepository(client).getFollowing(),
|
||||
const Duration(hours: 1),
|
||||
|
||||
@@ -12,7 +12,7 @@ typedef StudyList = ({IList<StudyPageData> studies, int? nextPage});
|
||||
@riverpod
|
||||
class StudyListPaginator extends _$StudyListPaginator {
|
||||
@override
|
||||
Future<StudyList> build({required StudyFilterState filter, String? search}) async {
|
||||
Future<StudyList> build({required StudyFilterState filter, String? search}) {
|
||||
return _nextPage();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class StudyListPaginator extends _$StudyListPaginator {
|
||||
));
|
||||
}
|
||||
|
||||
Future<StudyList> _nextPage() async {
|
||||
Future<StudyList> _nextPage() {
|
||||
final nextPage = state.value?.nextPage ?? 1;
|
||||
|
||||
final repo = ref.read(studyRepositoryProvider);
|
||||
|
||||
@@ -25,7 +25,7 @@ class LiveTvChannels extends _$LiveTvChannels {
|
||||
late SocketClient _socketClient;
|
||||
|
||||
@override
|
||||
Future<LiveTvChannelsState> build() async {
|
||||
Future<LiveTvChannelsState> build() {
|
||||
ref.onDispose(() {
|
||||
_socketSubscription?.cancel();
|
||||
_socketReadySubscription?.cancel();
|
||||
|
||||
@@ -30,7 +30,7 @@ class TvController extends _$TvController {
|
||||
int? _socketEventVersion;
|
||||
|
||||
@override
|
||||
Future<TvState> build(TvChannel? channel, (GameId id, Side orientation)? initialGame) async {
|
||||
Future<TvState> build(TvChannel? channel, (GameId id, Side orientation)? initialGame) {
|
||||
assert(channel != null || initialGame != null, 'Either a channel or a game must be provided');
|
||||
ref.onDispose(() {
|
||||
_socketSubscription?.cancel();
|
||||
|
||||
@@ -14,12 +14,12 @@ part 'user_repository_providers.g.dart';
|
||||
const _kAutoCompleteDebounceTimer = Duration(milliseconds: 300);
|
||||
|
||||
@riverpod
|
||||
Future<User> user(Ref ref, {required UserId id}) async {
|
||||
Future<User> user(Ref ref, {required UserId id}) {
|
||||
return ref.withClient((client) => UserRepository(client).getUser(id));
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<IList<UserActivity>> userActivity(Ref ref, {required UserId id}) async {
|
||||
Future<IList<UserActivity>> userActivity(Ref ref, {required UserId id}) {
|
||||
return ref.withClientCacheFor(
|
||||
(client) => UserRepository(client).getActivity(id),
|
||||
// cache is important because the associated widget is in a [ListView] and
|
||||
@@ -32,8 +32,8 @@ Future<IList<UserActivity>> userActivity(Ref ref, {required UserId id}) async {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<(User, UserStatus)> userAndStatus(Ref ref, {required UserId id}) async {
|
||||
return ref.withClient((client) async {
|
||||
Future<(User, UserStatus)> userAndStatus(Ref ref, {required UserId id}) {
|
||||
return ref.withClient((client) {
|
||||
final repo = UserRepository(client);
|
||||
return Future.wait([
|
||||
repo.getUser(id, withCanChallenge: true),
|
||||
@@ -43,17 +43,17 @@ Future<(User, UserStatus)> userAndStatus(Ref ref, {required UserId id}) async {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<UserPerfStats> userPerfStats(Ref ref, {required UserId id, required Perf perf}) async {
|
||||
Future<UserPerfStats> userPerfStats(Ref ref, {required UserId id, required Perf perf}) {
|
||||
return ref.withClient((client) => UserRepository(client).getPerfStats(id, perf));
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<IList<UserStatus>> userStatuses(Ref ref, {required ISet<UserId> ids}) async {
|
||||
Future<IList<UserStatus>> userStatuses(Ref ref, {required ISet<UserId> ids}) {
|
||||
return ref.withClient((client) => UserRepository(client).getUsersStatuses(ids));
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<IList<Streamer>> liveStreamers(Ref ref) async {
|
||||
Future<IList<Streamer>> liveStreamers(Ref ref) {
|
||||
return ref.withClientCacheFor(
|
||||
(client) => UserRepository(client).getLiveStreamers(),
|
||||
const Duration(minutes: 1),
|
||||
@@ -61,7 +61,7 @@ Future<IList<Streamer>> liveStreamers(Ref ref) async {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<IMap<Perf, LeaderboardUser>> top1(Ref ref) async {
|
||||
Future<IMap<Perf, LeaderboardUser>> top1(Ref ref) {
|
||||
return ref.withClientCacheFor(
|
||||
(client) => UserRepository(client).getTop1(),
|
||||
const Duration(hours: 12),
|
||||
@@ -69,7 +69,7 @@ Future<IMap<Perf, LeaderboardUser>> top1(Ref ref) async {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<Leaderboard> leaderboard(Ref ref) async {
|
||||
Future<Leaderboard> leaderboard(Ref ref) {
|
||||
return ref.withClientCacheFor(
|
||||
(client) => UserRepository(client).getLeaderboard(),
|
||||
const Duration(hours: 2),
|
||||
@@ -90,7 +90,7 @@ Future<IList<LightUser>> autoCompleteUser(Ref ref, String term) async {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<IList<UserRatingHistoryPerf>> userRatingHistory(Ref ref, {required UserId id}) async {
|
||||
Future<IList<UserRatingHistoryPerf>> userRatingHistory(Ref ref, {required UserId id}) {
|
||||
return ref.withClientCacheFor(
|
||||
(client) => UserRepository(client).getRatingHistory(id),
|
||||
const Duration(minutes: 1),
|
||||
|
||||
@@ -69,7 +69,7 @@ class ImmersiveMode {
|
||||
///
|
||||
/// This hides the system UI (status bar and navigation bar) and forces the
|
||||
/// device to stay awake.
|
||||
Future<void> enable() async {
|
||||
Future<void> enable() {
|
||||
return Future.wait([
|
||||
WakelockPlus.enable(),
|
||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky),
|
||||
|
||||
@@ -35,7 +35,7 @@ class EditProfileScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool?> _showBackDialog(BuildContext context) async {
|
||||
Future<bool?> _showBackDialog(BuildContext context) {
|
||||
return showAdaptiveDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
@@ -290,7 +290,7 @@ class _EditProfileFormState extends ConsumerState<_EditProfileForm> {
|
||||
final result = await future;
|
||||
|
||||
result.match(
|
||||
onError: (err, __) {
|
||||
onError: (err, _) {
|
||||
if (context.mounted) {
|
||||
showPlatformSnackbar(
|
||||
context,
|
||||
|
||||
@@ -580,7 +580,7 @@ class _BroadcastGameBottomBar extends ConsumerWidget {
|
||||
if (tournamentSlug != null && roundSlug != null)
|
||||
BottomSheetAction(
|
||||
makeLabel: (context) => Text(context.l10n.mobileShareGameURL),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
launchShareDialog(
|
||||
context,
|
||||
uri: lichessUri('/broadcast/$tournamentSlug/$roundSlug/$roundId/$gameId'),
|
||||
|
||||
@@ -383,7 +383,7 @@ class BroadcastListTile extends StatelessWidget {
|
||||
width: thumbnailSize,
|
||||
cacheWidth: (thumbnailSize * devicePixelRatio).toInt(),
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, _, __) => const Icon(LichessIcons.radio_tower_lichess),
|
||||
errorBuilder: (context, _, _) => const Icon(LichessIcons.radio_tower_lichess),
|
||||
)
|
||||
: Image(image: kDefaultBroadcastImage, width: thumbnailSize);
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ import 'package:lichess_mobile/src/widgets/adaptive_action_sheet.dart';
|
||||
Future<void> showBroadcastShareMenu(
|
||||
BuildContext context,
|
||||
Broadcast broadcast,
|
||||
) async => showAdaptiveActionSheet<void>(
|
||||
) => showAdaptiveActionSheet<void>(
|
||||
context: context,
|
||||
actions: [
|
||||
BottomSheetAction(
|
||||
makeLabel: (context) => Text(broadcast.title),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
launchShareDialog(
|
||||
context,
|
||||
uri: lichessUri('/broadcast/${broadcast.tour.slug}/${broadcast.tour.id}'),
|
||||
@@ -21,7 +21,7 @@ Future<void> showBroadcastShareMenu(
|
||||
),
|
||||
BottomSheetAction(
|
||||
makeLabel: (context) => Text(broadcast.round.name),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
launchShareDialog(
|
||||
context,
|
||||
uri: lichessUri(
|
||||
@@ -32,7 +32,7 @@ Future<void> showBroadcastShareMenu(
|
||||
),
|
||||
BottomSheetAction(
|
||||
makeLabel: (context) => Text('${broadcast.round.name} PGN'),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
launchShareDialog(
|
||||
context,
|
||||
uri: lichessUri(
|
||||
|
||||
@@ -118,7 +118,7 @@ class GamePlayer extends StatelessWidget {
|
||||
const SizedBox(width: 5),
|
||||
CachedNetworkImage(
|
||||
imageUrl: lichessFlairSrc(player.user!.flair!),
|
||||
errorWidget: (_, __, ___) => kEmptyWidget,
|
||||
errorWidget: (_, _, _) => kEmptyWidget,
|
||||
width: 16,
|
||||
height: 16,
|
||||
),
|
||||
|
||||
@@ -198,7 +198,7 @@ class _HomeScreenState extends ConsumerState<HomeTabScreen> with RouteAware {
|
||||
);
|
||||
}
|
||||
},
|
||||
error: (_, __) => const CenterLoadingIndicator(),
|
||||
error: (_, _) => const CenterLoadingIndicator(),
|
||||
loading: () => const CenterLoadingIndicator(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import 'package:lichess_mobile/src/widgets/user_full_name.dart';
|
||||
import 'package:linkify/linkify.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
final _onlineBotsProvider = FutureProvider.autoDispose<IList<User>>((ref) async {
|
||||
final _onlineBotsProvider = FutureProvider.autoDispose<IList<User>>((ref) {
|
||||
return ref.withClientCacheFor(
|
||||
(client) => UserRepository(client).getOnlineBots().then((bots) => bots.toIList()),
|
||||
const Duration(hours: 5),
|
||||
@@ -175,7 +175,7 @@ class _ContextMenu extends ConsumerWidget {
|
||||
const SizedBox(height: 8.0),
|
||||
if (bot.profile?.bio != null)
|
||||
Linkify(
|
||||
onOpen: (link) async {
|
||||
onOpen: (link) {
|
||||
if (link.originText.startsWith('@')) {
|
||||
final username = link.originText.substring(1);
|
||||
Navigator.of(context).push(
|
||||
|
||||
@@ -118,7 +118,7 @@ class _Title extends ConsumerWidget {
|
||||
.when(
|
||||
data: (data) => Text(data),
|
||||
loading: () => const SizedBox.shrink(),
|
||||
error: (_, __) => Text(key.replaceAll('_', ' ')),
|
||||
error: (_, _) => Text(key.replaceAll('_', ' ')),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class _Body extends ConsumerWidget {
|
||||
);
|
||||
},
|
||||
separatorBuilder:
|
||||
(_, __) => PlatformDivider(
|
||||
(_, _) => PlatformDivider(
|
||||
height: 1,
|
||||
// on iOS: 14 (default indent) + 16 (padding)
|
||||
indent: Theme.of(context).platform == TargetPlatform.iOS ? 14 + 16 : null,
|
||||
|
||||
@@ -62,7 +62,7 @@ class _PieceSetScreenState extends ConsumerState<PieceSetScreen> {
|
||||
child: ListView.separated(
|
||||
itemCount: PieceSet.values.length,
|
||||
separatorBuilder:
|
||||
(_, __) => PlatformDivider(
|
||||
(_, _) => PlatformDivider(
|
||||
height: 1,
|
||||
// on iOS: 14 (default indent) + 16 (padding)
|
||||
indent: Theme.of(context).platform == TargetPlatform.iOS ? 14 + 16 : null,
|
||||
|
||||
@@ -51,7 +51,7 @@ class _Comment extends ConsumerWidget {
|
||||
child: Linkify(
|
||||
text: comment,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
onOpen: (link) async {
|
||||
onOpen: (link) {
|
||||
launchUrl(Uri.parse(link.url));
|
||||
},
|
||||
),
|
||||
|
||||
@@ -356,7 +356,7 @@ class _StudyFlair extends StatelessWidget {
|
||||
return (flair != null)
|
||||
? CachedNetworkImage(
|
||||
imageUrl: lichessFlairSrc(flair!),
|
||||
errorWidget: (_, __, ___) => iconIfNoFlair,
|
||||
errorWidget: (_, _, _) => iconIfNoFlair,
|
||||
width: size,
|
||||
height: size,
|
||||
)
|
||||
|
||||
@@ -239,13 +239,13 @@ class _StudyMenu extends ConsumerWidget {
|
||||
actions: [
|
||||
BottomSheetAction(
|
||||
makeLabel: (context) => Text(context.l10n.studyStudyUrl),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
launchShareDialog(context, uri: lichessUri('/study/${state.study.id}'));
|
||||
},
|
||||
),
|
||||
BottomSheetAction(
|
||||
makeLabel: (context) => Text(context.l10n.studyCurrentChapterUrl),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
launchShareDialog(
|
||||
context,
|
||||
uri: lichessUri('/study/${state.study.id}/${state.study.chapter.id}'),
|
||||
@@ -276,7 +276,7 @@ class _StudyMenu extends ConsumerWidget {
|
||||
),
|
||||
BottomSheetAction(
|
||||
makeLabel: (context) => Text(context.l10n.studyChapterPgn),
|
||||
onPressed: () async {
|
||||
onPressed: () {
|
||||
launchShareDialog(context, text: state.pgn);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -391,7 +391,7 @@ class _FilterGamesState extends ConsumerState<_FilterGames> {
|
||||
.when(
|
||||
data: (user) => perfFilter(availablePerfs(user)),
|
||||
loading: () => const Center(child: CircularProgressIndicator.adaptive()),
|
||||
error: (_, __) => perfFilter(gamePerfs),
|
||||
error: (_, _) => perfFilter(gamePerfs),
|
||||
)
|
||||
: perfFilter(gamePerfs);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class UserProfileWidget extends ConsumerWidget {
|
||||
Padding(padding: const EdgeInsets.only(bottom: 5), child: userFullName),
|
||||
if (user.profile?.bio != null)
|
||||
Linkify(
|
||||
onOpen: (link) async {
|
||||
onOpen: (link) {
|
||||
if (link.originText.startsWith('@')) {
|
||||
final username = link.originText.substring(1);
|
||||
Navigator.of(context).push(
|
||||
@@ -165,7 +165,7 @@ class Location extends StatelessWidget {
|
||||
if (profile.country != null) ...[
|
||||
CachedNetworkImage(
|
||||
imageUrl: lichessFlagSrc(profile.country!),
|
||||
errorWidget: (_, __, ___) => kEmptyWidget,
|
||||
errorWidget: (_, _, _) => kEmptyWidget,
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
],
|
||||
|
||||
@@ -37,7 +37,7 @@ const _featuredChannelsSet = ISetConst({
|
||||
TvChannel.classical,
|
||||
});
|
||||
|
||||
final featuredChannelsProvider = FutureProvider.autoDispose<IList<TvGameSnapshot>>((ref) async {
|
||||
final featuredChannelsProvider = FutureProvider.autoDispose<IList<TvGameSnapshot>>((ref) {
|
||||
return ref.withClient((client) async {
|
||||
final channels = await TvRepository(client).channels();
|
||||
return _featuredChannelsSet
|
||||
|
||||
@@ -19,7 +19,7 @@ Future<T?> showAdaptiveActionSheet<T>({
|
||||
Widget? title,
|
||||
required List<BottomSheetAction> actions,
|
||||
bool isDismissible = true,
|
||||
}) async {
|
||||
}) {
|
||||
if (Theme.of(context).platform == TargetPlatform.iOS) {
|
||||
return showCupertinoActionSheet(
|
||||
context: context,
|
||||
|
||||
@@ -11,7 +11,7 @@ Future<T?> showAdaptiveBottomSheet<T>({
|
||||
bool isScrollControlled = false,
|
||||
bool? showDragHandle,
|
||||
BoxConstraints? constraints,
|
||||
}) async {
|
||||
}) {
|
||||
return showModalBottomSheet<T>(
|
||||
context: context,
|
||||
isDismissible: isDismissible,
|
||||
|
||||
@@ -140,7 +140,7 @@ class _InvertBackgroundState extends State<_AnimatedInvertBackground>
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: _colorAnimation,
|
||||
builder: (_, __) => Container(color: _colorAnimation.value, child: widget.child),
|
||||
builder: (_, _) => Container(color: _colorAnimation.value, child: widget.child),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class UserFullNameWidget extends ConsumerWidget {
|
||||
const SizedBox(width: 5),
|
||||
CachedNetworkImage(
|
||||
imageUrl: lichessFlairSrc(user!.flair!),
|
||||
errorWidget: (_, __, ___) => kEmptyWidget,
|
||||
errorWidget: (_, _, _) => kEmptyWidget,
|
||||
width: style?.fontSize ?? DefaultTextStyle.of(context).style.fontSize,
|
||||
height: style?.fontSize ?? DefaultTextStyle.of(context).style.fontSize,
|
||||
),
|
||||
|
||||
@@ -83,7 +83,7 @@ class UserListTile extends StatelessWidget {
|
||||
const SizedBox(width: 5),
|
||||
CachedNetworkImage(
|
||||
imageUrl: lichessFlairSrc(flair!),
|
||||
errorWidget: (_, __, ___) => kEmptyWidget,
|
||||
errorWidget: (_, _, _) => kEmptyWidget,
|
||||
width: DefaultTextStyle.of(context).style.fontSize,
|
||||
height: DefaultTextStyle.of(context).style.fontSize,
|
||||
),
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
int tokenTestRequests = 0;
|
||||
final mockClient = MockClient((request) async {
|
||||
final mockClient = MockClient((request) {
|
||||
if (request.url.path == '/api/token/test') {
|
||||
tokenTestRequests++;
|
||||
return mockResponse('''
|
||||
|
||||
@@ -9,7 +9,7 @@ class FakeStockfishFactory extends StockfishFactory {
|
||||
const FakeStockfishFactory();
|
||||
|
||||
@override
|
||||
Future<Stockfish> call() async => Future.value(FakeStockfish());
|
||||
Future<Stockfish> call() => Future.value(FakeStockfish());
|
||||
}
|
||||
|
||||
/// A fake implementation of [Stockfish].
|
||||
|
||||
@@ -18,7 +18,7 @@ import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
void main() {
|
||||
Future<ProviderContainer> makeTestContainer(MockClient mockClient) async {
|
||||
Future<ProviderContainer> makeTestContainer(MockClient mockClient) {
|
||||
return makeContainer(
|
||||
overrides: [
|
||||
lichessClientProvider.overrideWith((ref) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import '../../test_container.dart';
|
||||
import '../../test_helpers.dart';
|
||||
|
||||
void main() {
|
||||
Future<ProviderContainer> makeTestContainer(MockClient mockClient) async {
|
||||
Future<ProviderContainer> makeTestContainer(MockClient mockClient) {
|
||||
return makeContainer(
|
||||
overrides: [
|
||||
lichessClientProvider.overrideWith((ref) {
|
||||
|
||||
@@ -32,7 +32,7 @@ final testContainerMockClient = MockClient((request) async {
|
||||
|
||||
/// Returns a [ProviderContainer] with the [httpClientFactoryProvider] configured
|
||||
/// with the given [mockClient].
|
||||
Future<ProviderContainer> lichessClientContainer(MockClient mockClient) async {
|
||||
Future<ProviderContainer> lichessClientContainer(MockClient mockClient) {
|
||||
return makeContainer(
|
||||
overrides: [
|
||||
httpClientFactoryProvider.overrideWith((ref) {
|
||||
|
||||
@@ -42,7 +42,7 @@ final mockClient = MockClient((request) async {
|
||||
return http.Response('', 200);
|
||||
});
|
||||
|
||||
final offlineClient = MockClient((request) async {
|
||||
final offlineClient = MockClient((request) {
|
||||
throw const SocketException('No internet');
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ Future<Widget> makeTestProviderScopeApp(
|
||||
List<Override>? overrides,
|
||||
AuthSessionState? userSession,
|
||||
Map<String, Object>? defaultPreferences,
|
||||
}) async {
|
||||
}) {
|
||||
return makeTestProviderScope(
|
||||
tester,
|
||||
child: MaterialApp(
|
||||
|
||||
@@ -59,7 +59,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('throttle', () {
|
||||
test('should call the callback immediately', () async {
|
||||
test('should call the callback immediately', () {
|
||||
final throttler = Throttler(const Duration(milliseconds: 100));
|
||||
var called = false;
|
||||
throttler(() {
|
||||
|
||||
@@ -106,7 +106,7 @@ void main() {
|
||||
|
||||
testWidgets('session, no played game: do not show welcome screen', (tester) async {
|
||||
int nbUserGamesRequests = 0;
|
||||
final mockClient = MockClient((request) async {
|
||||
final mockClient = MockClient((request) {
|
||||
if (request.url.path == '/api/games/user/testuser') {
|
||||
nbUserGamesRequests++;
|
||||
return mockResponse('', 200);
|
||||
@@ -153,7 +153,7 @@ void main() {
|
||||
|
||||
testWidgets('session, with played games: shows recent games', (tester) async {
|
||||
int nbUserGamesRequests = 0;
|
||||
final mockClient = MockClient((request) async {
|
||||
final mockClient = MockClient((request) {
|
||||
if (request.url.path == '/api/games/user/testuser') {
|
||||
nbUserGamesRequests++;
|
||||
return mockResponse(mockUserRecentGameResponse('testUser'), 200);
|
||||
@@ -182,7 +182,7 @@ void main() {
|
||||
|
||||
testWidgets('shows ongoing games if any', (tester) async {
|
||||
int nbOngoingGamesRequests = 0;
|
||||
final mockClient = MockClient((request) async {
|
||||
final mockClient = MockClient((request) {
|
||||
if (request.url.path == '/api/account/playing') {
|
||||
nbOngoingGamesRequests++;
|
||||
return mockResponse(mockAccountOngoingGamesResponse(), 200);
|
||||
|
||||
@@ -24,7 +24,7 @@ import '../../test_helpers.dart';
|
||||
import '../../test_provider_scope.dart';
|
||||
import 'example_data.dart';
|
||||
|
||||
final mockClient = MockClient((request) async {
|
||||
final mockClient = MockClient((request) {
|
||||
if (request.url.path == '/api/puzzle/daily') {
|
||||
return mockResponse(mockDailyPuzzleResponse, 200);
|
||||
}
|
||||
@@ -238,7 +238,7 @@ void main() {
|
||||
httpClientFactoryProvider.overrideWith((ref) {
|
||||
return FakeHttpClientFactory(() => mockClient);
|
||||
}),
|
||||
databaseProvider.overrideWith((ref) async {
|
||||
databaseProvider.overrideWith((ref) {
|
||||
ref.onDispose(testDb.close);
|
||||
return testDb;
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user