Skip to content

Commit 7d92700

Browse files
Move toggleable to widget layer (#148272)
Currently, toggleable exists independently in the material and cupertino libraries. Cupertino's toggleable is a minimal copy of material's, and so it makes sense to have only one toggleable in the widgets layer. This change makes it easier for cupertino's toggleables (switch, radio, checkbox) to potentially have as many capabilities as material toggleables (for example, resolving in different widget states), thus increasing support for the cupertino library. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat [Data Driven Fixes]: https://github.com/flutter/flutter/wiki/Data-driven-Fixes --------- Co-authored-by: Pierre-Louis <6655696+guidezpl@users.noreply.github.com>
1 parent a24b764 commit 7d92700

File tree

10 files changed

+89
-282
lines changed

10 files changed

+89
-282
lines changed

packages/flutter/lib/material.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ export 'src/material/time_picker.dart';
188188
export 'src/material/time_picker_theme.dart';
189189
export 'src/material/toggle_buttons.dart';
190190
export 'src/material/toggle_buttons_theme.dart';
191-
export 'src/material/toggleable.dart';
192191
export 'src/material/tooltip.dart';
193192
export 'src/material/tooltip_theme.dart';
194193
export 'src/material/tooltip_visibility.dart';

packages/flutter/lib/src/cupertino/checkbox.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:flutter/widgets.dart';
66

77
import 'colors.dart';
88
import 'constants.dart';
9-
import 'toggleable.dart';
109

1110
// Examples can assume:
1211
// bool _throwShotAway = false;

packages/flutter/lib/src/cupertino/radio.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:flutter/foundation.dart';
66
import 'package:flutter/widgets.dart';
77

88
import 'colors.dart';
9-
import 'toggleable.dart';
109

1110
// Examples can assume:
1211
// late BuildContext context;

packages/flutter/lib/src/cupertino/toggleable.dart

Lines changed: 0 additions & 244 deletions
This file was deleted.

packages/flutter/lib/src/material/checkbox.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import 'debug.dart';
1212
import 'material_state.dart';
1313
import 'theme.dart';
1414
import 'theme_data.dart';
15-
import 'toggleable.dart';
1615

1716
// Examples can assume:
1817
// bool _throwShotAway = false;
@@ -444,6 +443,9 @@ class _CheckboxState extends State<Checkbox> with TickerProviderStateMixin, Togg
444443
@override
445444
bool? get value => widget.value;
446445

446+
@override
447+
Duration? get reactionAnimationDuration => kRadialReactionDuration;
448+
447449
MaterialStateProperty<Color?> get _widgetFillColor {
448450
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
449451
if (states.contains(MaterialState.disabled)) {

packages/flutter/lib/src/material/radio.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'material_state.dart';
1313
import 'radio_theme.dart';
1414
import 'theme.dart';
1515
import 'theme_data.dart';
16-
import 'toggleable.dart';
1716

1817
// Examples can assume:
1918
// late BuildContext context;
@@ -412,6 +411,9 @@ class _RadioState<T> extends State<Radio<T>> with TickerProviderStateMixin, Togg
412411
@override
413412
bool? get value => widget._selected;
414413

414+
@override
415+
Duration? get reactionAnimationDuration => kRadialReactionDuration;
416+
415417
MaterialStateProperty<Color?> get _widgetFillColor {
416418
return MaterialStateProperty.resolveWith((Set<MaterialState> states) {
417419
if (states.contains(MaterialState.disabled)) {

packages/flutter/lib/src/material/switch.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import 'shadows.dart';
1818
import 'switch_theme.dart';
1919
import 'theme.dart';
2020
import 'theme_data.dart';
21-
import 'toggleable.dart';
2221

2322
// Examples can assume:
2423
// bool _giveVerse = true;
@@ -746,6 +745,9 @@ class _MaterialSwitchState extends State<_MaterialSwitch> with TickerProviderSta
746745
@override
747746
bool? get value => widget.value;
748747

748+
@override
749+
Duration? get reactionAnimationDuration => kRadialReactionDuration;
750+
749751
void updateCurve() {
750752
if (Theme.of(context).useMaterial3) {
751753
position

0 commit comments

Comments
 (0)