Skip to content
This repository was archived by the owner on Feb 25, 2024. It is now read-only.

Commit 552f0a4

Browse files
authored
Migrate to Flutter 3.10 & Dart 3.0 (#342)
* Migrate to Flutter 3.10 & Dart 3.0 * Restore 16px horizontal padding for buttons * Merge commonButtonStyle with type-specific button styles * Swap button style merge the other way around Use the common properties as defaults and let the type-specific properties override to avoid surprises.
1 parent e1c9757 commit 552f0a4

8 files changed

Lines changed: 30 additions & 30 deletions

File tree

.github/workflows/flutter-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
channel: 'stable'
5454

5555
- name: Check for any formatting issues
56-
run: flutter format --set-exit-if-changed .
56+
run: dart format --set-exit-if-changed .
5757

5858
pub:
5959
runs-on: ubuntu-20.04

example/lib/view/controls_view.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ class _ControlsViewState extends State<ControlsView>
227227
],
228228
),
229229
),
230-
Padding(
231-
padding: const EdgeInsets.all(12.0),
230+
const Padding(
231+
padding: EdgeInsets.all(12.0),
232232
child: Row(
233-
children: const [
233+
children: [
234234
DropdownMenu(
235235
dropdownMenuEntries: [
236236
DropdownMenuEntry(value: 1, label: '1'),
@@ -407,17 +407,17 @@ class _ControlsViewState extends State<ControlsView>
407407
const Text('No'),
408408
],
409409
),
410-
Row(
411-
children: const <Widget>[
410+
const Row(
411+
children: <Widget>[
412412
Switch(
413413
value: true,
414414
onChanged: null,
415415
),
416416
Text('Disabled Yes'),
417417
],
418418
),
419-
Row(
420-
children: const <Widget>[
419+
const Row(
420+
children: <Widget>[
421421
Switch(
422422
value: false,
423423
onChanged: null,
@@ -428,17 +428,17 @@ class _ControlsViewState extends State<ControlsView>
428428
],
429429
),
430430
),
431-
Column(
431+
const Column(
432432
children: [
433433
Padding(
434-
padding: const EdgeInsets.all(18.0),
434+
padding: EdgeInsets.all(18.0),
435435
child: Row(
436-
children: const [
436+
children: [
437437
CircularProgressIndicator(),
438438
],
439439
),
440440
),
441-
const Padding(
441+
Padding(
442442
padding: EdgeInsets.all(18.0),
443443
child: LinearProgressIndicator(),
444444
),

example/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ publish_to: "none"
44
version: 1.0.0
55

66
environment:
7-
sdk: ">=2.17.0 <3.0.0"
7+
sdk: ">=3.0.0 <4.0.0"
8+
flutter: ">=3.10.0"
89

910
dependencies:
1011
flutter:

lib/src/themes/common_themes.dart

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ const _tooltipThemeData = TooltipThemeData(
9999

100100
// Buttons
101101

102-
const _commonButtonStyle = ButtonStyle(visualDensity: VisualDensity.standard);
102+
const _commonButtonStyle = ButtonStyle(
103+
visualDensity: VisualDensity.standard,
104+
padding: MaterialStatePropertyAll(EdgeInsets.symmetric(horizontal: 16)),
105+
);
103106

104107
final _buttonThemeData = ButtonThemeData(
105108
shape: RoundedRectangleBorder(
@@ -117,13 +120,12 @@ OutlinedButtonThemeData _createOutlinedButtonTheme(
117120
? colorScheme.outlineVariant
118121
: colorScheme.outline,
119122
),
120-
visualDensity: _commonButtonStyle.visualDensity,
121123
// backgroundColor: colorScheme.surface, // defaults to transparent
122124
foregroundColor: colorScheme.onSurface,
123125
shape: RoundedRectangleBorder(
124126
borderRadius: BorderRadius.circular(kButtonRadius),
125127
),
126-
),
128+
).merge(_commonButtonStyle),
127129
);
128130
}
129131

@@ -134,11 +136,10 @@ TextButtonThemeData _createTextButtonTheme(
134136
style: TextButton.styleFrom(
135137
iconColor: colorScheme.primary,
136138
foregroundColor: colorScheme.primary,
137-
visualDensity: _commonButtonStyle.visualDensity,
138139
shape: RoundedRectangleBorder(
139140
borderRadius: BorderRadius.circular(kButtonRadius),
140141
),
141-
),
142+
).merge(_commonButtonStyle),
142143
);
143144
}
144145

@@ -151,7 +152,6 @@ ElevatedButtonThemeData _createElevatedButtonTheme({
151152
style: ElevatedButton.styleFrom(
152153
backgroundColor: color,
153154
foregroundColor: textColor ?? contrastColor(color),
154-
visualDensity: _commonButtonStyle.visualDensity,
155155
elevation: 0,
156156
shadowColor: Colors.transparent,
157157
shape: RoundedRectangleBorder(
@@ -160,7 +160,7 @@ ElevatedButtonThemeData _createElevatedButtonTheme({
160160
: BorderSide.none,
161161
borderRadius: BorderRadius.circular(kButtonRadius),
162162
),
163-
),
163+
).merge(_commonButtonStyle),
164164
);
165165
}
166166

@@ -173,7 +173,6 @@ FilledButtonThemeData _createFilledButtonTheme(
173173
backgroundColor: colorScheme.onSurface.withOpacity(0.1),
174174
surfaceTintColor: colorScheme.onSurface.withOpacity(0.1),
175175
foregroundColor: colorScheme.onSurface,
176-
visualDensity: _commonButtonStyle.visualDensity,
177176
elevation: 0,
178177
shadowColor: Colors.transparent,
179178
shape: RoundedRectangleBorder(
@@ -182,7 +181,7 @@ FilledButtonThemeData _createFilledButtonTheme(
182181
: BorderSide.none,
183182
borderRadius: BorderRadius.circular(kButtonRadius),
184183
),
185-
),
184+
).merge(_commonButtonStyle),
186185
);
187186
}
188187

pubspec.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ homepage: https://github.com/ubuntu/yaru.dart
77
issue_tracker: https://github.com/ubuntu/yaru.dart/issues
88

99
environment:
10-
sdk: ">=2.17.0 <3.0.0"
11-
flutter: ">=3.7.0-0"
10+
sdk: ">=3.0.0 <4.0.0"
11+
flutter: ">=3.10.0"
1212

1313
platforms:
1414
android:
@@ -19,18 +19,18 @@ platforms:
1919
windows:
2020

2121
dependencies:
22-
collection: ^1.16.0
22+
collection: ^1.17.0
2323
flutter:
2424
sdk: flutter
2525
gtk: ^2.0.0
2626
platform: ^3.1.0
2727

2828
dev_dependencies:
2929
build_runner: ^2.1.10
30-
flutter_lints: ^1.0.4
30+
flutter_lints: ^2.0.0
3131
flutter_test:
3232
sdk: flutter
33-
mockito: ^5.1.0
33+
mockito: ^5.4.0
3434

3535
flutter:
3636
fonts:

test/settings_test.mocks.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Mocks generated by Mockito 5.3.2 from annotations
1+
// Mocks generated by Mockito 5.4.0 from annotations
22
// in yaru/test/settings_test.dart.
33
// Do not manually edit this file.
44

test/widget_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ extension ThemeTester on WidgetTester {
214214
MaterialApp(
215215
key: ValueKey(data),
216216
home: YaruTheme(
217-
child: Container(),
218217
data: data,
219218
platform: FakePlatform(
220219
operatingSystem: Platform.linux,
@@ -224,6 +223,7 @@ extension ThemeTester on WidgetTester {
224223
},
225224
),
226225
settings: settings,
226+
child: Container(),
227227
),
228228
),
229229
);

test/widget_test.mocks.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Mocks generated by Mockito 5.3.2 from annotations
1+
// Mocks generated by Mockito 5.4.0 from annotations
22
// in yaru/test/widget_test.dart.
33
// Do not manually edit this file.
44

0 commit comments

Comments
 (0)