Unverified Commit 0a417c3b authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

A bunch of cleanups and a missing `ShortcutRegistar` in `WidgetsApp` (#104560)

A bunch of random cleanup things I found while doing MenuBar development.

Changes an if test to an assert in binding.dart, since the if should always be true.
Adds the default ShortcutRegistrar that should have been in the ShortcutRegistry PR.
Moves a debug message in the FocusManager to print the result after the focus change instead of before.
Reorders the test parameters in theme_data_test.dart to match the order of the theme data fields everywhere else.
parent 19d69a97
...@@ -399,9 +399,9 @@ mixin GestureBinding on BindingBase implements HitTestable, HitTestDispatcher, H ...@@ -399,9 +399,9 @@ mixin GestureBinding on BindingBase implements HitTestable, HitTestDispatcher, H
@pragma('vm:notify-debugger-on-exception') @pragma('vm:notify-debugger-on-exception')
void dispatchEvent(PointerEvent event, HitTestResult? hitTestResult) { void dispatchEvent(PointerEvent event, HitTestResult? hitTestResult) {
assert(!locked); assert(!locked);
// No hit test information implies that this is a [PointerHoverEvent], // No hit test information implies that this is a [PointerAddedEvent] or
// [PointerAddedEvent], or [PointerRemovedEvent]. These events are specially // [PointerRemovedEvent]. These events are specially routed here; other
// routed here; other events will be routed through the `handleEvent` below. // events will be routed through the `handleEvent` below.
if (hitTestResult == null) { if (hitTestResult == null) {
assert(event is PointerAddedEvent || event is PointerRemovedEvent); assert(event is PointerAddedEvent || event is PointerRemovedEvent);
try { try {
......
...@@ -1730,7 +1730,9 @@ class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver { ...@@ -1730,7 +1730,9 @@ class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver {
actions: widget.actions ?? WidgetsApp.defaultActions, actions: widget.actions ?? WidgetsApp.defaultActions,
child: FocusTraversalGroup( child: FocusTraversalGroup(
policy: ReadingOrderTraversalPolicy(), policy: ReadingOrderTraversalPolicy(),
child: child, child: ShortcutRegistrar(
child: child,
),
), ),
), ),
), ),
......
...@@ -1798,10 +1798,10 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier { ...@@ -1798,10 +1798,10 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier {
_dirtyNodes.add(_primaryFocus!); _dirtyNodes.add(_primaryFocus!);
} }
} }
assert(_focusDebug('Notifying ${_dirtyNodes.length} dirty nodes:', _dirtyNodes.toList().map<String>((FocusNode node) => node.toString())));
for (final FocusNode node in _dirtyNodes) { for (final FocusNode node in _dirtyNodes) {
node._notify(); node._notify();
} }
assert(_focusDebug('Notified ${_dirtyNodes.length} dirty nodes:', _dirtyNodes.toList().map<String>((FocusNode node) => node.toString())));
_dirtyNodes.clear(); _dirtyNodes.clear();
if (previousFocus != _primaryFocus) { if (previousFocus != _primaryFocus) {
notifyListeners(); notifyListeners();
......
...@@ -186,6 +186,13 @@ void main() { ...@@ -186,6 +186,13 @@ void main() {
' Localizations\n' ' Localizations\n'
' MediaQuery\n' ' MediaQuery\n'
' _MediaQueryFromWindow\n' ' _MediaQueryFromWindow\n'
' _ShortcutRegistrarMarker\n'
' _ShortcutsMarker\n'
' Semantics\n'
' _FocusMarker\n'
' Focus\n'
' Shortcuts\n'
' ShortcutRegistrar\n'
' _FocusMarker\n' ' _FocusMarker\n'
' Focus\n' ' Focus\n'
' _FocusTraversalGroupMarker\n' ' _FocusTraversalGroupMarker\n'
......
...@@ -706,6 +706,7 @@ void main() { ...@@ -706,6 +706,7 @@ void main() {
buttonColor: Colors.black, buttonColor: Colors.black,
fixTextFieldOutlineLabel: false, fixTextFieldOutlineLabel: false,
primaryColorBrightness: Brightness.dark, primaryColorBrightness: Brightness.dark,
androidOverscrollIndicator: AndroidOverscrollIndicator.glow,
); );
final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors( final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors(
...@@ -722,245 +723,303 @@ void main() { ...@@ -722,245 +723,303 @@ void main() {
); );
final ThemeData otherTheme = ThemeData.raw( final ThemeData otherTheme = ThemeData.raw(
// For the sanity of the reader, make sure these properties are in the same
// order everywhere that they are separated by section comments (e.g.
// GENERAL CONFIGURATION). Each section except for deprecations should be
// alphabetical by symbol name.
// GENERAL CONFIGURATION
applyElevationOverlayColor: true,
cupertinoOverrideTheme: ThemeData.light().cupertinoOverrideTheme,
extensions: const <Object, ThemeExtension<dynamic>>{
MyThemeExtensionB: MyThemeExtensionB(textStyle: TextStyle()),
},
inputDecorationTheme: ThemeData.light().inputDecorationTheme.copyWith(border: InputBorder.none),
materialTapTargetSize: MaterialTapTargetSize.padded,
pageTransitionsTheme: const PageTransitionsTheme(),
platform: TargetPlatform.android,
scrollbarTheme: const ScrollbarThemeData(radius: Radius.circular(10.0)),
splashFactory: InkRipple.splashFactory,
useMaterial3: true,
visualDensity: VisualDensity.standard, visualDensity: VisualDensity.standard,
primaryColor: Colors.white,
primaryColorBrightness: Brightness.light, // COLOR
primaryColorLight: Colors.white, backgroundColor: Colors.white,
primaryColorDark: Colors.white,
accentColor: Colors.white,
accentColorBrightness: Brightness.light,
canvasColor: Colors.white,
shadowColor: Colors.white,
scaffoldBackgroundColor: Colors.white,
bottomAppBarColor: Colors.white, bottomAppBarColor: Colors.white,
canvasColor: Colors.white,
cardColor: Colors.white, cardColor: Colors.white,
colorScheme: const ColorScheme.light(),
dialogBackgroundColor: Colors.white,
disabledColor: Colors.white,
dividerColor: Colors.white, dividerColor: Colors.white,
errorColor: Colors.white,
focusColor: Colors.white, focusColor: Colors.white,
hoverColor: Colors.white,
highlightColor: Colors.white, highlightColor: Colors.white,
splashColor: Colors.white,
splashFactory: InkRipple.splashFactory,
useMaterial3: true,
selectedRowColor: Colors.white,
unselectedWidgetColor: Colors.white,
disabledColor: Colors.white,
buttonTheme: const ButtonThemeData(colorScheme: ColorScheme.light()),
toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.white)),
buttonColor: Colors.white,
secondaryHeaderColor: Colors.white,
backgroundColor: Colors.white,
dialogBackgroundColor: Colors.white,
indicatorColor: Colors.white,
hintColor: Colors.white, hintColor: Colors.white,
errorColor: Colors.white, hoverColor: Colors.white,
indicatorColor: Colors.white,
primaryColor: Colors.white,
primaryColorDark: Colors.white,
primaryColorLight: Colors.white,
scaffoldBackgroundColor: Colors.white,
secondaryHeaderColor: Colors.white,
selectedRowColor: Colors.white,
shadowColor: Colors.white,
splashColor: Colors.white,
toggleableActiveColor: Colors.white, toggleableActiveColor: Colors.white,
textTheme: ThemeData.light().textTheme, unselectedWidgetColor: Colors.white,
primaryTextTheme: ThemeData.light().textTheme,
accentTextTheme: ThemeData.light().textTheme, // TYPOGRAPHY & ICONOGRAPHY
inputDecorationTheme: ThemeData.light().inputDecorationTheme.copyWith(border: InputBorder.none),
iconTheme: ThemeData.light().iconTheme, iconTheme: ThemeData.light().iconTheme,
primaryIconTheme: ThemeData.light().iconTheme, primaryIconTheme: ThemeData.light().iconTheme,
accentIconTheme: ThemeData.light().iconTheme, primaryTextTheme: ThemeData.light().textTheme,
sliderTheme: otherSliderTheme, textTheme: ThemeData.light().textTheme,
tabBarTheme: const TabBarTheme(labelColor: Colors.white), typography: Typography.material2018(platform: TargetPlatform.iOS),
tooltipTheme: const TooltipThemeData(height: 100),
expansionTileTheme: const ExpansionTileThemeData(backgroundColor: Colors.black), // COMPONENT THEMES
cardTheme: const CardTheme(color: Colors.white),
chipTheme: otherChipTheme,
platform: TargetPlatform.android,
materialTapTargetSize: MaterialTapTargetSize.padded,
applyElevationOverlayColor: true,
pageTransitionsTheme: const PageTransitionsTheme(),
appBarTheme: const AppBarTheme(backgroundColor: Colors.white), appBarTheme: const AppBarTheme(backgroundColor: Colors.white),
scrollbarTheme: const ScrollbarThemeData(radius: Radius.circular(10.0)), bannerTheme: const MaterialBannerThemeData(backgroundColor: Colors.white),
bottomAppBarTheme: const BottomAppBarTheme(color: Colors.white), bottomAppBarTheme: const BottomAppBarTheme(color: Colors.white),
colorScheme: const ColorScheme.light(), bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.shifting),
bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.white),
buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.end),
buttonTheme: const ButtonThemeData(colorScheme: ColorScheme.light()),
cardTheme: const CardTheme(color: Colors.white),
checkboxTheme: const CheckboxThemeData(),
chipTheme: otherChipTheme,
dataTableTheme: const DataTableThemeData(),
dialogTheme: const DialogTheme(backgroundColor: Colors.white), dialogTheme: const DialogTheme(backgroundColor: Colors.white),
dividerTheme: const DividerThemeData(color: Colors.white),
drawerTheme: const DrawerThemeData(),
elevatedButtonTheme: const ElevatedButtonThemeData(),
expansionTileTheme: const ExpansionTileThemeData(backgroundColor: Colors.black),
floatingActionButtonTheme: const FloatingActionButtonThemeData(backgroundColor: Colors.white), floatingActionButtonTheme: const FloatingActionButtonThemeData(backgroundColor: Colors.white),
listTileTheme: const ListTileThemeData(),
navigationBarTheme: const NavigationBarThemeData(backgroundColor: Colors.white), navigationBarTheme: const NavigationBarThemeData(backgroundColor: Colors.white),
navigationRailTheme: const NavigationRailThemeData(backgroundColor: Colors.white), navigationRailTheme: const NavigationRailThemeData(backgroundColor: Colors.white),
typography: Typography.material2018(platform: TargetPlatform.iOS),
cupertinoOverrideTheme: ThemeData.light().cupertinoOverrideTheme,
snackBarTheme: const SnackBarThemeData(backgroundColor: Colors.white),
bottomSheetTheme: const BottomSheetThemeData(backgroundColor: Colors.white),
popupMenuTheme: const PopupMenuThemeData(color: Colors.white),
bannerTheme: const MaterialBannerThemeData(backgroundColor: Colors.white),
dividerTheme: const DividerThemeData(color: Colors.white),
buttonBarTheme: const ButtonBarThemeData(alignment: MainAxisAlignment.end),
bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.shifting),
timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.white),
textButtonTheme: const TextButtonThemeData(),
elevatedButtonTheme: const ElevatedButtonThemeData(),
outlinedButtonTheme: const OutlinedButtonThemeData(), outlinedButtonTheme: const OutlinedButtonThemeData(),
textSelectionTheme: const TextSelectionThemeData(cursorColor: Colors.white), popupMenuTheme: const PopupMenuThemeData(color: Colors.white),
dataTableTheme: const DataTableThemeData(), progressIndicatorTheme: const ProgressIndicatorThemeData(),
checkboxTheme: const CheckboxThemeData(),
radioTheme: const RadioThemeData(), radioTheme: const RadioThemeData(),
sliderTheme: otherSliderTheme,
snackBarTheme: const SnackBarThemeData(backgroundColor: Colors.white),
switchTheme: const SwitchThemeData(), switchTheme: const SwitchThemeData(),
progressIndicatorTheme: const ProgressIndicatorThemeData(), tabBarTheme: const TabBarTheme(labelColor: Colors.white),
drawerTheme: const DrawerThemeData(), textButtonTheme: const TextButtonThemeData(),
listTileTheme: const ListTileThemeData(), textSelectionTheme: const TextSelectionThemeData(cursorColor: Colors.white),
timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.white),
toggleButtonsTheme: const ToggleButtonsThemeData(textStyle: TextStyle(color: Colors.white)),
tooltipTheme: const TooltipThemeData(height: 100),
// DEPRECATED (newest deprecations at the bottom)
accentColor: Colors.white,
accentColorBrightness: Brightness.light,
accentIconTheme: ThemeData.light().iconTheme,
accentTextTheme: ThemeData.light().textTheme,
buttonColor: Colors.white,
fixTextFieldOutlineLabel: true, fixTextFieldOutlineLabel: true,
primaryColorBrightness: Brightness.light,
androidOverscrollIndicator: AndroidOverscrollIndicator.stretch, androidOverscrollIndicator: AndroidOverscrollIndicator.stretch,
extensions: const <Object, ThemeExtension<dynamic>>{
MyThemeExtensionB: MyThemeExtensionB(textStyle: TextStyle()),
},
); );
final ThemeData themeDataCopy = theme.copyWith( final ThemeData themeDataCopy = theme.copyWith(
primaryColor: otherTheme.primaryColor, // For the sanity of the reader, make sure these properties are in the same
primaryColorBrightness: otherTheme.primaryColorBrightness, // order everywhere that they are separated by section comments (e.g.
primaryColorLight: otherTheme.primaryColorLight, // GENERAL CONFIGURATION). Each section except for deprecations should be
primaryColorDark: otherTheme.primaryColorDark, // alphabetical by symbol name.
canvasColor: otherTheme.canvasColor,
shadowColor: otherTheme.shadowColor, // GENERAL CONFIGURATION
scaffoldBackgroundColor: otherTheme.scaffoldBackgroundColor, applyElevationOverlayColor: otherTheme.applyElevationOverlayColor,
cupertinoOverrideTheme: otherTheme.cupertinoOverrideTheme,
extensions: otherTheme.extensions.values,
inputDecorationTheme: otherTheme.inputDecorationTheme,
materialTapTargetSize: otherTheme.materialTapTargetSize,
pageTransitionsTheme: otherTheme.pageTransitionsTheme,
platform: otherTheme.platform,
scrollbarTheme: otherTheme.scrollbarTheme,
splashFactory: otherTheme.splashFactory,
useMaterial3: otherTheme.useMaterial3,
visualDensity: otherTheme.visualDensity,
// COLOR
backgroundColor: otherTheme.backgroundColor,
bottomAppBarColor: otherTheme.bottomAppBarColor, bottomAppBarColor: otherTheme.bottomAppBarColor,
canvasColor: otherTheme.canvasColor,
cardColor: otherTheme.cardColor, cardColor: otherTheme.cardColor,
colorScheme: otherTheme.colorScheme,
dialogBackgroundColor: otherTheme.dialogBackgroundColor,
disabledColor: otherTheme.disabledColor,
dividerColor: otherTheme.dividerColor, dividerColor: otherTheme.dividerColor,
errorColor: otherTheme.errorColor,
focusColor: otherTheme.focusColor, focusColor: otherTheme.focusColor,
hoverColor: otherTheme.hoverColor,
highlightColor: otherTheme.highlightColor, highlightColor: otherTheme.highlightColor,
splashColor: otherTheme.splashColor,
splashFactory: otherTheme.splashFactory,
useMaterial3: otherTheme.useMaterial3,
selectedRowColor: otherTheme.selectedRowColor,
unselectedWidgetColor: otherTheme.unselectedWidgetColor,
disabledColor: otherTheme.disabledColor,
buttonTheme: otherTheme.buttonTheme,
toggleButtonsTheme: otherTheme.toggleButtonsTheme,
buttonColor: otherTheme.buttonColor,
secondaryHeaderColor: otherTheme.secondaryHeaderColor,
backgroundColor: otherTheme.backgroundColor,
dialogBackgroundColor: otherTheme.dialogBackgroundColor,
indicatorColor: otherTheme.indicatorColor,
hintColor: otherTheme.hintColor, hintColor: otherTheme.hintColor,
errorColor: otherTheme.errorColor, hoverColor: otherTheme.hoverColor,
indicatorColor: otherTheme.indicatorColor,
primaryColor: otherTheme.primaryColor,
primaryColorDark: otherTheme.primaryColorDark,
primaryColorLight: otherTheme.primaryColorLight,
scaffoldBackgroundColor: otherTheme.scaffoldBackgroundColor,
secondaryHeaderColor: otherTheme.secondaryHeaderColor,
selectedRowColor: otherTheme.selectedRowColor,
shadowColor: otherTheme.shadowColor,
splashColor: otherTheme.splashColor,
toggleableActiveColor: otherTheme.toggleableActiveColor, toggleableActiveColor: otherTheme.toggleableActiveColor,
textTheme: otherTheme.textTheme, unselectedWidgetColor: otherTheme.unselectedWidgetColor,
primaryTextTheme: otherTheme.primaryTextTheme,
inputDecorationTheme: otherTheme.inputDecorationTheme, // TYPOGRAPHY & ICONOGRAPHY
iconTheme: otherTheme.iconTheme, iconTheme: otherTheme.iconTheme,
primaryIconTheme: otherTheme.primaryIconTheme, primaryIconTheme: otherTheme.primaryIconTheme,
sliderTheme: otherTheme.sliderTheme, primaryTextTheme: otherTheme.primaryTextTheme,
tabBarTheme: otherTheme.tabBarTheme, textTheme: otherTheme.textTheme,
tooltipTheme: otherTheme.tooltipTheme, typography: otherTheme.typography,
expansionTileTheme: otherTheme.expansionTileTheme,
cardTheme: otherTheme.cardTheme, // COMPONENT THEMES
chipTheme: otherTheme.chipTheme,
platform: otherTheme.platform,
materialTapTargetSize: otherTheme.materialTapTargetSize,
applyElevationOverlayColor: otherTheme.applyElevationOverlayColor,
pageTransitionsTheme: otherTheme.pageTransitionsTheme,
appBarTheme: otherTheme.appBarTheme, appBarTheme: otherTheme.appBarTheme,
bannerTheme: otherTheme.bannerTheme,
bottomAppBarTheme: otherTheme.bottomAppBarTheme, bottomAppBarTheme: otherTheme.bottomAppBarTheme,
colorScheme: otherTheme.colorScheme, bottomNavigationBarTheme: otherTheme.bottomNavigationBarTheme,
bottomSheetTheme: otherTheme.bottomSheetTheme,
buttonBarTheme: otherTheme.buttonBarTheme,
buttonTheme: otherTheme.buttonTheme,
cardTheme: otherTheme.cardTheme,
checkboxTheme: otherTheme.checkboxTheme,
chipTheme: otherTheme.chipTheme,
dataTableTheme: otherTheme.dataTableTheme,
dialogTheme: otherTheme.dialogTheme, dialogTheme: otherTheme.dialogTheme,
dividerTheme: otherTheme.dividerTheme,
drawerTheme: otherTheme.drawerTheme,
elevatedButtonTheme: otherTheme.elevatedButtonTheme,
expansionTileTheme: otherTheme.expansionTileTheme,
floatingActionButtonTheme: otherTheme.floatingActionButtonTheme, floatingActionButtonTheme: otherTheme.floatingActionButtonTheme,
listTileTheme: otherTheme.listTileTheme,
navigationBarTheme: otherTheme.navigationBarTheme, navigationBarTheme: otherTheme.navigationBarTheme,
navigationRailTheme: otherTheme.navigationRailTheme, navigationRailTheme: otherTheme.navigationRailTheme,
typography: otherTheme.typography,
cupertinoOverrideTheme: otherTheme.cupertinoOverrideTheme,
snackBarTheme: otherTheme.snackBarTheme,
bottomSheetTheme: otherTheme.bottomSheetTheme,
popupMenuTheme: otherTheme.popupMenuTheme,
bannerTheme: otherTheme.bannerTheme,
dividerTheme: otherTheme.dividerTheme,
buttonBarTheme: otherTheme.buttonBarTheme,
bottomNavigationBarTheme: otherTheme.bottomNavigationBarTheme,
timePickerTheme: otherTheme.timePickerTheme,
textButtonTheme: otherTheme.textButtonTheme,
elevatedButtonTheme: otherTheme.elevatedButtonTheme,
outlinedButtonTheme: otherTheme.outlinedButtonTheme, outlinedButtonTheme: otherTheme.outlinedButtonTheme,
textSelectionTheme: otherTheme.textSelectionTheme, popupMenuTheme: otherTheme.popupMenuTheme,
dataTableTheme: otherTheme.dataTableTheme, progressIndicatorTheme: otherTheme.progressIndicatorTheme,
checkboxTheme: otherTheme.checkboxTheme,
radioTheme: otherTheme.radioTheme, radioTheme: otherTheme.radioTheme,
sliderTheme: otherTheme.sliderTheme,
snackBarTheme: otherTheme.snackBarTheme,
switchTheme: otherTheme.switchTheme, switchTheme: otherTheme.switchTheme,
progressIndicatorTheme: otherTheme.progressIndicatorTheme, tabBarTheme: otherTheme.tabBarTheme,
drawerTheme: otherTheme.drawerTheme, textButtonTheme: otherTheme.textButtonTheme,
listTileTheme: otherTheme.listTileTheme, textSelectionTheme: otherTheme.textSelectionTheme,
timePickerTheme: otherTheme.timePickerTheme,
toggleButtonsTheme: otherTheme.toggleButtonsTheme,
tooltipTheme: otherTheme.tooltipTheme,
// DEPRECATED (newest deprecations at the bottom)
accentColor: otherTheme.accentColor,
accentColorBrightness: otherTheme.accentColorBrightness,
accentIconTheme: otherTheme.accentIconTheme,
accentTextTheme: otherTheme.accentTextTheme,
buttonColor: otherTheme.buttonColor,
fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel,
extensions: otherTheme.extensions.values, primaryColorBrightness: otherTheme.primaryColorBrightness,
androidOverscrollIndicator: otherTheme.androidOverscrollIndicator,
); );
expect(themeDataCopy.brightness, equals(otherTheme.brightness)); // For the sanity of the reader, make sure these properties are in the same
expect(themeDataCopy.primaryColor, equals(otherTheme.primaryColor)); // order everywhere that they are separated by section comments (e.g.
expect(themeDataCopy.primaryColorBrightness, equals(otherTheme.primaryColorBrightness)); // GENERAL CONFIGURATION). Each section except for deprecations should be
expect(themeDataCopy.primaryColorLight, equals(otherTheme.primaryColorLight)); // alphabetical by symbol name.
expect(themeDataCopy.primaryColorDark, equals(otherTheme.primaryColorDark));
expect(themeDataCopy.canvasColor, equals(otherTheme.canvasColor)); // GENERAL CONFIGURATION
expect(themeDataCopy.shadowColor, equals(otherTheme.shadowColor)); expect(themeDataCopy.applyElevationOverlayColor, equals(otherTheme.applyElevationOverlayColor));
expect(themeDataCopy.scaffoldBackgroundColor, equals(otherTheme.scaffoldBackgroundColor)); expect(themeDataCopy.cupertinoOverrideTheme, equals(otherTheme.cupertinoOverrideTheme));
expect(themeDataCopy.extensions, equals(otherTheme.extensions));
expect(themeDataCopy.inputDecorationTheme, equals(otherTheme.inputDecorationTheme));
expect(themeDataCopy.materialTapTargetSize, equals(otherTheme.materialTapTargetSize));
expect(themeDataCopy.pageTransitionsTheme, equals(otherTheme.pageTransitionsTheme));
expect(themeDataCopy.platform, equals(otherTheme.platform));
expect(themeDataCopy.scrollbarTheme, equals(otherTheme.scrollbarTheme));
expect(themeDataCopy.splashFactory, equals(otherTheme.splashFactory));
expect(themeDataCopy.useMaterial3, equals(otherTheme.useMaterial3));
expect(themeDataCopy.visualDensity, equals(otherTheme.visualDensity));
// COLOR
expect(themeDataCopy.backgroundColor, equals(otherTheme.backgroundColor));
expect(themeDataCopy.bottomAppBarColor, equals(otherTheme.bottomAppBarColor)); expect(themeDataCopy.bottomAppBarColor, equals(otherTheme.bottomAppBarColor));
expect(themeDataCopy.canvasColor, equals(otherTheme.canvasColor));
expect(themeDataCopy.cardColor, equals(otherTheme.cardColor)); expect(themeDataCopy.cardColor, equals(otherTheme.cardColor));
expect(themeDataCopy.colorScheme, equals(otherTheme.colorScheme));
expect(themeDataCopy.dialogBackgroundColor, equals(otherTheme.dialogBackgroundColor));
expect(themeDataCopy.disabledColor, equals(otherTheme.disabledColor));
expect(themeDataCopy.dividerColor, equals(otherTheme.dividerColor)); expect(themeDataCopy.dividerColor, equals(otherTheme.dividerColor));
expect(themeDataCopy.errorColor, equals(otherTheme.errorColor));
expect(themeDataCopy.focusColor, equals(otherTheme.focusColor)); expect(themeDataCopy.focusColor, equals(otherTheme.focusColor));
expect(themeDataCopy.focusColor, equals(otherTheme.focusColor));
expect(themeDataCopy.hoverColor, equals(otherTheme.hoverColor));
expect(themeDataCopy.highlightColor, equals(otherTheme.highlightColor)); expect(themeDataCopy.highlightColor, equals(otherTheme.highlightColor));
expect(themeDataCopy.splashColor, equals(otherTheme.splashColor)); expect(themeDataCopy.hintColor, equals(otherTheme.hintColor));
expect(themeDataCopy.splashFactory, equals(otherTheme.splashFactory)); expect(themeDataCopy.hoverColor, equals(otherTheme.hoverColor));
expect(themeDataCopy.useMaterial3, equals(otherTheme.useMaterial3)); expect(themeDataCopy.indicatorColor, equals(otherTheme.indicatorColor));
expect(themeDataCopy.primaryColor, equals(otherTheme.primaryColor));
expect(themeDataCopy.primaryColorDark, equals(otherTheme.primaryColorDark));
expect(themeDataCopy.primaryColorLight, equals(otherTheme.primaryColorLight));
expect(themeDataCopy.scaffoldBackgroundColor, equals(otherTheme.scaffoldBackgroundColor));
expect(themeDataCopy.secondaryHeaderColor, equals(otherTheme.secondaryHeaderColor));
expect(themeDataCopy.selectedRowColor, equals(otherTheme.selectedRowColor)); expect(themeDataCopy.selectedRowColor, equals(otherTheme.selectedRowColor));
expect(themeDataCopy.shadowColor, equals(otherTheme.shadowColor));
expect(themeDataCopy.splashColor, equals(otherTheme.splashColor));
expect(themeDataCopy.toggleableActiveColor, equals(otherTheme.toggleableActiveColor));
expect(themeDataCopy.unselectedWidgetColor, equals(otherTheme.unselectedWidgetColor)); expect(themeDataCopy.unselectedWidgetColor, equals(otherTheme.unselectedWidgetColor));
expect(themeDataCopy.disabledColor, equals(otherTheme.disabledColor));
expect(themeDataCopy.buttonTheme, equals(otherTheme.buttonTheme)); // TYPOGRAPHY & ICONOGRAPHY
expect(themeDataCopy.toggleButtonsTheme, equals(otherTheme.toggleButtonsTheme)); expect(themeDataCopy.iconTheme, equals(otherTheme.iconTheme));
expect(themeDataCopy.buttonColor, equals(otherTheme.buttonColor)); expect(themeDataCopy.primaryIconTheme, equals(otherTheme.primaryIconTheme));
expect(themeDataCopy.secondaryHeaderColor, equals(otherTheme.secondaryHeaderColor));
expect(themeDataCopy.textSelectionTheme.selectionColor, equals(otherTheme.textSelectionTheme.selectionColor));
expect(themeDataCopy.textSelectionTheme.cursorColor, equals(otherTheme.textSelectionTheme.cursorColor));
expect(themeDataCopy.textSelectionTheme.selectionColor, equals(otherTheme.textSelectionTheme.selectionColor));
expect(themeDataCopy.textSelectionTheme.cursorColor, equals(otherTheme.textSelectionTheme.cursorColor));
expect(themeDataCopy.textSelectionTheme.selectionHandleColor, equals(otherTheme.textSelectionTheme.selectionHandleColor));
expect(themeDataCopy.backgroundColor, equals(otherTheme.backgroundColor));
expect(themeDataCopy.dialogBackgroundColor, equals(otherTheme.dialogBackgroundColor));
expect(themeDataCopy.indicatorColor, equals(otherTheme.indicatorColor));
expect(themeDataCopy.hintColor, equals(otherTheme.hintColor));
expect(themeDataCopy.errorColor, equals(otherTheme.errorColor));
expect(themeDataCopy.textTheme, equals(otherTheme.textTheme));
expect(themeDataCopy.primaryTextTheme, equals(otherTheme.primaryTextTheme)); expect(themeDataCopy.primaryTextTheme, equals(otherTheme.primaryTextTheme));
expect(themeDataCopy.sliderTheme, equals(otherTheme.sliderTheme)); expect(themeDataCopy.textTheme, equals(otherTheme.textTheme));
expect(themeDataCopy.tabBarTheme, equals(otherTheme.tabBarTheme)); expect(themeDataCopy.typography, equals(otherTheme.typography));
expect(themeDataCopy.tooltipTheme, equals(otherTheme.tooltipTheme));
expect(themeDataCopy.expansionTileTheme, equals(otherTheme.expansionTileTheme)); // COMPONENT THEMES
expect(themeDataCopy.cardTheme, equals(otherTheme.cardTheme));
expect(themeDataCopy.chipTheme, equals(otherTheme.chipTheme));
expect(themeDataCopy.platform, equals(otherTheme.platform));
expect(themeDataCopy.materialTapTargetSize, equals(otherTheme.materialTapTargetSize));
expect(themeDataCopy.applyElevationOverlayColor, equals(otherTheme.applyElevationOverlayColor));
expect(themeDataCopy.pageTransitionsTheme, equals(otherTheme.pageTransitionsTheme));
expect(themeDataCopy.appBarTheme, equals(otherTheme.appBarTheme)); expect(themeDataCopy.appBarTheme, equals(otherTheme.appBarTheme));
expect(themeDataCopy.bannerTheme, equals(otherTheme.bannerTheme));
expect(themeDataCopy.bottomAppBarTheme, equals(otherTheme.bottomAppBarTheme)); expect(themeDataCopy.bottomAppBarTheme, equals(otherTheme.bottomAppBarTheme));
expect(themeDataCopy.colorScheme, equals(otherTheme.colorScheme)); expect(themeDataCopy.bottomNavigationBarTheme, equals(otherTheme.bottomNavigationBarTheme));
expect(themeDataCopy.bottomSheetTheme, equals(otherTheme.bottomSheetTheme));
expect(themeDataCopy.buttonBarTheme, equals(otherTheme.buttonBarTheme));
expect(themeDataCopy.buttonTheme, equals(otherTheme.buttonTheme));
expect(themeDataCopy.cardTheme, equals(otherTheme.cardTheme));
expect(themeDataCopy.checkboxTheme, equals(otherTheme.checkboxTheme));
expect(themeDataCopy.chipTheme, equals(otherTheme.chipTheme));
expect(themeDataCopy.dataTableTheme, equals(otherTheme.dataTableTheme));
expect(themeDataCopy.dialogTheme, equals(otherTheme.dialogTheme)); expect(themeDataCopy.dialogTheme, equals(otherTheme.dialogTheme));
expect(themeDataCopy.dividerTheme, equals(otherTheme.dividerTheme));
expect(themeDataCopy.drawerTheme, equals(otherTheme.drawerTheme));
expect(themeDataCopy.elevatedButtonTheme, equals(otherTheme.elevatedButtonTheme));
expect(themeDataCopy.expansionTileTheme, equals(otherTheme.expansionTileTheme));
expect(themeDataCopy.floatingActionButtonTheme, equals(otherTheme.floatingActionButtonTheme)); expect(themeDataCopy.floatingActionButtonTheme, equals(otherTheme.floatingActionButtonTheme));
expect(themeDataCopy.listTileTheme, equals(otherTheme.listTileTheme));
expect(themeDataCopy.navigationBarTheme, equals(otherTheme.navigationBarTheme)); expect(themeDataCopy.navigationBarTheme, equals(otherTheme.navigationBarTheme));
expect(themeDataCopy.navigationRailTheme, equals(otherTheme.navigationRailTheme)); expect(themeDataCopy.navigationRailTheme, equals(otherTheme.navigationRailTheme));
expect(themeDataCopy.typography, equals(otherTheme.typography));
expect(themeDataCopy.cupertinoOverrideTheme, equals(otherTheme.cupertinoOverrideTheme));
expect(themeDataCopy.snackBarTheme, equals(otherTheme.snackBarTheme));
expect(themeDataCopy.bottomSheetTheme, equals(otherTheme.bottomSheetTheme));
expect(themeDataCopy.popupMenuTheme, equals(otherTheme.popupMenuTheme));
expect(themeDataCopy.bannerTheme, equals(otherTheme.bannerTheme));
expect(themeDataCopy.dividerTheme, equals(otherTheme.dividerTheme));
expect(themeDataCopy.buttonBarTheme, equals(otherTheme.buttonBarTheme));
expect(themeDataCopy.bottomNavigationBarTheme, equals(otherTheme.bottomNavigationBarTheme));
expect(themeDataCopy.timePickerTheme, equals(otherTheme.timePickerTheme));
expect(themeDataCopy.textButtonTheme, equals(otherTheme.textButtonTheme));
expect(themeDataCopy.elevatedButtonTheme, equals(otherTheme.elevatedButtonTheme));
expect(themeDataCopy.outlinedButtonTheme, equals(otherTheme.outlinedButtonTheme)); expect(themeDataCopy.outlinedButtonTheme, equals(otherTheme.outlinedButtonTheme));
expect(themeDataCopy.textSelectionTheme, equals(otherTheme.textSelectionTheme)); expect(themeDataCopy.popupMenuTheme, equals(otherTheme.popupMenuTheme));
expect(themeDataCopy.dataTableTheme, equals(otherTheme.dataTableTheme)); expect(themeDataCopy.progressIndicatorTheme, equals(otherTheme.progressIndicatorTheme));
expect(themeDataCopy.checkboxTheme, equals(otherTheme.checkboxTheme));
expect(themeDataCopy.radioTheme, equals(otherTheme.radioTheme)); expect(themeDataCopy.radioTheme, equals(otherTheme.radioTheme));
expect(themeDataCopy.sliderTheme, equals(otherTheme.sliderTheme));
expect(themeDataCopy.snackBarTheme, equals(otherTheme.snackBarTheme));
expect(themeDataCopy.switchTheme, equals(otherTheme.switchTheme)); expect(themeDataCopy.switchTheme, equals(otherTheme.switchTheme));
expect(themeDataCopy.progressIndicatorTheme, equals(otherTheme.progressIndicatorTheme)); expect(themeDataCopy.tabBarTheme, equals(otherTheme.tabBarTheme));
expect(themeDataCopy.drawerTheme, equals(otherTheme.drawerTheme)); expect(themeDataCopy.textButtonTheme, equals(otherTheme.textButtonTheme));
expect(themeDataCopy.listTileTheme, equals(otherTheme.listTileTheme)); expect(themeDataCopy.textSelectionTheme, equals(otherTheme.textSelectionTheme));
expect(themeDataCopy.textSelectionTheme.selectionColor, equals(otherTheme.textSelectionTheme.selectionColor));
expect(themeDataCopy.textSelectionTheme.cursorColor, equals(otherTheme.textSelectionTheme.cursorColor));
expect(themeDataCopy.textSelectionTheme.selectionColor, equals(otherTheme.textSelectionTheme.selectionColor));
expect(themeDataCopy.textSelectionTheme.cursorColor, equals(otherTheme.textSelectionTheme.cursorColor));
expect(themeDataCopy.textSelectionTheme.selectionHandleColor, equals(otherTheme.textSelectionTheme.selectionHandleColor));
expect(themeDataCopy.timePickerTheme, equals(otherTheme.timePickerTheme));
expect(themeDataCopy.toggleButtonsTheme, equals(otherTheme.toggleButtonsTheme));
expect(themeDataCopy.tooltipTheme, equals(otherTheme.tooltipTheme));
// DEPRECATED (newest deprecations at the bottom)
expect(themeDataCopy.accentColor, equals(otherTheme.accentColor));
expect(themeDataCopy.accentColorBrightness, equals(otherTheme.accentColorBrightness));
expect(themeDataCopy.accentIconTheme, equals(otherTheme.accentIconTheme));
expect(themeDataCopy.accentTextTheme, equals(otherTheme.accentTextTheme));
expect(themeDataCopy.buttonColor, equals(otherTheme.buttonColor));
expect(themeDataCopy.fixTextFieldOutlineLabel, equals(otherTheme.fixTextFieldOutlineLabel)); expect(themeDataCopy.fixTextFieldOutlineLabel, equals(otherTheme.fixTextFieldOutlineLabel));
expect(themeDataCopy.extensions, equals(otherTheme.extensions)); expect(themeDataCopy.primaryColorBrightness, equals(otherTheme.primaryColorBrightness));
expect(themeDataCopy.androidOverscrollIndicator, equals(otherTheme.androidOverscrollIndicator));
}); });
testWidgets('ThemeData.toString has less than 200 characters output', (WidgetTester tester) async { testWidgets('ThemeData.toString has less than 200 characters output', (WidgetTester tester) async {
......
...@@ -1697,7 +1697,7 @@ void main() { ...@@ -1697,7 +1697,7 @@ void main() {
final String messagesStr = messages.toString(); final String messagesStr = messages.toString();
expect(messagesStr.split('\n').length, equals(58)); expect(messagesStr.split('\n').length, equals(58));
expect(messagesStr, contains(RegExp(r' └─Child 1: FocusScopeNode#[a-f0-9]{5}\(parent1 \[PRIMARY FOCUS\]\)'))); expect(messagesStr, contains(RegExp(r' └─Child 1: FocusScopeNode#[a-f0-9]{5}\(parent1 \[PRIMARY FOCUS\]\)')));
expect(messagesStr, contains('FOCUS: Notifying 2 dirty nodes')); expect(messagesStr, contains('FOCUS: Notified 2 dirty nodes'));
expect(messagesStr, contains(RegExp(r'FOCUS: Scheduling update, current focus is null, next focus will be FocusScopeNode#.*parent1'))); expect(messagesStr, contains(RegExp(r'FOCUS: Scheduling update, current focus is null, next focus will be FocusScopeNode#.*parent1')));
}); });
} }
...@@ -1354,6 +1354,51 @@ void main() { ...@@ -1354,6 +1354,51 @@ void main() {
expect(invokedB, equals(1)); expect(invokedB, equals(1));
}); });
testWidgets('MaterialApp has a ShortcutRegistrar listening', (WidgetTester tester) async {
int invokedA = 0;
int invokedB = 0;
await tester.pumpWidget(
MaterialApp(
home: TestCallbackRegistration(
shortcuts: <ShortcutActivator, Intent>{
const SingleActivator(LogicalKeyboardKey.keyA): VoidCallbackIntent(() {
invokedA += 1;
}),
const SingleActivator(LogicalKeyboardKey.keyB): VoidCallbackIntent(() {
invokedB += 1;
}),
},
child: Actions(
actions: <Type, Action<Intent>>{
VoidCallbackIntent: VoidCallbackAction(),
},
child: const Focus(
autofocus: true,
child: Placeholder(),
),
),
),
),
);
await tester.pump();
await tester.sendKeyDownEvent(LogicalKeyboardKey.keyA);
await tester.pump();
expect(invokedA, equals(1));
expect(invokedB, equals(0));
await tester.sendKeyUpEvent(LogicalKeyboardKey.keyA);
expect(invokedA, equals(1));
expect(invokedB, equals(0));
invokedA = 0;
invokedB = 0;
await tester.sendKeyDownEvent(LogicalKeyboardKey.keyB);
expect(invokedA, equals(0));
expect(invokedB, equals(1));
await tester.sendKeyUpEvent(LogicalKeyboardKey.keyB);
expect(invokedA, equals(0));
expect(invokedB, equals(1));
});
testWidgets("doesn't override text field shortcuts", (WidgetTester tester) async { testWidgets("doesn't override text field shortcuts", (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
await tester.pumpWidget( await tester.pumpWidget(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment