Skip to content

Commit 34683ac

Browse files
authored
Migrating styleFrom API to new version. (flutter#4540)
Updates the styleFrom API to use `backgroundColor` and `foregroundColor` instead of deprecated methods (`primary`, `onPrimary`). Fixes [#105724](flutter/flutter#105724)
1 parent ac41376 commit 34683ac

Some content is hidden

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

53 files changed

+127
-214
lines changed

packages/camera/camera/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.5+3
2+
3+
* Migrates `styleFrom` usage in examples off of deprecated `primary` and `onPrimary` parameters.
4+
15
## 0.10.5+2
26

37
* Fixes unawaited_futures violations.

packages/camera/camera/example/lib/main.dart

+4-12
Original file line numberDiff line numberDiff line change
@@ -365,16 +365,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
365365

366366
Widget _exposureModeControlRowWidget() {
367367
final ButtonStyle styleAuto = TextButton.styleFrom(
368-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
369-
// ignore: deprecated_member_use
370-
primary: controller?.value.exposureMode == ExposureMode.auto
368+
foregroundColor: controller?.value.exposureMode == ExposureMode.auto
371369
? Colors.orange
372370
: Colors.blue,
373371
);
374372
final ButtonStyle styleLocked = TextButton.styleFrom(
375-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
376-
// ignore: deprecated_member_use
377-
primary: controller?.value.exposureMode == ExposureMode.locked
373+
foregroundColor: controller?.value.exposureMode == ExposureMode.locked
378374
? Colors.orange
379375
: Colors.blue,
380376
);
@@ -452,16 +448,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
452448

453449
Widget _focusModeControlRowWidget() {
454450
final ButtonStyle styleAuto = TextButton.styleFrom(
455-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
456-
// ignore: deprecated_member_use
457-
primary: controller?.value.focusMode == FocusMode.auto
451+
foregroundColor: controller?.value.focusMode == FocusMode.auto
458452
? Colors.orange
459453
: Colors.blue,
460454
);
461455
final ButtonStyle styleLocked = TextButton.styleFrom(
462-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
463-
// ignore: deprecated_member_use
464-
primary: controller?.value.focusMode == FocusMode.locked
456+
foregroundColor: controller?.value.focusMode == FocusMode.locked
465457
? Colors.orange
466458
: Colors.blue,
467459
);

packages/camera/camera/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing
44
Dart.
55
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera
66
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
7-
version: 0.10.5+2
7+
version: 0.10.5+3
88

99
environment:
1010
sdk: ">=2.18.0 <4.0.0"

packages/camera/camera_android/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.8+6
2+
3+
* Migrates `styleFrom` usage in examples off of deprecated `primary` and `onPrimary` parameters.
4+
15
## 0.10.8+5
26

37
* Provides a default exposure point if null.

packages/camera/camera_android/example/lib/main.dart

+4-12
Original file line numberDiff line numberDiff line change
@@ -368,16 +368,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
368368

369369
Widget _exposureModeControlRowWidget() {
370370
final ButtonStyle styleAuto = TextButton.styleFrom(
371-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
372-
// ignore: deprecated_member_use
373-
primary: controller?.value.exposureMode == ExposureMode.auto
371+
foregroundColor: controller?.value.exposureMode == ExposureMode.auto
374372
? Colors.orange
375373
: Colors.blue,
376374
);
377375
final ButtonStyle styleLocked = TextButton.styleFrom(
378-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
379-
// ignore: deprecated_member_use
380-
primary: controller?.value.exposureMode == ExposureMode.locked
376+
foregroundColor: controller?.value.exposureMode == ExposureMode.locked
381377
? Colors.orange
382378
: Colors.blue,
383379
);
@@ -456,16 +452,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
456452

457453
Widget _focusModeControlRowWidget() {
458454
final ButtonStyle styleAuto = TextButton.styleFrom(
459-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
460-
// ignore: deprecated_member_use
461-
primary: controller?.value.focusMode == FocusMode.auto
455+
foregroundColor: controller?.value.focusMode == FocusMode.auto
462456
? Colors.orange
463457
: Colors.blue,
464458
);
465459
final ButtonStyle styleLocked = TextButton.styleFrom(
466-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
467-
// ignore: deprecated_member_use
468-
primary: controller?.value.focusMode == FocusMode.locked
460+
foregroundColor: controller?.value.focusMode == FocusMode.locked
469461
? Colors.orange
470462
: Colors.blue,
471463
);

packages/camera/camera_android/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Android implementation of the camera plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
55

6-
version: 0.10.8+5
6+
version: 0.10.8+6
77

88
environment:
99
sdk: ">=2.18.0 <4.0.0"

packages/camera/camera_android_camerax/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.0+13
2+
3+
* Migrates `styleFrom` usage in examples off of deprecated `primary` and `onPrimary` parameters.
4+
15
## 0.5.0+12
26

37
* Wraps classes needed to implement resolution configuration for image capture, image analysis, and preview.

packages/camera/camera_android_camerax/example/lib/main.dart

+4-12
Original file line numberDiff line numberDiff line change
@@ -357,16 +357,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
357357

358358
Widget _exposureModeControlRowWidget() {
359359
final ButtonStyle styleAuto = TextButton.styleFrom(
360-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
361-
// ignore: deprecated_member_use
362-
primary: controller?.value.exposureMode == ExposureMode.auto
360+
foregroundColor: controller?.value.exposureMode == ExposureMode.auto
363361
? Colors.orange
364362
: Colors.blue,
365363
);
366364
final ButtonStyle styleLocked = TextButton.styleFrom(
367-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
368-
// ignore: deprecated_member_use
369-
primary: controller?.value.exposureMode == ExposureMode.locked
365+
foregroundColor: controller?.value.exposureMode == ExposureMode.locked
370366
? Colors.orange
371367
: Colors.blue,
372368
);
@@ -439,16 +435,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
439435

440436
Widget _focusModeControlRowWidget() {
441437
final ButtonStyle styleAuto = TextButton.styleFrom(
442-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
443-
// ignore: deprecated_member_use
444-
primary: controller?.value.focusMode == FocusMode.auto
438+
foregroundColor: controller?.value.focusMode == FocusMode.auto
445439
? Colors.orange
446440
: Colors.blue,
447441
);
448442
final ButtonStyle styleLocked = TextButton.styleFrom(
449-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
450-
// ignore: deprecated_member_use
451-
primary: controller?.value.focusMode == FocusMode.locked
443+
foregroundColor: controller?.value.focusMode == FocusMode.locked
452444
? Colors.orange
453445
: Colors.blue,
454446
);

packages/camera/camera_android_camerax/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_android_camerax
22
description: Android implementation of the camera plugin using the CameraX library.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.5.0+12
5+
version: 0.5.0+13
66

77
environment:
88
sdk: ">=2.19.0 <4.0.0"

packages/camera/camera_avfoundation/CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 0.9.13+3
22

3+
* Migrates `styleFrom` usage in examples off of deprecated `primary` and `onPrimary` parameters.
34
* Fixes unawaited_futures violations.
45

56
## 0.9.13+2

packages/camera/camera_avfoundation/example/lib/main.dart

+4-12
Original file line numberDiff line numberDiff line change
@@ -368,16 +368,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
368368

369369
Widget _exposureModeControlRowWidget() {
370370
final ButtonStyle styleAuto = TextButton.styleFrom(
371-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
372-
// ignore: deprecated_member_use
373-
primary: controller?.value.exposureMode == ExposureMode.auto
371+
foregroundColor: controller?.value.exposureMode == ExposureMode.auto
374372
? Colors.orange
375373
: Colors.blue,
376374
);
377375
final ButtonStyle styleLocked = TextButton.styleFrom(
378-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
379-
// ignore: deprecated_member_use
380-
primary: controller?.value.exposureMode == ExposureMode.locked
376+
foregroundColor: controller?.value.exposureMode == ExposureMode.locked
381377
? Colors.orange
382378
: Colors.blue,
383379
);
@@ -456,16 +452,12 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
456452

457453
Widget _focusModeControlRowWidget() {
458454
final ButtonStyle styleAuto = TextButton.styleFrom(
459-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
460-
// ignore: deprecated_member_use
461-
primary: controller?.value.focusMode == FocusMode.auto
455+
foregroundColor: controller?.value.focusMode == FocusMode.auto
462456
? Colors.orange
463457
: Colors.blue,
464458
);
465459
final ButtonStyle styleLocked = TextButton.styleFrom(
466-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
467-
// ignore: deprecated_member_use
468-
primary: controller?.value.focusMode == FocusMode.locked
460+
foregroundColor: controller?.value.focusMode == FocusMode.locked
469461
? Colors.orange
470462
: Colors.blue,
471463
);

packages/camera/camera_avfoundation/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_avfoundation
22
description: iOS implementation of the camera plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_avfoundation
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.9.13+2
5+
version: 0.9.13+3
66

77
environment:
88
sdk: ">=2.18.0 <4.0.0"

packages/file_selector/file_selector/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## NEXT
2+
3+
* Migrates `styleFrom` usage in examples off of deprecated `primary` and `onPrimary` parameters.
4+
15
## 1.0.0
26

37
* Removes the deprecated `getSavePath` in favor of `getSaveLocation`.

packages/file_selector/file_selector/example/lib/get_directory_page.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@ class GetDirectoryPage extends StatelessWidget {
4242
children: <Widget>[
4343
ElevatedButton(
4444
style: ElevatedButton.styleFrom(
45-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
46-
// ignore: deprecated_member_use
47-
primary: Colors.blue,
48-
// ignore: deprecated_member_use
49-
onPrimary: Colors.white,
45+
backgroundColor: Colors.blue,
46+
foregroundColor: Colors.white,
5047
),
5148
onPressed: _isIOS ? null : () => _getDirectoryPath(context),
5249
child: const Text(

packages/file_selector/file_selector/example/lib/get_multiple_directories_page.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,8 @@ class GetMultipleDirectoriesPage extends StatelessWidget {
4444
children: <Widget>[
4545
ElevatedButton(
4646
style: ElevatedButton.styleFrom(
47-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
48-
// ignore: deprecated_member_use
49-
primary: Colors.blue,
50-
// ignore: deprecated_member_use
51-
onPrimary: Colors.white,
47+
backgroundColor: Colors.blue,
48+
foregroundColor: Colors.white,
5249
),
5350
child: const Text(
5451
'Press to ask user to choose multiple directories'),

packages/file_selector/file_selector/example/lib/home_page.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ class HomePage extends StatelessWidget {
1515
@override
1616
Widget build(BuildContext context) {
1717
final ButtonStyle style = ElevatedButton.styleFrom(
18-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
19-
// ignore: deprecated_member_use
20-
primary: Colors.blue,
21-
// ignore: deprecated_member_use
22-
onPrimary: Colors.white,
18+
backgroundColor: Colors.blue,
19+
foregroundColor: Colors.white,
2320
);
2421
return Scaffold(
2522
appBar: AppBar(

packages/file_selector/file_selector/example/lib/open_image_page.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ class OpenImagePage extends StatelessWidget {
4949
children: <Widget>[
5050
ElevatedButton(
5151
style: ElevatedButton.styleFrom(
52-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
53-
// ignore: deprecated_member_use
54-
primary: Colors.blue,
55-
// ignore: deprecated_member_use
56-
onPrimary: Colors.white,
52+
backgroundColor: Colors.blue,
53+
foregroundColor: Colors.white,
5754
),
5855
child: const Text('Press to open an image file(png, jpg)'),
5956
onPressed: () => _openImageFile(context),

packages/file_selector/file_selector/example/lib/open_multiple_images_page.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,8 @@ class OpenMultipleImagesPage extends StatelessWidget {
5252
children: <Widget>[
5353
ElevatedButton(
5454
style: ElevatedButton.styleFrom(
55-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
56-
// ignore: deprecated_member_use
57-
primary: Colors.blue,
58-
// ignore: deprecated_member_use
59-
onPrimary: Colors.white,
55+
backgroundColor: Colors.blue,
56+
foregroundColor: Colors.white,
6057
),
6158
child: const Text('Press to open multiple images (png, jpg)'),
6259
onPressed: () => _openImageFile(context),

packages/file_selector/file_selector/example/lib/open_text_page.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ class OpenTextPage extends StatelessWidget {
5353
children: <Widget>[
5454
ElevatedButton(
5555
style: ElevatedButton.styleFrom(
56-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
57-
// ignore: deprecated_member_use
58-
primary: Colors.blue,
59-
// ignore: deprecated_member_use
60-
onPrimary: Colors.white,
56+
backgroundColor: Colors.blue,
57+
foregroundColor: Colors.white,
6158
),
6259
child: const Text('Press to open a text file (json, txt)'),
6360
onPressed: () => _openTextFile(context),

packages/file_selector/file_selector/example/lib/save_text_page.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,8 @@ class SaveTextPage extends StatelessWidget {
7979
const SizedBox(height: 10),
8080
ElevatedButton(
8181
style: ElevatedButton.styleFrom(
82-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
83-
// ignore: deprecated_member_use
84-
primary: Colors.blue,
85-
// ignore: deprecated_member_use
86-
onPrimary: Colors.white,
82+
backgroundColor: Colors.blue,
83+
foregroundColor: Colors.white,
8784
),
8885
onPressed: _isIOS ? null : () => _saveFile(),
8986
child: const Text(

packages/file_selector/file_selector_ios/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## NEXT
2+
3+
* Migrates `styleFrom` usage in examples off of deprecated `primary` and `onPrimary` parameters.
4+
15
## 0.5.1+4
26

37
* Updates references to the deprecated `macUTIs`.

packages/file_selector/file_selector_ios/example/lib/home_page.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ class HomePage extends StatelessWidget {
1212
@override
1313
Widget build(BuildContext context) {
1414
final ButtonStyle style = ElevatedButton.styleFrom(
15-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
16-
// ignore: deprecated_member_use
17-
primary: Colors.blue,
18-
// ignore: deprecated_member_use
19-
onPrimary: Colors.white,
15+
backgroundColor: Colors.blue,
16+
foregroundColor: Colors.white,
2017
);
2118
return Scaffold(
2219
appBar: AppBar(

packages/file_selector/file_selector_ios/example/lib/open_image_page.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ class OpenImagePage extends StatelessWidget {
4949
children: <Widget>[
5050
ElevatedButton(
5151
style: ElevatedButton.styleFrom(
52-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
53-
// ignore: deprecated_member_use
54-
primary: Colors.blue,
55-
// ignore: deprecated_member_use
56-
onPrimary: Colors.white,
52+
backgroundColor: Colors.blue,
53+
foregroundColor: Colors.white,
5754
),
5855
child: const Text('Press to open an image file(png, jpg)'),
5956
onPressed: () => _openImageFile(context),

packages/file_selector/file_selector_ios/example/lib/open_multiple_images_page.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,8 @@ class OpenMultipleImagesPage extends StatelessWidget {
5454
children: <Widget>[
5555
ElevatedButton(
5656
style: ElevatedButton.styleFrom(
57-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
58-
// ignore: deprecated_member_use
59-
primary: Colors.blue,
60-
// ignore: deprecated_member_use
61-
onPrimary: Colors.white,
57+
backgroundColor: Colors.blue,
58+
foregroundColor: Colors.white,
6259
),
6360
child: const Text('Press to open multiple images (png, jpg)'),
6461
onPressed: () => _openImageFile(context),

packages/file_selector/file_selector_ios/example/lib/open_text_page.dart

+2-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,8 @@ class OpenTextPage extends StatelessWidget {
4646
children: <Widget>[
4747
ElevatedButton(
4848
style: ElevatedButton.styleFrom(
49-
// TODO(darrenaustin): Migrate to new API once it lands in stable: https://github.com/flutter/flutter/issues/105724
50-
// ignore: deprecated_member_use
51-
primary: Colors.blue,
52-
// ignore: deprecated_member_use
53-
onPrimary: Colors.white,
49+
backgroundColor: Colors.blue,
50+
foregroundColor: Colors.white,
5451
),
5552
child: const Text('Press to open a text file (json, txt)'),
5653
onPressed: () => _openTextFile(context),

packages/file_selector/file_selector_linux/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## NEXT
2+
3+
* Migrates `styleFrom` usage in examples off of deprecated `primary` and `onPrimary` parameters.
4+
15
## 0.9.2
26

37
* Adds `getSaveLocation` and deprecates `getSavePath`.

0 commit comments

Comments
 (0)