Skip to content

Commit 3018af6

Browse files
authored
Merge pull request #474 from M-Ahal/refactor/lint-cleanup
Cleanup of some common lints
2 parents f2ed9a5 + c35d66d commit 3018af6

45 files changed

Lines changed: 142 additions & 130 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

example/lib/cupertino_date_picker.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:flutter/cupertino.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
44

5-
showDatePickerWithCustomCupertinoStateful(BuildContext context) async {
5+
Future<void> showDatePickerWithCustomCupertinoStateful(BuildContext context) async {
66
final now = DateUtils.dateOnly(DateTime.now());
77
final firstDate = now.subtract(const Duration(days: 100));
88
final lastDate = now.add(const Duration(days: 100));
@@ -23,7 +23,7 @@ showDatePickerWithCustomCupertinoStateful(BuildContext context) async {
2323
}
2424
}
2525

26-
showDatePickerWithCustomCupertino(BuildContext context) async {
26+
Future<void> showDatePickerWithCustomCupertino(BuildContext context) async {
2727
final now = DateUtils.dateOnly(DateTime.now());
2828
final firstDate = now.subtract(const Duration(days: 100));
2929
final lastDate = now.add(const Duration(days: 100));
@@ -61,11 +61,11 @@ showDatePickerWithCustomCupertino(BuildContext context) async {
6161
}
6262
}
6363

64-
_showResultDialog(BuildContext context, String text) {
64+
void _showResultDialog(BuildContext context, String text) {
6565
showPlatformDialog(
6666
context: context,
6767
builder: (_) => PlatformAlertDialog(
68-
title: Text('Alert'),
68+
title: const Text('Alert'),
6969
content: Text('$text content'),
7070
actions: <Widget>[
7171
PlatformDialogAction(

example/lib/icons_page.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
44
import 'platform_widget_example.dart';
55

66
class IconsPage extends StatelessWidget {
7+
const IconsPage({super.key});
8+
79
@override
810
Widget build(BuildContext context) {
911
return PlatformScaffold(
1012
iosContentPadding: true,
11-
appBar: PlatformAppBar(title: Text('Platform Icons')),
13+
appBar: const PlatformAppBar(title: Text('Platform Icons')),
1214
body: Column(
1315
mainAxisSize: MainAxisSize.min,
1416
children: [
15-
Padding(
16-
padding: const EdgeInsets.all(8.0),
17+
const Padding(
18+
padding: EdgeInsets.all(8.0),
1719
child: Row(
1820
mainAxisAlignment: MainAxisAlignment.center,
1921
children: <Widget>[
@@ -32,7 +34,7 @@ class IconsPage extends StatelessWidget {
3234
],
3335
),
3436
),
35-
Divider(
37+
const Divider(
3638
thickness: 2,
3739
),
3840
Expanded(
@@ -274,7 +276,7 @@ class IconsPage extends StatelessWidget {
274276
}
275277

276278
class _IconCompared extends StatelessWidget {
277-
_IconCompared(this.title, this.icon);
279+
const _IconCompared(this.title, this.icon);
278280

279281
final String title;
280282
final IconData Function(BuildContext context) icon;

example/lib/logo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class FlutterPlatformWidgetsLogo extends StatelessWidget {
3636
),
3737
),
3838
CupertinoButton.filled(
39-
padding: EdgeInsets.all(8),
39+
padding: const EdgeInsets.all(8),
4040
child: Padding(
4141
padding: const EdgeInsets.symmetric(horizontal: 8),
4242
child: Text(

example/lib/main.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
55
import 'platform_page.dart.dart';
66

77
void main() {
8-
runApp(MyApp());
8+
runApp(const MyApp());
99
}
1010

1111
class MyApp extends StatefulWidget {
12+
const MyApp({super.key});
13+
1214
@override
1315
State<MyApp> createState() => _MyAppState();
1416
}
@@ -59,7 +61,7 @@ class _MyAppState extends State<MyApp> {
5961
onThemeModeChanged: (themeMode) {
6062
this.themeMode = themeMode; /* you can save to storage */
6163
},
62-
builder: (context) => PlatformApp(
64+
builder: (context) => const PlatformApp(
6365
localizationsDelegates: <LocalizationsDelegate<dynamic>>[
6466
DefaultMaterialLocalizations.delegate,
6567
DefaultWidgetsLocalizations.delegate,

example/lib/material_ios_page.dart

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
33

44
/// Page to show what material widgets look like on cupertino
55
class IosMaterialPage extends StatelessWidget {
6+
const IosMaterialPage({super.key});
7+
68
@override
79
Widget build(BuildContext context) {
810
return PlatformScaffold(
911
appBar: PlatformAppBar(
10-
title: Text('iOS with Material'),
12+
title: const Text('iOS with Material'),
1113
trailingActions: [
1214
// This is possible because of PlatformProvider iosUsesMaterialWidgets setting
13-
IconButton(icon: Icon(Icons.ac_unit), onPressed: () {}),
15+
IconButton(icon: const Icon(Icons.ac_unit), onPressed: () {}),
1416
],
1517
cupertino: (_, __) => CupertinoNavigationBarData(
1618
// If this is enabled and set to true then the IconButton above will complain of no parent Material widget
@@ -20,17 +22,17 @@ class IosMaterialPage extends StatelessWidget {
2022
body: ListView(
2123
children: [
2224
IconButton(
23-
icon: Icon(Icons.book),
25+
icon: const Icon(Icons.book),
2426
onPressed: () {},
2527
),
26-
Divider(
28+
const Divider(
2729
thickness: 6,
2830
),
2931
ListTile(
30-
title: Text('List Tile title'),
31-
subtitle: Text('sub title'),
32+
title: const Text('List Tile title'),
33+
subtitle: const Text('sub title'),
3234
onTap: () {},
33-
trailing: Icon(Icons.place),
35+
trailing: const Icon(Icons.place),
3436
),
3537
],
3638
),

example/lib/platform_page.dart.dart

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ import 'icons_page.dart';
88
import 'logo.dart';
99
import 'material_ios_page.dart';
1010
import 'platform_widget_example.dart';
11-
import 'tab_impl_page.dart';
1211
import 'sliver_app_bar_page.dart';
12+
import 'tab_impl_page.dart';
1313

1414
class PlatformPage extends StatelessWidget {
15+
const PlatformPage({super.key});
16+
1517
@override
1618
Widget build(BuildContext context) {
1719
return PlatformScaffold(
18-
appBar: PlatformAppBar(
20+
appBar: const PlatformAppBar(
1921
title: Text('Flutter Platform Widgets'),
2022
),
2123
body: PlatformScrollbar(
2224
thumbVisibility: true,
2325
child: ListView(
2426
children: [
25-
FlutterPlatformWidgetsLogo(size: 60),
26-
Divider(thickness: 10),
27+
const FlutterPlatformWidgetsLogo(size: 60),
28+
const Divider(thickness: 10),
2729
Padding(
2830
padding: const EdgeInsets.all(8.0),
2931
child: PlatformElevatedButton(
@@ -49,15 +51,15 @@ class PlatformPage extends StatelessWidget {
4951
PlatformTheme.of(context)?.themeMode = newMode;
5052
}),
5153
),
52-
Divider(thickness: 10),
54+
const Divider(thickness: 10),
5355
// ! PlatformSearchBar
5456
PlatformWidgetExample(
5557
title:
5658
'PlatformSearchBar ${isMaterial(context) ? " (Material 3 only)" : ""}',
5759
builder: (context, platform) => PlatformSearchBar(
5860
onChanged: (value) =>
59-
print('${platform.text} SearchBar changed: $value'),
60-
onTap: () => print('${platform.text} SearchBar tapped'),
61+
debugPrint('${platform.text} SearchBar changed: $value'),
62+
onTap: () => debugPrint('${platform.text} SearchBar tapped'),
6163
hintText: '${platform.text} SearchBar',
6264
),
6365
),
@@ -66,10 +68,10 @@ class PlatformPage extends StatelessWidget {
6668
title: 'PlatformListTile',
6769
builder: (_, platform) => PlatformListTile(
6870
leading: Icon(context.platformIcons.book),
69-
title: PlatformText("title"),
70-
subtitle: PlatformText("subtitle"),
71+
title: PlatformText('title'),
72+
subtitle: PlatformText('subtitle'),
7173
trailing: Icon(context.platformIcons.rightChevron),
72-
onTap: () => print('${platform.text} PlatformListTile'),
74+
onTap: () => debugPrint('${platform.text} PlatformListTile'),
7375
),
7476
),
7577
// ! PlatformText
@@ -145,7 +147,7 @@ class PlatformPage extends StatelessWidget {
145147
title: 'PlatformElevatedButton',
146148
builder: (_, platform) => PlatformElevatedButton(
147149
child: Text(platform.text),
148-
onPressed: () => print('${platform.text} PlatformButton'),
150+
onPressed: () => debugPrint('${platform.text} PlatformButton'),
149151
padding: const EdgeInsets.all(8),
150152
color: Colors.orange,
151153
),
@@ -154,10 +156,10 @@ class PlatformPage extends StatelessWidget {
154156
title: 'PlatformElevatedButton Icon',
155157
builder: (_, platform) => PlatformElevatedButton(
156158
child: Text(platform.text),
157-
onPressed: () => print('${platform.text} PlatformButton'),
159+
onPressed: () => debugPrint('${platform.text} PlatformButton'),
158160
padding: const EdgeInsets.all(8),
159161
material: (_, __) => MaterialElevatedButtonData(
160-
icon: Icon(Icons.home),
162+
icon: const Icon(Icons.home),
161163
),
162164
cupertino: (_, __) => CupertinoElevatedButtonData(
163165
originalStyle: true,
@@ -169,18 +171,18 @@ class PlatformPage extends StatelessWidget {
169171
title: 'PlatformTextButton',
170172
builder: (_, platform) => PlatformTextButton(
171173
child: Text(platform.text),
172-
onPressed: () => print('${platform.text} PlatformButton'),
174+
onPressed: () => debugPrint('${platform.text} PlatformButton'),
173175
padding: const EdgeInsets.all(8),
174176
),
175177
),
176178
PlatformWidgetExample(
177179
title: 'PlatformTextButton Icon',
178180
builder: (_, platform) => PlatformTextButton(
179181
child: Text(platform.text),
180-
onPressed: () => print('${platform.text} PlatformButton'),
182+
onPressed: () => debugPrint('${platform.text} PlatformButton'),
181183
padding: const EdgeInsets.all(8),
182184
material: (_, __) => MaterialTextButtonData(
183-
icon: Icon(Icons.home),
185+
icon: const Icon(Icons.home),
184186
),
185187
cupertino: (_, __) => CupertinoTextButtonData(
186188
originalStyle: true,
@@ -256,11 +258,11 @@ class PlatformPage extends StatelessWidget {
256258
builder: (_, platform) => PlatformWidgetBuilder(
257259
cupertino: (_, child, __) => GestureDetector(
258260
child: child,
259-
onTap: () => print('Cupertino PlatformWidgetBuilder'),
261+
onTap: () => debugPrint('Cupertino PlatformWidgetBuilder'),
260262
),
261263
material: (_, child, __) => InkWell(
262264
child: child,
263-
onTap: () => print('Material PlatformWidgetBuilder'),
265+
onTap: () => debugPrint('Material PlatformWidgetBuilder'),
264266
),
265267
child: Container(
266268
padding: const EdgeInsets.all(12),
@@ -351,11 +353,11 @@ class PlatformPage extends StatelessWidget {
351353
Padding(
352354
padding: const EdgeInsets.all(8.0),
353355
child: PlatformElevatedButton(
354-
child: Text('Show Tabbed Pages'),
356+
child: const Text('Show Tabbed Pages'),
355357
onPressed: () => Navigator.of(context).push(
356358
platformPageRoute(
357359
context: context,
358-
builder: (context) => TabImplementationPage(),
360+
builder: (context) => const TabImplementationPage(),
359361
),
360362
),
361363
),
@@ -365,11 +367,11 @@ class PlatformPage extends StatelessWidget {
365367
Padding(
366368
padding: const EdgeInsets.all(8.0),
367369
child: PlatformElevatedButton(
368-
child: Text('Show Sliver AppBar Page'),
370+
child: const Text('Show Sliver AppBar Page'),
369371
onPressed: () => Navigator.of(context).push(
370372
platformPageRoute(
371373
context: context,
372-
builder: (context) => PlatformSliverAppBarPage(),
374+
builder: (context) => const PlatformSliverAppBarPage(),
373375
),
374376
),
375377
),
@@ -380,11 +382,11 @@ class PlatformPage extends StatelessWidget {
380382
Padding(
381383
padding: const EdgeInsets.all(8.0),
382384
child: PlatformElevatedButton(
383-
child: Text('Show Platform Icons'),
385+
child: const Text('Show Platform Icons'),
384386
onPressed: () => Navigator.of(context).push(
385387
platformPageRoute(
386388
context: context,
387-
builder: (context) => IconsPage(),
389+
builder: (context) => const IconsPage(),
388390
),
389391
),
390392
),
@@ -394,11 +396,11 @@ class PlatformPage extends StatelessWidget {
394396
Padding(
395397
padding: const EdgeInsets.all(8.0),
396398
child: PlatformElevatedButton(
397-
child: Text('Show Material on iOS'),
399+
child: const Text('Show Material on iOS'),
398400
onPressed: () => Navigator.of(context).push(
399401
platformPageRoute(
400402
context: context,
401-
builder: (context) => IosMaterialPage(),
403+
builder: (context) => const IosMaterialPage(),
402404
),
403405
),
404406
),
@@ -429,7 +431,7 @@ ThemeMode _cycleThemeMode(ThemeMode? mode) {
429431
}
430432
}
431433

432-
_showDatePicker(BuildContext context) async {
434+
Future<void> _showDatePicker(BuildContext context) async {
433435
final now = DateUtils.dateOnly(DateTime.now());
434436
final date = await showPlatformDatePicker(
435437
context: context,
@@ -443,11 +445,11 @@ _showDatePicker(BuildContext context) async {
443445
}
444446
}
445447

446-
_showExampleDialog(BuildContext context, String text) {
448+
void _showExampleDialog(BuildContext context, String text) {
447449
showPlatformDialog(
448450
context: context,
449451
builder: (_) => PlatformAlertDialog(
450-
title: Text('Alert'),
452+
title: const Text('Alert'),
451453
content: Text('$text content'),
452454
actions: <Widget>[
453455
PlatformDialogAction(
@@ -465,7 +467,7 @@ _showExampleDialog(BuildContext context, String text) {
465467
);
466468
}
467469

468-
_showPopupSheet(BuildContext context, String text) {
470+
void _showPopupSheet(BuildContext context, String text) {
469471
showPlatformModalSheet(
470472
context: context,
471473
builder: (_) => PlatformWidget(

example/lib/platform_widget_example.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class PlatformWidgetExample extends StatelessWidget {
3333
? TargetPlatform.android
3434
: TargetPlatform.iOS),
3535
),
36-
Divider(
36+
const Divider(
3737
height: 16,
3838
thickness: 2,
3939
),
@@ -51,8 +51,8 @@ class PlatformWidgetExample extends StatelessWidget {
5151
child: builder(context, TargetPlatform.android),
5252
),
5353
)).asMaterial(),
54-
Padding(
55-
padding: const EdgeInsets.all(8.0),
54+
const Padding(
55+
padding: EdgeInsets.all(8.0),
5656
child: VerticalDivider(
5757
width: 1,
5858
thickness: 1,

example/lib/sliver_app_bar_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class _PlatformSliverAppBarPageState extends State<PlatformSliverAppBarPage> {
1515
return PlatformScaffold(
1616
body: CustomScrollView(
1717
slivers: <Widget>[
18-
PlatformSliverAppBar(
18+
const PlatformSliverAppBar(
1919
title: Text('Sliver App Bar'),
2020
),
2121
SliverList(
@@ -26,7 +26,7 @@ class _PlatformSliverAppBarPageState extends State<PlatformSliverAppBarPage> {
2626
height: 100.0,
2727
child: Center(
2828
child: PlatformText('$index',
29-
textScaler: TextScaler.linear(5)),
29+
textScaler: const TextScaler.linear(5)),
3030
),
3131
);
3232
},

0 commit comments

Comments
 (0)