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

Merge branch '33-use-flutter-linter-and-apply-lints' into 'master'

Resolve "Use flutter linter and apply lints"

Closes #33

See merge request !28
parents be56bc92 fc925be9
No related branches found
No related tags found
1 merge request!28Resolve "Use flutter linter and apply lints"
Pipeline #5121 canceled
Showing
with 172 additions and 165 deletions
include: package:flutter_lints/flutter.yaml
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.24
app.versionCode=24
app.versionName=0.0.25
app.versionCode=25
Add automatic flutter linter. Apply code lints. Update dependencies.
Ajout d'un correcteur automatique de code. Application des corrections. Mise à jour des dépendances.
......@@ -38,7 +38,7 @@ class DefaultGameSettings {
return DefaultGameSettings.allowedColorsCountValues;
}
print('Did not find any available value for game parameter \"' + parameterCode + '\".');
print('Did not find any available value for game parameter "$parameterCode".');
return [];
}
......
......@@ -60,7 +60,7 @@ class DefaultGlobalSettings {
return DefaultGlobalSettings.allowedGraphicThemeValues;
}
print('Did not find any available value for global parameter \"' + parameterCode + '\".');
print('Did not find any available value for global parameter "$parameterCode".');
return [];
}
}
......@@ -50,31 +50,31 @@ class GameCubit extends HydratedCubit<GameState> {
}
void increaseMovesCount() {
this.state.currentGame.increaseMovesCount();
state.currentGame.increaseMovesCount();
refresh();
}
void increaseScore(int increment) {
this.state.currentGame.increaseScore(increment);
state.currentGame.increaseScore(increment);
refresh();
}
void updateAvailableBlocksCount() {
this.state.currentGame.updateAvailableBlocksCount();
state.currentGame.updateAvailableBlocksCount();
refresh();
}
void updateGameIsFinished(bool gameIsFinished) {
this.state.currentGame.updateGameIsFinished(gameIsFinished);
state.currentGame.updateGameIsFinished(gameIsFinished);
refresh();
}
void shuffleColors(final int colorsTheme) {
this.state.currentGame.shuffleColorsAgain(colorsTheme);
state.currentGame.shuffleColorsAgain(colorsTheme);
}
moveCellsDown() {
final Game currentGame = this.state.currentGame;
final Game currentGame = state.currentGame;
final int boardSizeHorizontal = currentGame.gameSettings.boardSize;
final int boardSizeVertical = currentGame.gameSettings.boardSize;
......@@ -85,11 +85,11 @@ class GameCubit extends HydratedCubit<GameState> {
if (currentGame.getCellValue(CellLocation.go(row, col)) == null) {
// move cells down
for (int r = row; r > 0; r--) {
this.updateCellValue(CellLocation.go(r, col),
updateCellValue(CellLocation.go(r, col),
currentGame.getCellValue(CellLocation.go(r - 1, col)));
}
// fill top empty cell
this.updateCellValue(
updateCellValue(
CellLocation.go(0, col), currentGame.getFillValue(CellLocation.go(row, col)));
}
}
......@@ -100,9 +100,9 @@ class GameCubit extends HydratedCubit<GameState> {
// Sort cells from top to bottom
block.sort((cell1, cell2) => cell1.row.compareTo(cell2.row));
// Delete all cells
block.forEach((CellLocation blockItemToDelete) {
this.updateCellValue(blockItemToDelete, null);
});
for (CellLocation blockItemToDelete in block) {
updateCellValue(blockItemToDelete, null);
}
}
int getScoreFromBlock(int blockSize) {
......@@ -110,16 +110,16 @@ class GameCubit extends HydratedCubit<GameState> {
}
List<CellLocation> tapOnCell(CellLocation tappedCellLocation) {
final Game currentGame = this.state.currentGame;
final Game currentGame = state.currentGame;
final int? cellValue = currentGame.getCellValue(tappedCellLocation);
if (cellValue != null) {
List<CellLocation> blockCells = currentGame.getSiblingCells(tappedCellLocation, []);
if (blockCells.length >= DefaultGameSettings.blockMinimumCellsCount) {
this.deleteBlock(blockCells);
this.increaseMovesCount();
this.increaseScore(getScoreFromBlock(blockCells.length));
deleteBlock(blockCells);
increaseMovesCount();
increaseScore(getScoreFromBlock(blockCells.length));
return blockCells;
}
}
......@@ -128,13 +128,13 @@ class GameCubit extends HydratedCubit<GameState> {
}
void postAnimate() {
this.moveCellsDown();
this.updateAvailableBlocksCount();
moveCellsDown();
updateAvailableBlocksCount();
refresh();
if (!this.state.currentGame.hasAtLeastOneAvailableBlock()) {
if (!state.currentGame.hasAtLeastOneAvailableBlock()) {
print('no more block found. finish game.');
this.updateGameIsFinished(true);
updateGameIsFinished(true);
}
}
......@@ -150,7 +150,7 @@ class GameCubit extends HydratedCubit<GameState> {
newGame.dump();
updateState(newGame);
this.postAnimate();
postAnimate();
}
@override
......
......@@ -35,7 +35,7 @@ class GameSettingsCubit extends HydratedCubit<GameSettingsState> {
void setParameterValue(String code, int value) {
print('GameSettingsCubit.setParameterValue');
print('code: ' + code + ' / value: ' + value.toString());
print('code: $code / value: $value');
int boardSize = code == 'boardSize' ? value : getParameterValue('boardSize');
int colorsCount = code == 'colorsCount' ? value : getParameterValue('colorsCount');
......
......@@ -35,7 +35,7 @@ class GlobalSettingsCubit extends HydratedCubit<GlobalSettingsState> {
void setParameterValue(String code, int value) {
print('GlobalSettingsCubit.setParameterValue');
print('code: ' + code + ' / value: ' + value.toString());
print('code: $code / value: $value');
int colorsTheme = code == 'colorsTheme' ? value : getParameterValue('colorsTheme');
int graphicTheme = code == 'graphicTheme' ? value : getParameterValue('graphicTheme');
......
......@@ -8,10 +8,11 @@ class CellLocation {
});
factory CellLocation.go(int row, int col) {
return new CellLocation(col: col, row: row);
return CellLocation(col: col, row: row);
}
@override
String toString() {
return 'CellLocation(col: ' + col.toString() + ', row: ' + row.toString() + ')';
return 'CellLocation(col: $col, row: $row)';
}
}
......@@ -58,61 +58,61 @@ class Game {
static List<int> shuffleColors(final int colorsTheme) {
List<int> values =
new List<int>.generate(ColorTheme.getColorsCount(colorsTheme), (i) => i + 1);
List<int>.generate(ColorTheme.getColorsCount(colorsTheme), (i) => i + 1);
values.shuffle();
return values;
}
void shuffleColorsAgain(final int colorsTheme) {
this.shuffledColors = shuffleColors(colorsTheme);
shuffledColors = shuffleColors(colorsTheme);
}
GameCell getCell(CellLocation cellLocation) {
return this.board.cells[cellLocation.row][cellLocation.col];
return board.cells[cellLocation.row][cellLocation.col];
}
int? getCellValue(CellLocation cellLocation) {
return this.getCell(cellLocation).value;
return getCell(cellLocation).value;
}
int? getCellValueShuffled(CellLocation cellLocation) {
final int? value = this.getCell(cellLocation).value;
return value != null ? this.shuffledColors[value - 1] : null;
final int? value = getCell(cellLocation).value;
return value != null ? shuffledColors[value - 1] : null;
}
void updateCellValue(CellLocation locationToUpdate, int? value) {
this.board.cells[locationToUpdate.row][locationToUpdate.col].value = value;
board.cells[locationToUpdate.row][locationToUpdate.col].value = value;
}
void increaseMovesCount() {
this.movesCount += 1;
movesCount += 1;
}
void increaseScore(int? count) {
this.score += (count ?? 0);
score += (count ?? 0);
}
void updateAvailableBlocksCount() {
this.availableBlocksCount = this.getAvailableBlocks(this).length;
availableBlocksCount = getAvailableBlocks(this).length;
}
void updateGameIsRunning(bool gameIsRunning) {
this.isRunning = gameIsRunning;
isRunning = gameIsRunning;
}
void updateGameIsFinished(bool gameIsFinished) {
this.isFinished = gameIsFinished;
isFinished = gameIsFinished;
}
List<CellLocation> getSiblingCells(
final CellLocation referenceCellLocation,
List<CellLocation> siblingCells,
) {
final int boardSizeHorizontal = this.gameSettings.boardSize;
final int boardSizeVertical = this.gameSettings.boardSize;
final int boardSizeHorizontal = gameSettings.boardSize;
final int boardSizeVertical = gameSettings.boardSize;
final int? referenceValue = this.getCellValue(referenceCellLocation);
final int? referenceValue = getCellValue(referenceCellLocation);
for (int deltaRow = -1; deltaRow <= 1; deltaRow++) {
for (int deltaCol = -1; deltaCol <= 1; deltaCol++) {
......@@ -124,7 +124,7 @@ class Game {
(candidateCol >= 0 && candidateCol < boardSizeHorizontal)) {
final candidateLocation = CellLocation.go(candidateRow, candidateCol);
if (this.getCellValue(candidateLocation) == referenceValue) {
if (getCellValue(candidateLocation) == referenceValue) {
bool alreadyFound = false;
for (int index = 0; index < siblingCells.length; index++) {
if ((siblingCells[index].row == candidateRow) &&
......@@ -158,13 +158,13 @@ class Game {
// if current cell not already in a found block
bool alreadyFound = false;
blocks.forEach((List<CellLocation> foundBlock) {
foundBlock.forEach((CellLocation foundBlockCell) {
for (List<CellLocation> foundBlock in blocks) {
for (CellLocation foundBlockCell in foundBlock) {
if ((foundBlockCell.row == row) && (foundBlockCell.col == col)) {
alreadyFound = true;
}
});
});
}
}
if (!alreadyFound) {
final List<CellLocation> block = game.getSiblingCells(cellLocation, []);
if (block.length >= 3) {
......@@ -179,14 +179,14 @@ class Game {
}
bool hasAtLeastOneAvailableBlock() {
final int boardSizeHorizontal = this.gameSettings.boardSize;
final int boardSizeVertical = this.gameSettings.boardSize;
final int boardSizeHorizontal = gameSettings.boardSize;
final int boardSizeVertical = gameSettings.boardSize;
for (int row = 0; row < boardSizeVertical; row++) {
for (int col = 0; col < boardSizeHorizontal; col++) {
final CellLocation cellLocation = CellLocation.go(row, col);
if (this.getCellValue(cellLocation) != null) {
final List<CellLocation> block = this.getSiblingCells(cellLocation, []);
if (getCellValue(cellLocation) != null) {
final List<CellLocation> block = getSiblingCells(cellLocation, []);
if (block.length >= 3) {
// found one block => ok, not locked
return true;
......@@ -201,9 +201,9 @@ class Game {
bool isInBoard(CellLocation cell) {
if (cell.row > 0 &&
cell.row < this.gameSettings.boardSize &&
cell.row < gameSettings.boardSize &&
cell.col > 0 &&
cell.col < this.gameSettings.boardSize) {
cell.col < gameSettings.boardSize) {
return true;
}
return false;
......@@ -217,16 +217,16 @@ class Game {
final List<int> values = [];
// All eligible values (twice)
final int maxValue = this.gameSettings.colorsCount;
final int maxValue = gameSettings.colorsCount;
for (int i = 1; i <= maxValue; i++) {
values.add(i);
values.add(i);
}
// Add values of current col (twice)
for (int r = 0; r <= this.gameSettings.boardSize; r++) {
if (this.isInBoard(CellLocation.go(r, col))) {
final int? value = this.getCellValue(CellLocation.go(r, col));
for (int r = 0; r <= gameSettings.boardSize; r++) {
if (isInBoard(CellLocation.go(r, col))) {
final int? value = getCellValue(CellLocation.go(r, col));
if (value != null) {
values.add(value);
values.add(value);
......@@ -237,12 +237,12 @@ class Game {
// Add values of sibling cols (twice for top rows)
for (int deltaCol = -1; deltaCol <= 1; deltaCol++) {
final int c = col + deltaCol;
for (int r = 0; r < this.gameSettings.boardSize; r++) {
if (this.isInBoard(CellLocation.go(r, c))) {
final int? value = this.getCellValue(CellLocation.go(r, c));
for (int r = 0; r < gameSettings.boardSize; r++) {
if (isInBoard(CellLocation.go(r, c))) {
final int? value = getCellValue(CellLocation.go(r, c));
if (value != null) {
values.add(value);
if (row < this.gameSettings.boardSize / 3) {
if (row < gameSettings.boardSize / 3) {
values.add(value);
}
}
......@@ -255,8 +255,8 @@ class Game {
final int c = col + deltaCol;
for (int deltaRow = -2; deltaRow <= 2; deltaRow++) {
final int r = row + deltaRow;
if (this.isInBoard(CellLocation.go(r, c))) {
final int? value = this.getCellValue(CellLocation.go(r, c));
if (isInBoard(CellLocation.go(r, c))) {
final int? value = getCellValue(CellLocation.go(r, c));
if (value != null) {
values.add(value);
}
......@@ -272,36 +272,37 @@ class Game {
print('');
print('## Current game dump:');
print('');
this.gameSettings.dump();
this.globalSettings.dump();
gameSettings.dump();
globalSettings.dump();
print('');
this.board.dump();
board.dump();
print('');
print('Game: ');
print(' isRunning: ' + isRunning.toString());
print(' isFinished: ' + isFinished.toString());
print(' movesCount: ' + movesCount.toString());
print(' score: ' + score.toString());
print(' availableBlocksCount: ' + availableBlocksCount.toString());
print(' shuffledColors: ' + shuffledColors.toString());
print(' isRunning: $isRunning');
print(' isFinished: $isFinished');
print(' movesCount: $movesCount');
print(' score: $score');
print(' availableBlocksCount: $availableBlocksCount');
print(' shuffledColors: $shuffledColors');
print('');
}
@override
String toString() {
return 'Game(' + this.toJson().toString() + ')';
return 'Game(${toJson()})';
}
Map<String, dynamic>? toJson() {
return <String, dynamic>{
'board': this.board.toJson(),
'gameSettings': this.gameSettings.toJson(),
'globalSettings': this.globalSettings.toJson(),
'shuffledColors': this.shuffledColors,
'isRunning': this.isRunning,
'isFinished': this.isFinished,
'availableBlocksCount': this.availableBlocksCount,
'movesCount': this.movesCount,
'score': this.score,
'board': board.toJson(),
'gameSettings': gameSettings.toJson(),
'globalSettings': globalSettings.toJson(),
'shuffledColors': shuffledColors,
'isRunning': isRunning,
'isFinished': isFinished,
'availableBlocksCount': availableBlocksCount,
'movesCount': movesCount,
'score': score,
};
}
}
......@@ -19,7 +19,7 @@ class GameBoard {
final int boardSizeVertical = gameSettings.boardSize;
final int maxValue = gameSettings.colorsCount;
final rand = new Random();
final rand = Random();
List<List<GameCell>> cells = [];
for (int rowIndex = 0; rowIndex < boardSizeVertical; rowIndex++) {
......@@ -38,9 +38,9 @@ class GameBoard {
void dump() {
String horizontalRule = '----';
cells[0].forEach((element) {
for (int i = 0; i < cells[0].length; i++) {
horizontalRule += '-';
});
}
print('Board:');
print(horizontalRule);
......@@ -58,13 +58,14 @@ class GameBoard {
print(horizontalRule);
}
@override
String toString() {
return 'Board(' + this.toJson().toString() + ')';
return 'Board(${toJson()})';
}
Map<String, dynamic>? toJson() {
return <String, dynamic>{
'cells': this.cells.toString(),
'cells': cells.toString(),
};
}
}
......@@ -5,13 +5,14 @@ class GameCell {
this.value,
);
@override
String toString() {
return 'Cell(' + this.toJson().toString() + ')';
return 'Cell(${toJson()})';
}
Map<String, dynamic>? toJson() {
return <String, dynamic>{
'value': this.value,
'value': value,
};
}
}
......@@ -34,18 +34,19 @@ class GameSettings {
void dump() {
print('Settings: ');
print(' boardSize: ' + boardSize.toString());
print(' colorsCount: ' + colorsCount.toString());
print(' boardSize: $boardSize');
print(' colorsCount: $colorsCount');
}
@override
String toString() {
return 'GameSettings(' + this.toJson().toString() + ')';
return 'GameSettings(${toJson()})';
}
Map<String, dynamic>? toJson() {
return <String, dynamic>{
'boardSize': this.boardSize,
'colorsCount': this.colorsCount,
'boardSize': boardSize,
'colorsCount': colorsCount,
};
}
}
......@@ -34,18 +34,19 @@ class GlobalSettings {
void dump() {
print('Settings: ');
print(' colorsTheme: ' + colorsTheme.toString());
print(' graphicTheme: ' + graphicTheme.toString());
print(' colorsTheme: $colorsTheme');
print(' graphicTheme: $graphicTheme');
}
@override
String toString() {
return 'GlobalSettings(' + this.toJson().toString() + ')';
return 'GlobalSettings(${toJson()})';
}
Map<String, dynamic>? toJson() {
return <String, dynamic>{
'colorsTheme': this.colorsTheme,
'graphicTheme': this.graphicTheme,
'colorsTheme': colorsTheme,
'graphicTheme': graphicTheme,
};
}
}
......@@ -29,14 +29,14 @@ class GameBoardPainter extends CustomPainter {
switch (graphicTheme) {
case DefaultGlobalSettings.graphicThemeSolidBackground:
this.drawBoard(
drawBoard(
canvas: canvas,
canvasSize: canvasSize,
game: game,
);
break;
case DefaultGlobalSettings.graphicThemeGradientAndBorder:
this.drawBoard(
drawBoard(
canvas: canvas,
canvasSize: canvasSize,
game: game,
......@@ -46,7 +46,7 @@ class GameBoardPainter extends CustomPainter {
);
break;
case DefaultGlobalSettings.graphicThemeEmojis:
this.drawBoard(
drawBoard(
canvas: canvas,
canvasSize: canvasSize,
game: game,
......@@ -54,7 +54,7 @@ class GameBoardPainter extends CustomPainter {
);
break;
case DefaultGlobalSettings.graphicThemePatterns:
this.drawBoard(
drawBoard(
canvas: canvas,
canvasSize: canvasSize,
game: game,
......@@ -71,7 +71,7 @@ class GameBoardPainter extends CustomPainter {
boardPaintBorder.strokeWidth = boardBorderWidth;
boardPaintBorder.strokeCap = StrokeCap.round;
final Offset boardTopLeft = Offset(0, 0);
const Offset boardTopLeft = Offset(0, 0);
final Offset boardTopRight = Offset(canvasSize, 0);
final Offset boardBottomLeft = Offset(0, canvasSize);
final Offset boardBottomRight = Offset(canvasSize, canvasSize);
......@@ -111,10 +111,10 @@ class GameBoardPainter extends CustomPainter {
final CellLocation cellLocation = CellLocation.go(row, col);
final int? cellValue = game.getCellValueShuffled(cellLocation);
if (cellValue != null) {
final Animation<double>? translation = this.animations[row][col];
final Animation<double>? translation = animations[row][col];
final double y = yOrigin + (translation?.value ?? 0) * size;
this.drawCell(
drawCell(
canvas: canvas,
x: x,
y: y,
......
......@@ -36,10 +36,10 @@ class ParameterPainter extends CustomPainter {
// "enabled/disabled" border
final paint = Paint();
paint.style = PaintingStyle.stroke;
paint.color = this.isSelected ? borderColorEnabled : borderColorDisabled;
paint.color = isSelected ? borderColorEnabled : borderColorDisabled;
paint.strokeJoin = StrokeJoin.round;
paint.strokeWidth = 20 / 100 * canvasSize;
canvas.drawRect(Rect.fromPoints(Offset(0, 0), Offset(canvasSize, canvasSize)), paint);
canvas.drawRect(Rect.fromPoints(const Offset(0, 0), Offset(canvasSize, canvasSize)), paint);
// content
switch (code) {
......@@ -56,7 +56,7 @@ class ParameterPainter extends CustomPainter {
paintGraphicThemeParameterItem(value, canvas, canvasSize);
break;
default:
print('Unknown parameter: ' + code + '/' + value.toString());
print('Unknown parameter: $code/$value');
paintUnknownParameterItem(value, canvas, canvasSize);
}
}
......@@ -78,10 +78,10 @@ class ParameterPainter extends CustomPainter {
paint.color = Colors.grey;
paint.style = PaintingStyle.fill;
canvas.drawRect(Rect.fromPoints(Offset(0, 0), Offset(size, size)), paint);
canvas.drawRect(Rect.fromPoints(const Offset(0, 0), Offset(size, size)), paint);
final textSpan = TextSpan(
text: '?' + '\n' + value.toString(),
text: '?\n$value',
style: const TextStyle(
color: Colors.black,
fontSize: 18,
......@@ -128,7 +128,7 @@ class ParameterPainter extends CustomPainter {
gridWidth = 5;
break;
default:
print('Wrong value for boardSize parameter value: ' + value.toString());
print('Wrong value for boardSize parameter value: $value');
}
final paint = Paint();
......@@ -138,7 +138,7 @@ class ParameterPainter extends CustomPainter {
// Colored background
paint.color = backgroundColor;
paint.style = PaintingStyle.fill;
canvas.drawRect(Rect.fromPoints(Offset(0, 0), Offset(size, size)), paint);
canvas.drawRect(Rect.fromPoints(const Offset(0, 0), Offset(size, size)), paint);
// Mini grid
final borderColor = Colors.grey.shade800;
......@@ -186,7 +186,7 @@ class ParameterPainter extends CustomPainter {
backgroundColor = Colors.purple;
break;
default:
print('Wrong value for colorsCount parameter value: ' + value.toString());
print('Wrong value for colorsCount parameter value: $value');
}
final paint = Paint();
......@@ -196,7 +196,7 @@ class ParameterPainter extends CustomPainter {
// Colored background
paint.color = backgroundColor;
paint.style = PaintingStyle.fill;
canvas.drawRect(Rect.fromPoints(Offset(0, 0), Offset(size, size)), paint);
canvas.drawRect(Rect.fromPoints(const Offset(0, 0), Offset(size, size)), paint);
// Colors preview
const List<Offset> positions = [
......@@ -272,7 +272,7 @@ class ParameterPainter extends CustomPainter {
// Colored background
paint.color = backgroundColor;
paint.style = PaintingStyle.fill;
canvas.drawRect(Rect.fromPoints(Offset(0, 0), Offset(size, size)), paint);
canvas.drawRect(Rect.fromPoints(const Offset(0, 0), Offset(size, size)), paint);
// Mini grid
final borderColor = Colors.grey.shade800;
......@@ -312,7 +312,7 @@ class ParameterPainter extends CustomPainter {
// Colored background
paint.color = backgroundColor;
paint.style = PaintingStyle.fill;
canvas.drawRect(Rect.fromPoints(Offset(0, 0), Offset(size, size)), paint);
canvas.drawRect(Rect.fromPoints(const Offset(0, 0), Offset(size, size)), paint);
// cells preview
const List<Offset> positions = [
......@@ -347,7 +347,7 @@ class ParameterPainter extends CustomPainter {
contentStrings = DefaultGlobalSettings.graphicThemeContentPatternStrings;
break;
default:
print('Wrong value for colorsCount parameter value: ' + value.toString());
print('Wrong value for colorsCount parameter value: $value');
}
for (int itemValue = 0; itemValue < positions.length; itemValue++) {
......@@ -385,7 +385,7 @@ class ParameterPainter extends CustomPainter {
}
// centered text value
if (contentStrings.length != 0) {
if (contentStrings.isNotEmpty) {
final textSpan = TextSpan(
text: contentStrings[itemValue],
style: TextStyle(
......
......@@ -9,9 +9,9 @@ class SkeletonScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: GlobalAppBar(),
appBar: const GlobalAppBar(),
extendBodyBehindAppBar: false,
body: ScreenGame(),
body: const ScreenGame(),
backgroundColor: Theme.of(context).colorScheme.background,
);
}
......
......@@ -19,7 +19,7 @@ class _GameBoard extends State<GameBoard> with TickerProviderStateMixin {
List<List<Animation<double>?>> animations = [];
void resetAnimations(int boardSize) {
this.animations = List.generate(
animations = List.generate(
boardSize,
(i) => List.generate(
boardSize,
......@@ -72,21 +72,21 @@ class _GameBoard extends State<GameBoard> with TickerProviderStateMixin {
(i) => 0,
),
);
cellsToRemove.forEach((cellToRemove) {
for (CellLocation cellToRemove in cellsToRemove) {
for (int i = 0; i < cellToRemove.row; i++) {
stepsDownCounts[(cellToRemove.row - i) - 1][cellToRemove.col] += 1;
}
});
}
// Build animation for each cell to move
bool needAnimation = false;
cellsToRemove.forEach((cellToRemove) {
for (CellLocation cellToRemove in cellsToRemove) {
for (int i = 0; i < cellToRemove.row; i++) {
final int stepsCount = stepsDownCounts[(cellToRemove.row - i) - 1][cellToRemove.col];
this.animations[(cellToRemove.row - i) - 1][cellToRemove.col] = animation(stepsCount);
animations[(cellToRemove.row - i) - 1][cellToRemove.col] = animation(stepsCount);
needAnimation = true;
}
});
}
controller.forward().orCancel;
......@@ -104,20 +104,20 @@ class _GameBoard extends State<GameBoard> with TickerProviderStateMixin {
builder: (BuildContext context, GameState gameState) {
final Game currentGame = gameState.currentGame;
if (this.animations.length == 0) {
if (animations.isEmpty) {
resetAnimations(currentGame.gameSettings.boardSize);
}
return GestureDetector(
onTapUp: (details) {
bool animationInProgress = false;
animations.forEach((row) {
row.forEach((cell) {
for (List<Animation<double>?> row in animations) {
for (Animation<double>? cell in row) {
if (cell != null) {
animationInProgress = true;
}
});
});
}
}
if (!animationInProgress) {
final double xTap = details.localPosition.dx;
......@@ -134,7 +134,7 @@ class _GameBoard extends State<GameBoard> with TickerProviderStateMixin {
willChange: false,
painter: GameBoardPainter(
game: currentGame,
animations: this.animations,
animations: animations,
),
isComplex: true,
),
......
......@@ -15,12 +15,11 @@ class GameBottomButtonsWidget extends StatelessWidget {
image: AssetImage(decorationImageAssetName),
fit: BoxFit.fill,
),
onPressed: () => null,
onPressed: () {},
);
return Container(
child: Table(
defaultColumnWidth: IntrinsicColumnWidth(),
return Table(
defaultColumnWidth: const IntrinsicColumnWidth(),
children: [
TableRow(
children: [
......@@ -30,7 +29,7 @@ class GameBottomButtonsWidget extends StatelessWidget {
Column(
children: [
TextButton(
child: Image(
child: const Image(
image: AssetImage('assets/icons/button_back.png'),
fit: BoxFit.fill,
),
......@@ -47,7 +46,6 @@ class GameBottomButtonsWidget extends StatelessWidget {
],
),
],
),
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment