ContextExtensions extension

Useful extensions on BuildContext for responsive design, theme, and navigation.

on

Properties

colorScheme → ColorScheme

Available on BuildContext, provided by the ContextExtensions extension

Returns the current ColorScheme.
no setter
height → double

Available on BuildContext, provided by the ContextExtensions extension

Returns the screen height.
no setter
isDarkMode → bool

Available on BuildContext, provided by the ContextExtensions extension

Returns true if the active theme is dark mode.
no setter
isKeyboardOpen → bool

Available on BuildContext, provided by the ContextExtensions extension

Returns true if the keyboard is open.
no setter
isLandscape → bool

Available on BuildContext, provided by the ContextExtensions extension

Returns true if the device is in landscape mode.
no setter
isLightMode → bool

Available on BuildContext, provided by the ContextExtensions extension

Returns true if the active theme is light mode.
no setter
isPortrait → bool

Available on BuildContext, provided by the ContextExtensions extension

Returns true if the device is in portrait mode.
no setter
keyboardHeight → double

Available on BuildContext, provided by the ContextExtensions extension

Returns the bottom view inset (keyboard height).
no setter
mediaQuery → MediaQueryData

Available on BuildContext, provided by the ContextExtensions extension

Returns the screen MediaQueryData.
no setter
orientation → Orientation

Available on BuildContext, provided by the ContextExtensions extension

Returns the current orientation.
no setter
pixelRatio → double

Available on BuildContext, provided by the ContextExtensions extension

Returns the device pixel ratio.
no setter
primaryColor → Color

Available on BuildContext, provided by the ContextExtensions extension

Returns the primary color of current theme.
no setter
scaffoldBackgroundColor → Color

Available on BuildContext, provided by the ContextExtensions extension

Returns the scaffold background color.
no setter
screenSize → Size

Available on BuildContext, provided by the ContextExtensions extension

Returns the screen Size.
no setter
textTheme → TextTheme

Available on BuildContext, provided by the ContextExtensions extension

Returns the current TextTheme.
no setter
theme → ThemeData

Available on BuildContext, provided by the ContextExtensions extension

Returns the current ThemeData.
no setter
viewInsets → EdgeInsets

Available on BuildContext, provided by the ContextExtensions extension

Returns the view insets (e.g. keyboard height).
no setter
viewPadding → EdgeInsets

Available on BuildContext, provided by the ContextExtensions extension

Returns the view padding (e.g. status bar / notches).
no setter
width → double

Available on BuildContext, provided by the ContextExtensions extension

Returns the screen width.
no setter

Methods

canPop() → bool

Available on BuildContext, provided by the ContextExtensions extension

Whether the navigator can be popped.
hideKeyboard() → void

Available on BuildContext, provided by the ContextExtensions extension

Unfocuses current focus node and hides soft keyboard.
pop<T extends Object?>([T? result]) → void

Available on BuildContext, provided by the ContextExtensions extension

Pops the top-most route off the navigator.
push<T extends Object?>(Widget page) → Future<T?>

Available on BuildContext, provided by the ContextExtensions extension

Pushes a new route onto the navigator.
pushNamed<T extends Object?>(String routeName, {Object? arguments}) → Future<T?>

Available on BuildContext, provided by the ContextExtensions extension

Pushes a named route onto the navigator.
pushReplacement<T extends Object?, TO extends Object?>(Widget page, {TO? result}) → Future<T?>

Available on BuildContext, provided by the ContextExtensions extension

Pushes a replacement route onto the navigator.
showSnackBar(SnackBar snackBar) → ScaffoldFeatureController<SnackBar, SnackBarClosedReason>

Available on BuildContext, provided by the ContextExtensions extension

Shows a SnackBar with the given snackBar.
showSnackBarText(String message, {Duration duration = const Duration(seconds: 3), Color? backgroundColor, SnackBarAction? action}) → ScaffoldFeatureController<SnackBar, SnackBarClosedReason>

Available on BuildContext, provided by the ContextExtensions extension

Quick shortcut to show a text SnackBar.