Skip to content
Snippets Groups Projects
Commit 76199ec0 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 !34
parents b47b1790 290ae0fa
No related branches found
No related tags found
1 merge request!34Resolve "Use flutter linter and apply lints"
Pipeline #5114 passed
include: package:flutter_lints/flutter.yaml
...@@ -44,7 +44,7 @@ android { ...@@ -44,7 +44,7 @@ android {
defaultConfig { defaultConfig {
applicationId "org.benoitharrault.petitbac" applicationId "org.benoitharrault.petitbac"
minSdkVersion 16 minSdkVersion flutter.minSdkVersion
targetSdkVersion 30 targetSdkVersion 30
versionCode appVersionCode.toInteger() versionCode appVersionCode.toInteger()
versionName appVersionName versionName appVersionName
......
org.gradle.jvmargs=-Xmx1536M org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true android.useAndroidX=true
android.enableJetifier=true android.enableJetifier=true
app.versionName=1.2.24 app.versionName=1.2.25
app.versionCode=30 app.versionCode=31
Add automatic flutter linter. Apply code lints. Update dependencies.
Ajout d'un correcteur automatique de code. Application des corrections. Mise à jour des dépendances.
...@@ -8,10 +8,12 @@ import 'screens/home.dart'; ...@@ -8,10 +8,12 @@ import 'screens/home.dart';
void main() { void main() {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]) SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
.then((value) => runApp(MyApp())); .then((value) => runApp(const MyApp()));
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
const MyApp({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ChangeNotifierProvider( return ChangeNotifierProvider(
...@@ -24,9 +26,9 @@ class MyApp extends StatelessWidget { ...@@ -24,9 +26,9 @@ class MyApp extends StatelessWidget {
primaryColor: Colors.blue, primaryColor: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity, visualDensity: VisualDensity.adaptivePlatformDensity,
), ),
home: Home(), home: const Home(),
routes: { routes: {
Home.id: (context) => Home(), Home.id: (context) => const Home(),
}, },
); );
}, },
......
...@@ -11,8 +11,8 @@ class Data extends ChangeNotifier { ...@@ -11,8 +11,8 @@ class Data extends ChangeNotifier {
final int _recentCategoriesCount = 15; final int _recentCategoriesCount = 15;
final int _recentLettersCount = 10; final int _recentLettersCount = 10;
List _recentCategories = []; List<String> _recentCategories = [];
List _recentLetters = []; List<String> _recentLetters = [];
bool get searchingCategory => _searchingCategory; bool get searchingCategory => _searchingCategory;
void setSearchingCategory(bool value) { void setSearchingCategory(bool value) {
......
...@@ -8,6 +8,8 @@ import '../utils/random_pick_category.dart'; ...@@ -8,6 +8,8 @@ import '../utils/random_pick_category.dart';
import '../utils/random_pick_letter.dart'; import '../utils/random_pick_letter.dart';
class Home extends StatelessWidget { class Home extends StatelessWidget {
const Home({super.key});
static const String id = 'home'; static const String id = 'home';
static Timer? _timer; static Timer? _timer;
...@@ -22,13 +24,13 @@ class Home extends StatelessWidget { ...@@ -22,13 +24,13 @@ class Home extends StatelessWidget {
} }
Future<void> startTimer(Data myProvider) async { Future<void> startTimer(Data myProvider) async {
const oneSec = const Duration(seconds: 1); const oneSec = Duration(seconds: 1);
if (_timer != null) { if (_timer != null) {
dispose(); dispose();
} }
_countdownStart = 10; _countdownStart = 10;
myProvider.updateCountdown(_countdownStart); myProvider.updateCountdown(_countdownStart);
_timer = new Timer.periodic( _timer = Timer.periodic(
oneSec, oneSec,
(Timer timer) { (Timer timer) {
if (_countdownStart < 0) { if (_countdownStart < 0) {
...@@ -84,8 +86,11 @@ class Home extends StatelessWidget { ...@@ -84,8 +86,11 @@ class Home extends StatelessWidget {
} }
Container mainLetterButtonContainer( Container mainLetterButtonContainer(
Data myProvider, Color backgroundColor, double borderWidth) { Data myProvider,
Color borderColor = darken(backgroundColor); Color backgroundColor,
double borderWidth,
) {
final Color borderColor = darken(backgroundColor);
return Container( return Container(
margin: EdgeInsets.all(borderWidth), margin: EdgeInsets.all(borderWidth),
...@@ -102,7 +107,7 @@ class Home extends StatelessWidget { ...@@ -102,7 +107,7 @@ class Home extends StatelessWidget {
onPressed: () => pickLetter(myProvider), onPressed: () => pickLetter(myProvider),
child: Text( child: Text(
myProvider.letter == '' ? "🔀" : myProvider.letter, myProvider.letter == '' ? "🔀" : myProvider.letter,
style: TextStyle( style: const TextStyle(
fontSize: 40, fontSize: 40,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Colors.black, color: Colors.black,
...@@ -113,13 +118,13 @@ class Home extends StatelessWidget { ...@@ -113,13 +118,13 @@ class Home extends StatelessWidget {
} }
Container previousLetterBlockContainer(Data myProvider, int position, bool displayed) { Container previousLetterBlockContainer(Data myProvider, int position, bool displayed) {
double spacingWidth = 2; const double spacingWidth = 2;
double borderWidth = 3; const double borderWidth = 3;
Color backgroundColor = Colors.grey; Color backgroundColor = Colors.grey;
Color borderColor = darken(backgroundColor); Color borderColor = darken(backgroundColor);
Color fontColor = Colors.black; Color fontColor = Colors.black;
String letter = myProvider.recentlyPickedLetter(position); final String letter = myProvider.recentlyPickedLetter(position);
if (letter == '' || displayed == false) { if (letter == '' || displayed == false) {
backgroundColor = Colors.white; backgroundColor = Colors.white;
...@@ -128,8 +133,8 @@ class Home extends StatelessWidget { ...@@ -128,8 +133,8 @@ class Home extends StatelessWidget {
} }
return Container( return Container(
margin: EdgeInsets.all(spacingWidth), margin: const EdgeInsets.all(spacingWidth),
padding: EdgeInsets.all(spacingWidth), padding: const EdgeInsets.all(spacingWidth),
decoration: BoxDecoration( decoration: BoxDecoration(
color: backgroundColor, color: backgroundColor,
borderRadius: BorderRadius.circular(borderWidth), borderRadius: BorderRadius.circular(borderWidth),
...@@ -139,7 +144,7 @@ class Home extends StatelessWidget { ...@@ -139,7 +144,7 @@ class Home extends StatelessWidget {
), ),
), ),
child: Text( child: Text(
' ' + letter + ' ', ' $letter ',
style: TextStyle( style: TextStyle(
fontSize: 35.0 - (7 * position), fontSize: 35.0 - (7 * position),
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
...@@ -150,10 +155,13 @@ class Home extends StatelessWidget { ...@@ -150,10 +155,13 @@ class Home extends StatelessWidget {
} }
Container _buildPickedLetterContainer( Container _buildPickedLetterContainer(
Data myProvider, Color backgroundColor, double borderWidth) { Data myProvider,
int previousLettersCountToShow = 3; Color backgroundColor,
double borderWidth,
) {
const int previousLettersCountToShow = 3;
List<Widget> cells = []; final List<Widget> cells = [];
// Add previous letters blocks // Add previous letters blocks
for (var i = 0; i < previousLettersCountToShow; i++) { for (var i = 0; i < previousLettersCountToShow; i++) {
...@@ -178,10 +186,10 @@ class Home extends StatelessWidget { ...@@ -178,10 +186,10 @@ class Home extends StatelessWidget {
} }
return Container( return Container(
margin: EdgeInsets.all(2), margin: const EdgeInsets.all(2),
padding: EdgeInsets.all(2), padding: const EdgeInsets.all(2),
child: Table( child: Table(
defaultColumnWidth: IntrinsicColumnWidth(), defaultColumnWidth: const IntrinsicColumnWidth(),
children: [ children: [
TableRow(children: cells), TableRow(children: cells),
], ],
...@@ -189,12 +197,14 @@ class Home extends StatelessWidget { ...@@ -189,12 +197,14 @@ class Home extends StatelessWidget {
); );
} }
Container _buildPickedCategoryContainer( Widget _buildPickedCategoryContainer(
Data myProvider, Color backgroundColor, double borderWidth) { Data myProvider,
Color borderColor = darken(backgroundColor); Color backgroundColor,
double borderWidth,
) {
final Color borderColor = darken(backgroundColor);
return Container( return Column(
child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
...@@ -214,7 +224,7 @@ class Home extends StatelessWidget { ...@@ -214,7 +224,7 @@ class Home extends StatelessWidget {
child: Text( child: Text(
myProvider.category == '' ? "🔀" : myProvider.category, myProvider.category == '' ? "🔀" : myProvider.category,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: const TextStyle(
fontSize: 30, fontSize: 30,
fontWeight: FontWeight.w600, fontWeight: FontWeight.w600,
color: Colors.black, color: Colors.black,
...@@ -223,21 +233,22 @@ class Home extends StatelessWidget { ...@@ -223,21 +233,22 @@ class Home extends StatelessWidget {
), ),
), ),
], ],
),
); );
} }
Container _buildMiniGameContainer( Widget _buildMiniGameContainer(
Data myProvider, Color backgroundColor, double borderWidth) { Data myProvider,
Color borderColor = darken(backgroundColor); Color backgroundColor,
double borderWidth,
) {
final Color borderColor = darken(backgroundColor);
Color countDownColor = Colors.black; Color countDownColor = Colors.black;
if (myProvider.countdown == 0) { if (myProvider.countdown == 0) {
countDownColor = Colors.red; countDownColor = Colors.red;
} }
return Container( return Column(
child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
...@@ -266,28 +277,27 @@ class Home extends StatelessWidget { ...@@ -266,28 +277,27 @@ class Home extends StatelessWidget {
), ),
), ),
], ],
),
); );
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Data _myProvider = Provider.of<Data>(context); final Data myProvider = Provider.of<Data>(context);
double borderWidth = 8; const double borderWidth = 8;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text('Petit bac'), title: const Text('Petit bac'),
), ),
body: Center( body: Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
_buildPickedLetterContainer(_myProvider, Colors.orange, borderWidth), _buildPickedLetterContainer(myProvider, Colors.orange, borderWidth),
SizedBox(height: 5), const SizedBox(height: 5),
_buildMiniGameContainer(_myProvider, Colors.blue, borderWidth), _buildMiniGameContainer(myProvider, Colors.blue, borderWidth),
SizedBox(height: 5), const SizedBox(height: 5),
_buildPickedCategoryContainer(_myProvider, Colors.green, borderWidth), _buildPickedCategoryContainer(myProvider, Colors.green, borderWidth),
], ],
), ),
), ),
......
...@@ -13,31 +13,47 @@ packages: ...@@ -13,31 +13,47 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.17.2" version: "1.18.0"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
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"
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: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.9.1" version: "1.11.0"
nested: nested:
dependency: transitive dependency: transitive
description: description:
...@@ -50,10 +66,10 @@ packages: ...@@ -50,10 +66,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: provider name: provider
sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.0.5" version: "6.1.1"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
...@@ -67,14 +83,6 @@ packages: ...@@ -67,14 +83,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.4" version: "2.1.4"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
sdks: sdks:
dart: ">=3.1.0-185.0.dev <4.0.0" dart: ">=3.2.0-0 <4.0.0"
flutter: ">=1.16.0" flutter: ">=1.16.0"
name: petitbac name: petitbac
description: A PetitBac game application. description: A PetitBac game application.
publish_to: 'none' publish_to: 'none'
version: 1.0.0+1 version: 1.2.25+31
environment: environment:
sdk: '^3.0.0' sdk: '^3.0.0'
...@@ -11,6 +11,9 @@ dependencies: ...@@ -11,6 +11,9 @@ dependencies:
sdk: flutter sdk: flutter
provider: ^6.0.5 provider: ^6.0.5
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 to comment