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

Use flutter linter and apply lints, update dependencies

parent 815d75e7
Branches
Tags
1 merge request!29Resolve "Use flutter linter and apply lints"
Pipeline #5036 passed
include: package:flutter_lints/flutter.yaml
......@@ -44,7 +44,7 @@ android {
defaultConfig {
applicationId "org.benoitharrault.momomotus"
minSdkVersion 16
minSdkVersion flutter.minSdkVersion
targetSdkVersion 30
versionCode appVersionCode.toInteger()
versionName appVersionName
......
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.0.25
app.versionCode=25
app.versionName=0.0.26
app.versionCode=26
Add automatic flutter linter. Apply code lints. Update dependencies.
Ajout d'un correcteur automatique de code. Application des correction. Mise à jour des dépendances.
......@@ -27,7 +27,7 @@ class Board {
}
Image imageWidget = Image(
image: AssetImage('assets/skins/' + skin + '_' + cellImage + '.png'),
image: AssetImage('assets/skins/${skin}_$cellImage.png'),
fit: BoxFit.fill,
);
......@@ -124,7 +124,7 @@ class Board {
if (myProvider.isGameFinished() && !myProvider.gameWon) {
gameBoard.add(Text(
myProvider.word,
style: TextStyle(
style: const TextStyle(
fontSize: 40,
fontWeight: FontWeight.bold,
),
......@@ -133,7 +133,7 @@ class Board {
return Container(
margin: EdgeInsets.symmetric(horizontal: horizontalMargins),
padding: EdgeInsets.all(2),
padding: const EdgeInsets.all(2),
child: Column(
children: gameBoard,
),
......
......@@ -6,19 +6,18 @@ import '../provider/data.dart';
import '../utils/game_utils.dart';
class Game {
static Container buildGameWidget(Data myProvider) {
static Widget buildGameWidget(Data myProvider) {
bool gameIsFinished = myProvider.isGameFinished();
return Container(
child: Column(
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Board.buildGameBoard(myProvider),
),
SizedBox(height: 2),
Container(
const SizedBox(height: 2),
SizedBox(
height: 150,
width: double.maxFinite,
child: gameIsFinished
......@@ -26,13 +25,12 @@ class Game {
: Keyboard.buildWidget(myProvider),
),
],
),
);
}
static TextButton buildQuitGameButton(Data myProvider) {
return TextButton(
child: Image(
child: const Image(
image: AssetImage('assets/icons/button_back.png'),
fit: BoxFit.fill,
),
......@@ -53,14 +51,14 @@ class Game {
image: AssetImage(decorationImageAssetName),
fit: BoxFit.fill,
),
onPressed: () => null,
onPressed: () {},
);
return Container(
margin: EdgeInsets.all(2),
padding: EdgeInsets.all(2),
margin: const EdgeInsets.all(2),
padding: const EdgeInsets.all(2),
child: Table(
defaultColumnWidth: IntrinsicColumnWidth(),
defaultColumnWidth: const IntrinsicColumnWidth(),
children: [
TableRow(
children: [
......
......@@ -22,13 +22,13 @@ class Keyboard {
Color keyColor = Colors.black;
if (key == ' ') {
return SizedBox();
return const SizedBox();
}
return Stack(
alignment: Alignment.center,
children: <Widget>[
Image(
const Image(
image: AssetImage('assets/icons/key.png'),
fit: BoxFit.fill,
),
......@@ -62,19 +62,19 @@ class Keyboard {
}
List<TableRow> tableRows = [];
keys.forEach((row) {
for (var row in keys) {
List<TableCell> tableCells = [];
row.forEach((key) {
for (var key in row) {
tableCells.add(TableCell(
child: buildKeyWidget(key),
));
});
}
tableRows.add(TableRow(children: tableCells));
});
}
return Container(
margin: EdgeInsets.symmetric(horizontal: 2),
padding: EdgeInsets.all(2),
margin: const EdgeInsets.symmetric(horizontal: 2),
padding: const EdgeInsets.all(2),
child: Table(
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
children: tableRows,
......
......@@ -6,26 +6,26 @@ import '../utils/game_utils.dart';
class Parameters {
static Container buildParametersSelector(Data myProvider) {
return Container(
padding: EdgeInsets.all(2),
margin: EdgeInsets.all(2),
padding: const EdgeInsets.all(2),
margin: const EdgeInsets.all(2),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Parameters.buildParameterSelector(myProvider, 'lang'),
SizedBox(height: 5),
const SizedBox(height: 5),
Parameters.buildParameterSelector(myProvider, 'length'),
SizedBox(height: 5),
const SizedBox(height: 5),
Parameters.buildParameterSelector(myProvider, 'skin'),
SizedBox(height: 5),
const SizedBox(height: 5),
Parameters.buildStartGameButton(myProvider),
],
),
);
}
static Container buildStartGameButton(Data myProvider) {
Column decorationImage = Column(
static Widget buildStartGameButton(Data myProvider) {
Column decorationImage = const Column(
children: [
Image(
image: AssetImage('assets/icons/game_win.png'),
......@@ -35,10 +35,10 @@ class Parameters {
);
return Container(
margin: EdgeInsets.all(2),
padding: EdgeInsets.all(2),
margin: const EdgeInsets.all(2),
padding: const EdgeInsets.all(2),
child: Table(
defaultColumnWidth: IntrinsicColumnWidth(),
defaultColumnWidth: const IntrinsicColumnWidth(),
children: [
TableRow(
children: [
......@@ -46,12 +46,10 @@ class Parameters {
Column(
children: [
TextButton(
child: Container(
child: Image(
child: const Image(
image: AssetImage('assets/icons/button_start.png'),
fit: BoxFit.fill,
),
),
onPressed: () => GameUtils.startGame(myProvider),
),
],
......@@ -68,11 +66,11 @@ class Parameters {
List availableValues = myProvider.getParameterAvailableValues(parameterCode);
if (availableValues.length == 1) {
return SizedBox(height: 1);
return const SizedBox(height: 1);
}
return Table(
defaultColumnWidth: IntrinsicColumnWidth(),
defaultColumnWidth: const IntrinsicColumnWidth(),
children: [
TableRow(
children: [
......@@ -93,11 +91,11 @@ class Parameters {
String currentValue = myProvider.getParameterValue(parameterCode).toString();
bool isActive = (parameterValue == currentValue);
String imageAsset = 'assets/icons/' + parameterCode + '_' + parameterValue + '.png';
String imageAsset = 'assets/icons/${parameterCode}_$parameterValue.png';
return TextButton(
child: Container(
padding: EdgeInsets.all(2),
padding: const EdgeInsets.all(2),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
......
......@@ -9,10 +9,12 @@ import 'screens/home.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
.then((value) => runApp(MyApp()));
.then((value) => runApp(const MyApp()));
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
......@@ -25,9 +27,9 @@ class MyApp extends StatelessWidget {
primaryColor: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Home(),
home: const Home(),
routes: {
Home.id: (context) => Home(),
Home.id: (context) => const Home(),
},
),
);
......
......@@ -3,10 +3,10 @@ import 'package:shared_preferences/shared_preferences.dart';
class Data extends ChangeNotifier {
// Configuration available values
List _availableLangValues = ['fr'];
List _availableWordLengthValues = ['4', '5', '6', '7', '8'];
List _availableLevelValues = ['easy', 'normal'];
List _availableSkinValues = ['default'];
final List _availableLangValues = ['fr'];
final List _availableWordLengthValues = ['4', '5', '6', '7', '8'];
final List _availableLevelValues = ['easy', 'normal'];
final List _availableSkinValues = ['default'];
List get availableLangValues => _availableLangValues;
List get availableWordLengthValues => _availableWordLengthValues;
......@@ -15,13 +15,13 @@ class Data extends ChangeNotifier {
// Application default configuration
String _lang = '';
String _langDefault = 'fr';
final String _langDefault = 'fr';
String _length = '';
String _lengthDefault = '5';
final String _lengthDefault = '5';
String _level = '';
String _levelDefault = 'normal';
final String _levelDefault = 'normal';
String _skin = '';
String _skinDefault = 'default';
final String _skinDefault = 'default';
// Game data
bool _gameIsRunning = false;
......@@ -32,7 +32,7 @@ class Data extends ChangeNotifier {
List<String> _guesses = [];
String _currentGuess = '';
String _foundLetters = '';
int _maxGuessesCount = 7;
final int _maxGuessesCount = 7;
String get lang => _lang;
void updateLang(String lang) {
......@@ -69,7 +69,7 @@ class Data extends ChangeNotifier {
}
void currentGuessRemoveLetter() {
if (_currentGuess.length > 0) {
if (_currentGuess.isNotEmpty) {
_currentGuess = _currentGuess.substring(0, _currentGuess.length - 1);
notifyListeners();
}
......
......@@ -10,11 +10,13 @@ import '../utils/game_utils.dart';
class Home extends StatefulWidget {
static const String id = 'home';
const Home({super.key});
@override
_HomeState createState() => _HomeState();
HomeState createState() => HomeState();
}
class _HomeState extends State<Home> {
class HomeState extends State<Home> {
@override
void initState() {
super.initState();
......@@ -32,12 +34,10 @@ class _HomeState extends State<Home> {
if (myProvider.gameIsRunning) {
menuActions = [
TextButton(
child: Container(
child: Image(
child: const Image(
image: AssetImage('assets/icons/button_back.png'),
fit: BoxFit.fill,
),
),
onPressed: () => toast('Long press to quit game...'),
onLongPress: () => GameUtils.quitGame(myProvider),
),
......
......@@ -7,13 +7,7 @@ class GameUtils {
}
static Future<void> startGame(Data myProvider) async {
print('Starting game (' +
myProvider.lang +
' / ' +
myProvider.length +
' / ' +
myProvider.level +
' )');
print('Starting game (${myProvider.lang} / ${myProvider.length} / ${myProvider.level} )');
myProvider.resetGame();
......@@ -42,7 +36,7 @@ class GameUtils {
}
} while (myProvider.word != word && attempts < 10);
print('Picked word: ' + word);
print('Picked word: $word');
}
static void addLetter(Data myProvider, String letter) {
......@@ -95,10 +89,10 @@ class GameUtils {
static void submitWord(Data myProvider) {
if (GameUtils.checkCurrentlyGuessedWordExists(myProvider)) {
print('Ok word allowed: "' + myProvider.currentGuess + '".');
print('Ok word allowed: "${myProvider.currentGuess}".');
myProvider.currentGuessSubmitWord();
} else {
print('Unknown word: "' + myProvider.currentGuess + '".');
print('Unknown word: "${myProvider.currentGuess}".');
myProvider.currentGuessSubmitWrongWord();
}
}
......
......@@ -30,13 +30,13 @@ class RandomPickWord {
dictionary.clear();
wordList.clear();
String wordBaseFilename = 'words-' + length.toString() + '-' + lang;
String wordBaseFilename = 'words-$length-$lang';
// Get full dictionary (eligible words)
print('Reload dictionary (' + lang + ' / ' + length.toString() + ')');
print('Reload dictionary ($lang / $length)');
try {
String wordsFile = wordBaseFilename + '-' + 'dictionary';
var data = await rootBundle.loadString('assets/files/' + wordsFile + '.txt');
String wordsFile = '$wordBaseFilename-dictionary';
var data = await rootBundle.loadString('assets/files/$wordsFile.txt');
LineSplitter.split(data).forEach((line) {
if (line.length == length) {
dictionary.add(line.toUpperCase());
......@@ -47,10 +47,10 @@ class RandomPickWord {
}
// Get guessable words list (will pick random word from)
print('Reload words list (' + lang + ' / ' + length.toString() + ' / ' + level + ')');
print('Reload words list ($lang / $length / $level)');
try {
String wordsFile = wordBaseFilename + '-' + level;
var data = await rootBundle.loadString('assets/files/' + wordsFile + '.txt');
String wordsFile = '$wordBaseFilename-$level';
var data = await rootBundle.loadString('assets/files/$wordsFile.txt');
LineSplitter.split(data).forEach((line) {
if (line.length == length) {
wordList.add(line.toUpperCase());
......@@ -61,8 +61,8 @@ class RandomPickWord {
}
}
print('Words in dictionary: ' + dictionary.length.toString());
print('Words in words list: ' + wordList.length.toString());
print('Words in dictionary: ${dictionary.length}');
print('Words in words list: ${wordList.length}');
_word = '';
await wordFromLocalFile();
......@@ -70,12 +70,12 @@ class RandomPickWord {
Future<void> wordFromLocalFile() async {
// Check we have enough words
if (wordList.length < 1) {
if (wordList.isEmpty) {
print('Not enough words in list.');
_word = '';
} else {
final _random = new Random();
_word = wordList.elementAt(_random.nextInt(wordList.length));
final random = Random();
_word = wordList.elementAt(random.nextInt(wordList.length));
}
}
......
......@@ -21,52 +21,68 @@ packages:
dependency: transitive
description:
name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.17.2"
version: "1.18.0"
ffi:
dependency: transitive
description:
name: ffi
sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.1.2"
file:
dependency: transitive
description:
name: file
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "6.1.4"
version: "7.0.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
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:
dependency: transitive
description: flutter
source: sdk
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:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.11.0"
nested:
dependency: transitive
description:
......@@ -87,10 +103,10 @@ packages:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
path_provider_linux:
dependency: transitive
description:
......@@ -103,10 +119,10 @@ packages:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "94b1e0dd80970c1ce43d5d4e050a9918fce4f4a775e6142424c30a29a363265c"
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
path_provider_windows:
dependency: transitive
description:
......@@ -119,34 +135,34 @@ packages:
dependency: transitive
description:
name: platform
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
version: "3.1.4"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.6"
version: "2.1.8"
provider:
dependency: "direct main"
description:
name: provider
sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f
sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096"
url: "https://pub.dev"
source: hosted
version: "6.0.5"
version: "6.1.1"
shared_preferences:
dependency: "direct main"
description:
name: shared_preferences
sha256: b7f41bad7e521d205998772545de63ff4e6c97714775902c199353f8bf1511ac
sha256: "81429e4481e1ccfb51ede496e916348668fd0921627779233bd24cc3ff6abd02"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
version: "2.2.2"
shared_preferences_android:
dependency: transitive
description:
......@@ -159,42 +175,42 @@ packages:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: "7bf53a9f2d007329ee6f3df7268fd498f8373602f943c975598bbb34649b62a7"
sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c"
url: "https://pub.dev"
source: hosted
version: "2.3.4"
version: "2.3.5"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
sha256: c2eb5bf57a2fe9ad6988121609e47d3e07bb3bdca5b6f8444e4cf302428a128a
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.2"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
sha256: d4ec5fc9ebb2f2e056c617112aa75dcf92fc2e4faaf2ae999caa297473f75d8a
sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.2"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
sha256: d762709c2bbe80626ecc819143013cc820fa49ca5e363620ee20a8b15a3e3daf
sha256: "7b15ffb9387ea3e237bb7a66b8a23d2147663d391cafc5c8f37b2e7b4bde5d21"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
version: "2.2.2"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
sha256: f763a101313bd3be87edffe0560037500967de9c394a714cd598d945517f694f
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.2"
sky_engine:
dependency: transitive
description: flutter
......@@ -212,26 +228,26 @@ packages:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05"
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
version: "0.4.2"
win32:
dependency: transitive
description:
name: win32
sha256: "350a11abd2d1d97e0cc7a28a81b781c08002aa2864d9e3f192ca0ffa18b06ed3"
sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8"
url: "https://pub.dev"
source: hosted
version: "5.0.9"
version: "5.2.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: "589ada45ba9e39405c198fe34eb0f607cddb2108527e658136120892beac46d2"
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
url: "https://pub.dev"
source: hosted
version: "1.0.3"
version: "1.0.4"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=3.7.0"
dart: ">=3.3.0-279.1.beta <4.0.0"
flutter: ">=3.16.0"
name: momomotus
description: A motus-like game application.
publish_to: 'none'
version: 1.0.0+1
version: 0.0.26+26
environment:
sdk: '^3.0.0'
......@@ -13,6 +13,9 @@ dependencies:
shared_preferences: ^2.2.1
overlay_support: ^2.1.0
dev_dependencies:
flutter_lints: ^3.0.1
flutter:
uses-material-design: true
assets:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment