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

Use flutter linter, apply lints, update dependencies

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