Last active
May 6, 2025 10:27
-
-
Save SashaKryzh/1aaff150e67d784e323dd4c9b1d0a8c7 to your computer and use it in GitHub Desktop.
Revisions
-
SashaKryzh revised this gist
Jun 9, 2023 . 1 changed file with 12 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,11 @@ import 'package:flutter/material.dart'; extension BuildContextExtensions on BuildContext { ThemeData get theme => Theme.of(this); TextTheme get textTheme => theme.textTheme; ColorScheme get colorScheme => theme.colorScheme; DefaultTextStyle get defaultTextStyle => DefaultTextStyle.of(this); @@ -19,14 +21,14 @@ extension BuildContextExtensions on BuildContext { } extension MaterialStateHelpers on Iterable<MaterialState> { bool get isHovered => contains(MaterialState.hovered); bool get isFocused => contains(MaterialState.focused); bool get isPressed => contains(MaterialState.pressed); bool get isDragged => contains(MaterialState.dragged); bool get isSelected => contains(MaterialState.selected); bool get isScrolledUnder => contains(MaterialState.scrolledUnder); bool get isDisabled => contains(MaterialState.disabled); bool get isError => contains(MaterialState.error); } extension IterableExtensions on Iterable { -
SashaKryzh created this gist
Jun 9, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ extension BuildContextExtensions on BuildContext { ThemeData get theme => Theme.of(this); TextTheme get textTheme => Theme.of(this).textTheme; ColorScheme get colorScheme => Theme.of(this).colorScheme; DefaultTextStyle get defaultTextStyle => DefaultTextStyle.of(this); MediaQueryData get mediaQuery => MediaQuery.of(this); NavigatorState get navigator => Navigator.of(this); FocusScopeNode get focusScope => FocusScope.of(this); ScaffoldState get scaffold => Scaffold.of(this); ScaffoldMessengerState get scaffoldMessenger => ScaffoldMessenger.of(this); } extension MaterialStateHelpers on Iterable<MaterialState> { bool get hasHovered => contains(MaterialState.hovered); bool get hasFocused => contains(MaterialState.focused); bool get hasPressed => contains(MaterialState.pressed); bool get hasDragged => contains(MaterialState.dragged); bool get hasSelected => contains(MaterialState.selected); bool get hasScrolledUnder => contains(MaterialState.scrolledUnder); bool get hasDisabled => contains(MaterialState.disabled); bool get hasError => contains(MaterialState.error); } extension IterableExtensions on Iterable { bool containsAny(Iterable<Object?> other) => other.any((e) => contains(e)); }