Skip to content
Snippets Groups Projects
Commit 5e60eed8 authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Use flutter linter, apply lints, update dependencies

parent 01479dfd
Branches
Tags
1 merge request!15Resolve "Use flutter linter and apply lints"
Pipeline #5043 passed
This commit is part of merge request !15. Comments created here will be created in the context of that merge request.
include: package:flutter_lints/flutter.yaml
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=0.0.13 app.versionName=0.0.14
app.versionCode=13 app.versionCode=14
Add automatic flutter linter. Apply code lints. Update dependencies.
Ajout d'un correcteur automatique de code. Application des correction. Mise à jour des dépendances.
...@@ -24,8 +24,8 @@ class Position { ...@@ -24,8 +24,8 @@ class Position {
/// An immutable representation of a reversi game's board. /// An immutable representation of a reversi game's board.
class GameBoard { class GameBoard {
static final int height = 8; static const int height = 8;
static final int width = 8; static const int width = 8;
final List<List<PieceType>> rows; final List<List<PieceType>> rows;
// Because calculating out all the available moves for a player can be // Because calculating out all the available moves for a player can be
......
...@@ -21,12 +21,14 @@ void main() { ...@@ -21,12 +21,14 @@ void main() {
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
runApp(FlutterFlipApp()); runApp(const FlutterFlipApp());
} }
/// The App class. Unlike many Flutter apps, this one does not use Material /// The App class. Unlike many Flutter apps, this one does not use Material
/// widgets, so there's no [MaterialApp] or [Theme] objects. /// widgets, so there's no [MaterialApp] or [Theme] objects.
class FlutterFlipApp extends StatelessWidget { class FlutterFlipApp extends StatelessWidget {
const FlutterFlipApp({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
...@@ -35,7 +37,7 @@ class FlutterFlipApp extends StatelessWidget { ...@@ -35,7 +37,7 @@ class FlutterFlipApp extends StatelessWidget {
primaryColor: Colors.blue, primaryColor: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity, visualDensity: VisualDensity.adaptivePlatformDensity,
), ),
home: GameScreen(), home: const GameScreen(),
); );
} }
} }
...@@ -43,6 +45,8 @@ class FlutterFlipApp extends StatelessWidget { ...@@ -43,6 +45,8 @@ class FlutterFlipApp extends StatelessWidget {
/// The [GameScreen] Widget represents the entire game /// The [GameScreen] Widget represents the entire game
/// display, from scores to board state and everything in between. /// display, from scores to board state and everything in between.
class GameScreen extends StatefulWidget { class GameScreen extends StatefulWidget {
const GameScreen({super.key});
@override @override
State createState() => _GameScreenState(); State createState() => _GameScreenState();
} }
...@@ -90,7 +94,7 @@ class _GameScreenState extends State<GameScreen> { ...@@ -90,7 +94,7 @@ class _GameScreenState extends State<GameScreen> {
while (newModel.player == PieceType.white) { while (newModel.player == PieceType.white) {
final finder = MoveFinder(newModel.board); final finder = MoveFinder(newModel.board);
final move = await Future.delayed(Duration(milliseconds: 2000), () { final move = await Future.delayed(const Duration(milliseconds: 2000), () {
return finder.findNextMove(newModel.player, 5); return finder.findNextMove(newModel.player, 5);
}); });
if (move != null) { if (move != null) {
...@@ -136,7 +140,7 @@ class _GameScreenState extends State<GameScreen> { ...@@ -136,7 +140,7 @@ class _GameScreenState extends State<GameScreen> {
Widget _buildScoreBox(PieceType player, GameModel model) { Widget _buildScoreBox(PieceType player, GameModel model) {
var assetImageCode = player == PieceType.black ? 'black' : 'white'; var assetImageCode = player == PieceType.black ? 'black' : 'white';
String assetImageName = String assetImageName =
'assets/skins/' + model.skin + '_tile_' + assetImageCode + '.png'; 'assets/skins/${model.skin}_tile_$assetImageCode.png';
var scoreText = var scoreText =
player == PieceType.black ? '${model.blackScore}' : '${model.whiteScore}'; player == PieceType.black ? '${model.blackScore}' : '${model.whiteScore}';
...@@ -159,13 +163,13 @@ class _GameScreenState extends State<GameScreen> { ...@@ -159,13 +163,13 @@ class _GameScreenState extends State<GameScreen> {
fit: BoxFit.fill, fit: BoxFit.fill,
), ),
), ),
SizedBox( const SizedBox(
width: 10.0, width: 10.0,
), ),
Text( Text(
scoreText, scoreText,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: const TextStyle(
fontSize: 35.0, fontSize: 35.0,
color: Color(0xff000000), color: Color(0xff000000),
), ),
...@@ -179,11 +183,11 @@ class _GameScreenState extends State<GameScreen> { ...@@ -179,11 +183,11 @@ class _GameScreenState extends State<GameScreen> {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Spacer(flex: 1), const Spacer(flex: 1),
_buildScoreBox(PieceType.black, model), _buildScoreBox(PieceType.black, model),
Spacer(flex: 4), const Spacer(flex: 4),
_buildScoreBox(PieceType.white, model), _buildScoreBox(PieceType.white, model),
Spacer(flex: 1), const Spacer(flex: 1),
], ],
); );
} }
...@@ -197,11 +201,7 @@ class _GameScreenState extends State<GameScreen> { ...@@ -197,11 +201,7 @@ class _GameScreenState extends State<GameScreen> {
for (var x = 0; x < GameBoard.width; x++) { for (var x = 0; x < GameBoard.width; x++) {
PieceType pieceType = model.board.getPieceAtLocation(x, y); PieceType pieceType = model.board.getPieceAtLocation(x, y);
String? assetImageCode = Styling.assetImageCodes[pieceType]; String? assetImageCode = Styling.assetImageCodes[pieceType];
String assetImageName = 'assets/skins/' + String assetImageName = 'assets/skins/${model.skin}_tile_${assetImageCode ?? 'empty'}.png';
model.skin +
'_tile_' +
(assetImageCode != null ? assetImageCode : 'empty') +
'.png';
Column cell = Column( Column cell = Column(
children: [ children: [
...@@ -212,7 +212,7 @@ class _GameScreenState extends State<GameScreen> { ...@@ -212,7 +212,7 @@ class _GameScreenState extends State<GameScreen> {
child: AnimatedSwitcher( child: AnimatedSwitcher(
duration: const Duration(milliseconds: 500), duration: const Duration(milliseconds: 500),
transitionBuilder: (Widget child, Animation<double> animation) { transitionBuilder: (Widget child, Animation<double> animation) {
return ScaleTransition(child: child, scale: animation); return ScaleTransition(scale: animation, child: child);
}, },
child: Image( child: Image(
image: AssetImage(assetImageName), image: AssetImage(assetImageName),
...@@ -237,7 +237,7 @@ class _GameScreenState extends State<GameScreen> { ...@@ -237,7 +237,7 @@ class _GameScreenState extends State<GameScreen> {
rows.add(TableRow(children: cells)); rows.add(TableRow(children: cells));
} }
return Table(defaultColumnWidth: IntrinsicColumnWidth(), children: rows); return Table(defaultColumnWidth: const IntrinsicColumnWidth(), children: rows);
} }
Widget _buildThinkingIndicator(GameModel model) { Widget _buildThinkingIndicator(GameModel model) {
...@@ -254,7 +254,7 @@ class _GameScreenState extends State<GameScreen> { ...@@ -254,7 +254,7 @@ class _GameScreenState extends State<GameScreen> {
vertical: 5.0, vertical: 5.0,
horizontal: 15.0, horizontal: 15.0,
), ),
child: Image( child: const Image(
image: AssetImage('assets/icons/button_restart.png'), image: AssetImage('assets/icons/button_restart.png'),
fit: BoxFit.fill, fit: BoxFit.fill,
), ),
...@@ -270,9 +270,9 @@ class _GameScreenState extends State<GameScreen> { ...@@ -270,9 +270,9 @@ class _GameScreenState extends State<GameScreen> {
); );
return Container( return Container(
margin: EdgeInsets.all(2), margin: const EdgeInsets.all(2),
padding: EdgeInsets.all(2), padding: const EdgeInsets.all(2),
child: Table(defaultColumnWidth: IntrinsicColumnWidth(), children: [ child: Table(defaultColumnWidth: const IntrinsicColumnWidth(), children: [
TableRow( TableRow(
children: [ children: [
Column(children: [decorationImage]), Column(children: [decorationImage]),
...@@ -308,8 +308,8 @@ class _GameScreenState extends State<GameScreen> { ...@@ -308,8 +308,8 @@ class _GameScreenState extends State<GameScreen> {
width: 4, width: 4,
), ),
), ),
margin: EdgeInsets.all(8), margin: const EdgeInsets.all(8),
child: Image( child: const Image(
image: AssetImage('assets/icons/button_restart.png'), image: AssetImage('assets/icons/button_restart.png'),
fit: BoxFit.fill, fit: BoxFit.fill,
), ),
...@@ -319,7 +319,7 @@ class _GameScreenState extends State<GameScreen> { ...@@ -319,7 +319,7 @@ class _GameScreenState extends State<GameScreen> {
], ],
), ),
body: Container( body: Container(
padding: EdgeInsets.only( padding: const EdgeInsets.only(
top: 5.0, top: 5.0,
left: 5.0, left: 5.0,
right: 5.0, right: 5.0,
...@@ -329,9 +329,9 @@ class _GameScreenState extends State<GameScreen> { ...@@ -329,9 +329,9 @@ class _GameScreenState extends State<GameScreen> {
child: Column( child: Column(
children: [ children: [
_buildScoreBoxes(model), _buildScoreBoxes(model),
SizedBox(height: 5), const SizedBox(height: 5),
_buildGameBoardDisplay(context, model), _buildGameBoardDisplay(context, model),
SizedBox(height: 5), const SizedBox(height: 5),
_buildThinkingIndicator(model), _buildThinkingIndicator(model),
if (model.gameIsOver) _buildEndGameWidget(model), if (model.gameIsOver) _buildEndGameWidget(model),
], ],
......
...@@ -54,7 +54,7 @@ abstract class Styling { ...@@ -54,7 +54,7 @@ abstract class Styling {
); );
static const activePlayerIndicator = BoxDecoration( static const activePlayerIndicator = BoxDecoration(
borderRadius: const BorderRadius.all(const Radius.circular(10.0)), borderRadius: BorderRadius.all(Radius.circular(10.0)),
border: Border( border: Border(
bottom: activePlayerIndicatorBorder, bottom: activePlayerIndicatorBorder,
top: activePlayerIndicatorBorder, top: activePlayerIndicatorBorder,
...@@ -64,7 +64,7 @@ abstract class Styling { ...@@ -64,7 +64,7 @@ abstract class Styling {
); );
static const inactivePlayerIndicator = BoxDecoration( static const inactivePlayerIndicator = BoxDecoration(
borderRadius: const BorderRadius.all(const Radius.circular(10.0)), borderRadius: BorderRadius.all(Radius.circular(10.0)),
border: Border( border: Border(
bottom: inactivePlayerIndicatorBorder, bottom: inactivePlayerIndicatorBorder,
top: inactivePlayerIndicatorBorder, top: inactivePlayerIndicatorBorder,
......
...@@ -12,14 +12,13 @@ class ThinkingIndicator extends ImplicitlyAnimatedWidget { ...@@ -12,14 +12,13 @@ class ThinkingIndicator extends ImplicitlyAnimatedWidget {
final double height; final double height;
final bool visible; final bool visible;
ThinkingIndicator({ const ThinkingIndicator({
this.color = const Color(0xffffffff), this.color = const Color(0xffffffff),
this.height = 10.0, this.height = 10.0,
this.visible = true, this.visible = true,
Key? key, super.key,
}) : super( }) : super(
duration: Styling.thinkingFadeDuration, duration: Styling.thinkingFadeDuration,
key: key,
); );
@override @override
...@@ -29,10 +28,6 @@ class ThinkingIndicator extends ImplicitlyAnimatedWidget { ...@@ -29,10 +28,6 @@ class ThinkingIndicator extends ImplicitlyAnimatedWidget {
class _ThinkingIndicatorState extends AnimatedWidgetBaseState<ThinkingIndicator> { class _ThinkingIndicatorState extends AnimatedWidgetBaseState<ThinkingIndicator> {
Tween<double>? _opacityTween; Tween<double>? _opacityTween;
@override
void dispose() {
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -69,8 +64,7 @@ class _AnimatedCircles extends StatefulWidget { ...@@ -69,8 +64,7 @@ class _AnimatedCircles extends StatefulWidget {
const _AnimatedCircles({ const _AnimatedCircles({
required this.color, required this.color,
required this.height, required this.height,
Key? key, });
}) : super(key: key);
@override @override
_AnimatedCirclesState createState() => _AnimatedCirclesState(); _AnimatedCirclesState createState() => _AnimatedCirclesState();
...@@ -112,7 +106,7 @@ class _AnimatedCirclesState extends State<_AnimatedCircles> ...@@ -112,7 +106,7 @@ class _AnimatedCirclesState extends State<_AnimatedCircles>
color: widget.color, color: widget.color,
width: 2.0, width: 2.0,
), ),
borderRadius: BorderRadius.all(const Radius.circular(5.0)), borderRadius: const BorderRadius.all(Radius.circular(5.0)),
), ),
); );
} }
......
...@@ -29,10 +29,10 @@ packages: ...@@ -29,10 +29,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: ffi name: ffi
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.0" version: "2.1.2"
file: file:
dependency: transitive dependency: transitive
description: description:
...@@ -46,27 +46,43 @@ packages: ...@@ -46,27 +46,43 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
url: "https://pub.dev"
source: hosted
version: "3.0.1"
flutter_web_plugins: flutter_web_plugins:
dependency: transitive dependency: transitive
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
lints:
dependency: transitive
description:
name: lints
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "3.0.0"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.0" version: "0.8.0"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.10.0" version: "1.11.0"
nested: nested:
dependency: transitive dependency: transitive
description: description:
...@@ -95,10 +111,10 @@ packages: ...@@ -95,10 +111,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: path_provider_platform_interface name: path_provider_platform_interface
sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c" sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.2"
path_provider_windows: path_provider_windows:
dependency: transitive dependency: transitive
description: description:
...@@ -111,18 +127,18 @@ packages: ...@@ -111,18 +127,18 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: platform name: platform
sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59" sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.1.3" version: "3.1.4"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: plugin_platform_interface name: plugin_platform_interface
sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.7" version: "2.1.8"
provider: provider:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -151,10 +167,10 @@ packages: ...@@ -151,10 +167,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_foundation name: shared_preferences_foundation
sha256: "7bf53a9f2d007329ee6f3df7268fd498f8373602f943c975598bbb34649b62a7" sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.4" version: "2.3.5"
shared_preferences_linux: shared_preferences_linux:
dependency: transitive dependency: transitive
description: description:
...@@ -167,10 +183,10 @@ packages: ...@@ -167,10 +183,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: shared_preferences_platform_interface name: shared_preferences_platform_interface
sha256: d4ec5fc9ebb2f2e056c617112aa75dcf92fc2e4faaf2ae999caa297473f75d8a sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.3.1" version: "2.3.2"
shared_preferences_web: shared_preferences_web:
dependency: transitive dependency: transitive
description: description:
...@@ -204,26 +220,26 @@ packages: ...@@ -204,26 +220,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: web name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.3.0" version: "0.4.2"
win32: win32:
dependency: transitive dependency: transitive
description: description:
name: win32 name: win32
sha256: b0f37db61ba2f2e9b7a78a1caece0052564d1bc70668156cf3a29d676fe4e574 sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.1.1" version: "5.2.0"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
name: xdg_directories name: xdg_directories
sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2" sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.3" version: "1.0.4"
sdks: sdks:
dart: ">=3.2.0 <4.0.0" dart: ">=3.3.0-279.1.beta <4.0.0"
flutter: ">=3.16.0" flutter: ">=3.16.0"
name: simpler_reversi name: simpler_reversi
description: A reversi game application. description: A reversi game application.
publish_to: 'none' publish_to: 'none'
version: 0.0.13+13 version: 0.0.14+14
environment: environment:
sdk: '^3.0.0' sdk: '^3.0.0'
...@@ -13,6 +13,9 @@ dependencies: ...@@ -13,6 +13,9 @@ dependencies:
shared_preferences: ^2.2.1 shared_preferences: ^2.2.1
async: ^2.11.0 async: ^2.11.0
dev_dependencies:
flutter_lints: ^3.0.1
flutter: flutter:
uses-material-design: true uses-material-design: true
assets: assets:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment