context_extensions 0.0.1+1 copy "context_extensions: ^0.0.1+1" to clipboard
context_extensions: ^0.0.1+1 copied to clipboard

outdated

variuos extentions on build context to accsess inherated widgets data

context_extentions #

variuos extensions on BuildContext to accsess inherated widgets state

Accessing inherited widget's state #

using the of helper method in inherited widgets:

var themeData = Theme.of(context);

 var scaffold = Scaffold.of(context);
 
 var navigator = Navigator.of(context);
 
 var overlay = Overlay.of(context);

Only using context:

var themeData = context.dependOnInheritedWidgetOfExactType<_InheritedTheme>();

 var scaffold = context.dependOnInheritedWidgetOfExactType<ScaffoldState>();
 
 var navigator = context.dependOnInheritedWidgetOfExactType<NavigatorState>();
 
 var overlay = context.dependOnInheritedWidgetOfExactType<OverlayState>();

Using context_extensions (if you really hate parenthesis):

 var themeData = context.theme;

 var scaffold = context.scaffold;
 
 var navigator = context.navigator;
 
 var overlay = context.overlay;

Helper getter #

var colorPrimary = context.primaryColor;

var colorAccent = context.accentColor;

var colorCanvas = context.canvasColor;

var colorBackground = context.BackgroundColor;

Helper methods #


context.push((c) => NaxtPage());


context.pop();


context.showSnackbar(SnackBar(content: Text('text')));

4
likes
0
pub points
26%
popularity

Publisher

verified publisheraligator.ir

variuos extentions on build context to accsess inherated widgets data

Homepage

Dependencies

flutter

More

Packages that depend on context_extensions