Skip to content

Commit

Permalink
Add flutter lints
Browse files Browse the repository at this point in the history
  • Loading branch information
julien4215 committed Dec 24, 2024
1 parent 59a38b0 commit c2145a2
Show file tree
Hide file tree
Showing 85 changed files with 162 additions and 135 deletions.
7 changes: 4 additions & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:lint/strict.yaml
# The following lines activate a set of recommended lints.
include:
- package:lint/strict.yaml
- package:flutter_lints/flutter.yaml

analyzer:
language:
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/game/archived_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ArchivedGame with _$ArchivedGame, BaseGame, IndexableSteps implements Base
/// Create an archived game from the lichess api.
///
/// Currently, those endpoints are supported:
/// - GET /game/export/<id>
/// - GET /game/export/\<id\>
factory ArchivedGame.fromServerJson(Map<String, dynamic> json) {
return _archivedGameFromPick(pick(json).required());
}
Expand Down Expand Up @@ -88,7 +88,7 @@ typedef LightArchivedGameWithPov = ({LightArchivedGame game, Side pov});
///
/// This is commonly used to display a list of games.
/// Lichess endpoints that return this data:
/// - GET /api/games/user/<userId>
/// - GET /api/games/user/\<userId\>
/// - GET /api/games/export/_ids
@Freezed(fromJson: true, toJson: true)
class LightArchivedGame with _$LightArchivedGame {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/model/game/playable_game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class PlayableGame with _$PlayableGame, BaseGame, IndexableSteps implements Base
///
/// Currently, those endpoints are supported:
/// - GET /api/mobile/my-games
/// - player game socket (/play/<gameFullId>/v6) 'full' event
/// - watcher game socket (/watch/<gameId>/<side>/v6) 'full' event
/// - player game socket (/play/\<gameFullId\>/v6) 'full' event
/// - watcher game socket (/watch/<\gameId\>/<\side\>/v6) 'full' event
factory PlayableGame.fromServerJson(Map<String, dynamic> json) {
return _playableGameFromPick(pick(json).required());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/utils/focus_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class FocusDetector extends StatefulWidget {
final Widget child;

@override
_FocusDetectorState createState() => _FocusDetectorState();
State<FocusDetector> createState() => _FocusDetectorState();
}

class _FocusDetectorState extends State<FocusDetector> with WidgetsBindingObserver {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/account/profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ProfileScreen extends ConsumerWidget {
}

class AccountPerfCards extends ConsumerWidget {
const AccountPerfCards({this.padding});
const AccountPerfCards({super.key, this.padding});

final EdgeInsetsGeometry? padding;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/analysis/analysis_board.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:lichess_mobile/src/widgets/pgn.dart';
class AnalysisBoard extends ConsumerStatefulWidget {
const AnalysisBoard(
this.options,
this.boardSize, {
this.boardSize, {super.key,
this.borderRadius,
this.enableDrawingShapes = true,
this.shouldReplaceChildOnUserMove = false,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/analysis/analysis_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import 'package:logging/logging.dart';
final _logger = Logger('AnalysisScreen');

class AnalysisScreen extends ConsumerStatefulWidget {
const AnalysisScreen({required this.options, this.enableDrawingShapes = true});
const AnalysisScreen({super.key, required this.options, this.enableDrawingShapes = true});

final AnalysisOptions options;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/analysis/analysis_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:lichess_mobile/src/widgets/platform_scaffold.dart';
import 'package:lichess_mobile/src/widgets/settings.dart';

class AnalysisSettings extends ConsumerWidget {
const AnalysisSettings(this.options);
const AnalysisSettings(this.options, {super.key});

final AnalysisOptions options;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/analysis/analysis_share_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import 'package:lichess_mobile/src/widgets/platform_scaffold.dart';
final _dateFormatter = DateFormat('yyyy.MM.dd');

class AnalysisShareScreen extends StatelessWidget {
const AnalysisShareScreen({required this.options});
const AnalysisShareScreen({super.key, required this.options});

final AnalysisOptions options;

Expand Down
4 changes: 2 additions & 2 deletions lib/src/view/analysis/server_analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import 'package:lichess_mobile/src/widgets/buttons.dart';
import 'package:lichess_mobile/src/widgets/feedback.dart';

class ServerAnalysisSummary extends ConsumerWidget {
const ServerAnalysisSummary(this.options);
const ServerAnalysisSummary(this.options, {super.key});

final AnalysisOptions options;

Expand Down Expand Up @@ -295,7 +295,7 @@ class _SummaryPlayerName extends StatelessWidget {
}

class AcplChart extends ConsumerWidget {
const AcplChart(this.options);
const AcplChart(this.options, {super.key});

final AnalysisOptions options;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/analysis/tree_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:lichess_mobile/src/widgets/pgn.dart';
const kOpeningHeaderHeight = 32.0;

class AnalysisTreeView extends ConsumerWidget {
const AnalysisTreeView(this.options);
const AnalysisTreeView(this.options, {super.key});

final AnalysisOptions options;

Expand Down
6 changes: 3 additions & 3 deletions lib/src/view/broadcast/broadcast_boards_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const _kPlayerWidgetPadding = EdgeInsets.symmetric(vertical: 5.0);

/// A tab that displays the live games of a broadcast round.
class BroadcastBoardsTab extends ConsumerWidget {
const BroadcastBoardsTab({
const BroadcastBoardsTab({super.key,
required this.tournamentId,
required this.roundId,
required this.tournamentSlug,
Expand Down Expand Up @@ -79,7 +79,7 @@ class BroadcastBoardsTab extends ConsumerWidget {
}

class BroadcastPreview extends StatelessWidget {
const BroadcastPreview({
const BroadcastPreview({super.key,
required this.tournamentId,
required this.roundId,
required this.games,
Expand All @@ -88,7 +88,7 @@ class BroadcastPreview extends StatelessWidget {
required this.roundSlug,
});

const BroadcastPreview.loading()
const BroadcastPreview.loading({super.key})
: tournamentId = const BroadcastTournamentId(''),
roundId = const BroadcastRoundId(''),
games = null,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/broadcast/broadcast_game_bottom_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'package:lichess_mobile/src/widgets/buttons.dart';
import 'package:lichess_mobile/src/widgets/feedback.dart';

class BroadcastGameBottomBar extends ConsumerWidget {
const BroadcastGameBottomBar({
const BroadcastGameBottomBar({super.key,
required this.roundId,
required this.gameId,
this.tournamentSlug,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/broadcast/broadcast_game_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class BroadcastGameScreen extends ConsumerStatefulWidget {
final String? roundSlug;
final String? title;

const BroadcastGameScreen({
const BroadcastGameScreen({super.key,
required this.tournamentId,
required this.roundId,
required this.gameId,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/broadcast/broadcast_game_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:lichess_mobile/src/widgets/platform_scaffold.dart';
import 'package:lichess_mobile/src/widgets/settings.dart';

class BroadcastGameSettings extends ConsumerWidget {
const BroadcastGameSettings(this.roundId, this.gameId);
const BroadcastGameSettings(this.roundId, this.gameId, {super.key});

final BroadcastRoundId roundId;
final BroadcastGameId gameId;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/broadcast/broadcast_game_tree_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:lichess_mobile/src/widgets/pgn.dart';
const kOpeningHeaderHeight = 32.0;

class BroadcastGameTreeView extends ConsumerWidget {
const BroadcastGameTreeView(this.roundId, this.gameId);
const BroadcastGameTreeView(this.roundId, this.gameId, {super.key});

final BroadcastRoundId roundId;
final BroadcastGameId gameId;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/broadcast/broadcast_list_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class BroadcastCard extends StatefulWidget {
final ImageColorWorker worker;
final double aspectRatio;

const BroadcastCard.loading({required this.worker, required this.aspectRatio})
const BroadcastCard.loading({super.key, required this.worker, required this.aspectRatio})
: broadcast = const Broadcast(
tour: BroadcastTournamentData(
id: BroadcastTournamentId(''),
Expand Down
5 changes: 3 additions & 2 deletions lib/src/view/broadcast/broadcast_player_results_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ class BroadcastPlayerResultsScreen extends StatelessWidget {
this.tournamentId,
this.playerId,
this.playerTitle,
this.playerName,
);
this.playerName, {
super.key,
});

@override
Widget build(BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/broadcast/broadcast_player_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:lichess_mobile/src/styles/styles.dart';

class BroadcastPlayerWidget extends ConsumerWidget {
const BroadcastPlayerWidget({
const BroadcastPlayerWidget({super.key,
this.federation,
required this.title,
required this.name,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/view/broadcast/broadcast_players_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:lichess_mobile/src/widgets/progression_widget.dart';

/// A tab that displays the players participating in a broadcast tournament.
class BroadcastPlayersTab extends ConsumerWidget {
const BroadcastPlayersTab({required this.tournamentId});
const BroadcastPlayersTab({super.key, required this.tournamentId});

final BroadcastTournamentId tournamentId;

Expand Down Expand Up @@ -52,7 +52,7 @@ const _kTableRowPadding = EdgeInsets.symmetric(
const _kHeaderTextStyle = TextStyle(fontWeight: FontWeight.bold, overflow: TextOverflow.ellipsis);

class PlayersList extends ConsumerStatefulWidget {
const PlayersList(this.players, this.tournamentId);
const PlayersList(this.players, this.tournamentId, {super.key});

final IList<BroadcastPlayerExtended> players;
final BroadcastTournamentId tournamentId;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/view/broadcast/broadcast_round_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import 'package:lichess_mobile/src/widgets/shimmer.dart';
class BroadcastRoundScreen extends ConsumerStatefulWidget {
final Broadcast broadcast;

const BroadcastRoundScreen({required this.broadcast});
const BroadcastRoundScreen({super.key, required this.broadcast});

@override
_BroadcastRoundScreenState createState() => _BroadcastRoundScreenState();
ConsumerState<BroadcastRoundScreen> createState() => _BroadcastRoundScreenState();
}

enum _CupertinoView { overview, boards, players }
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/clock/custom_clock_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:lichess_mobile/src/widgets/list.dart';
import 'package:lichess_mobile/src/widgets/non_linear_slider.dart';

class CustomClockSettings extends StatefulWidget {
const CustomClockSettings({required this.onSubmit, required this.player, required this.clock});
const CustomClockSettings({super.key, required this.onSubmit, required this.player, required this.clock});

final Side player;
final TimeIncrement clock;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/coordinate_training/coordinate_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const double _kCurrCoordOpacity = 0.9;
const double _kNextCoordOpacity = 0.7;

class CoordinateDisplay extends ConsumerStatefulWidget {
const CoordinateDisplay({required this.currentCoord, required this.nextCoord});
const CoordinateDisplay({super.key, required this.currentCoord, required this.nextCoord});

final Square currentCoord;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ class _Button extends StatelessWidget {
}

class SettingsBottomSheet extends ConsumerWidget {
const SettingsBottomSheet();
const SettingsBottomSheet({super.key});

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/engine/engine_depth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:lichess_mobile/src/widgets/list.dart';
import 'package:popover/popover.dart';

class EngineDepth extends ConsumerWidget {
const EngineDepth({this.defaultEval});
const EngineDepth({super.key, this.defaultEval});

final ClientEval? defaultEval;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/engine/engine_gauge.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ typedef EngineGaugeParams =
});

class EngineGauge extends ConsumerWidget {
const EngineGauge({required this.displayMode, required this.params});
const EngineGauge({super.key, required this.displayMode, required this.params});

final EngineGaugeDisplayMode displayMode;

Expand Down
6 changes: 3 additions & 3 deletions lib/src/view/engine/engine_lines.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:lichess_mobile/src/view/engine/engine_gauge.dart';
import 'package:lichess_mobile/src/widgets/buttons.dart';

class EngineLines extends ConsumerWidget {
const EngineLines({required this.onTapMove, required this.clientEval, required this.isGameOver});
const EngineLines({super.key, required this.onTapMove, required this.clientEval, required this.isGameOver});
final void Function(NormalMove move) onTapMove;
final ClientEval? clientEval;
final bool isGameOver;
Expand Down Expand Up @@ -49,9 +49,9 @@ class EngineLines extends ConsumerWidget {
}

class Engineline extends ConsumerWidget {
const Engineline(this.onTapMove, this.fromPosition, this.pvData);
const Engineline(this.onTapMove, this.fromPosition, this.pvData, {super.key});

const Engineline.empty()
const Engineline.empty({super.key})
: onTapMove = null,
pvData = const PvData(moves: IListConst([])),
fromPosition = Chess.initial;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/game/game_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import 'package:lichess_mobile/src/widgets/yes_no_dialog.dart';
/// Handles the immersive mode through focus detection, and the pop scope to
/// prevent the user from going back to the previous screen.
class GameBody extends ConsumerWidget {
const GameBody({
const GameBody({super.key,
required this.id,
required this.whiteClockKey,
required this.blackClockKey,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/view/game/game_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final _dateFormatter = DateFormat.yMMMd().add_Hm();

/// A list tile that shows game info.
class GameListTile extends StatelessWidget {
const GameListTile({
const GameListTile({super.key,
required this.game,
required this.mySide,
required this.opponentTitle,
Expand Down Expand Up @@ -359,7 +359,7 @@ class _ContextMenu extends ConsumerWidget {

/// A list tile that shows extended game info including a result icon and analysis icon.
class ExtendedGameListTile extends StatelessWidget {
const ExtendedGameListTile({required this.item, this.userId, this.padding});
const ExtendedGameListTile({super.key, required this.item, this.userId, this.padding});

final LightArchivedGameWithPov item;
final UserId? userId;
Expand Down
8 changes: 4 additions & 4 deletions lib/src/view/game/game_loading_board.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'package:lichess_mobile/src/widgets/platform.dart';
import 'package:lichess_mobile/src/widgets/user_full_name.dart';

class LobbyScreenLoadingContent extends StatelessWidget {
const LobbyScreenLoadingContent(this.seek, this.cancelGameCreation);
const LobbyScreenLoadingContent(this.seek, this.cancelGameCreation, {super.key});

final GameSeek seek;
final Future<void> Function() cancelGameCreation;
Expand Down Expand Up @@ -92,7 +92,7 @@ class LobbyScreenLoadingContent extends StatelessWidget {
}

class ChallengeLoadingContent extends StatelessWidget {
const ChallengeLoadingContent(this.challenge, this.cancelChallenge);
const ChallengeLoadingContent(this.challenge, this.cancelChallenge, {super.key});

final ChallengeRequest challenge;
final Future<void> Function() cancelChallenge;
Expand Down Expand Up @@ -188,7 +188,7 @@ class StandaloneGameLoadingBoard extends StatelessWidget {
}

class LoadGameError extends StatelessWidget {
const LoadGameError(this.errorMessage);
const LoadGameError(this.errorMessage, {super.key});

final String errorMessage;

Expand Down Expand Up @@ -226,7 +226,7 @@ class LoadGameError extends StatelessWidget {

/// A board that shows a message that a challenge has been declined.
class ChallengeDeclinedBoard extends StatelessWidget {
const ChallengeDeclinedBoard({required this.declineReason, required this.challenge});
const ChallengeDeclinedBoard({super.key, required this.declineReason, required this.challenge});

final String declineReason;
final Challenge challenge;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/game/game_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class _MoveExpirationState extends ConsumerState<MoveExpiration> {
}

class MaterialDifferenceDisplay extends StatelessWidget {
const MaterialDifferenceDisplay({
const MaterialDifferenceDisplay({super.key,
required this.materialDiff,
this.materialDifferenceFormat = MaterialDifferenceFormat.materialDifference,
});
Expand Down
Loading

0 comments on commit c2145a2

Please sign in to comment.