0 purchases
dynamic tools
Dynamic Tools #
Help with some things in flutter
Usage shortcuts with context #
There's no secret, just an extension to make it easier to get the theme, screen size, scope functions, among others...
Something like this is usually used within the build:
final theme = Theme.of(context);
copied to clipboard
This can be made easier by looking like this:
Example: #
class ThemeExample extends StatelessWidget {
const ThemeExample({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
color: context.colorScheme.background,
child: Center(
child: Text(
"Easy",
style: context.textTheme.bodyMedium,
),
),
);
}
}
copied to clipboard
Obviously it will only return correctly if you correctly fill in the theme in the Material App!
Something similar happens when getting the screen size:
final sizeScreen = MediaQuery.of(context).size;
final screenHeight = screen.height;
copied to clipboard
Example: #
class Example extends StatelessWidget {
const Example({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
height: context.screenHeight,
color: context.colorScheme.background,
child: Center(
child: Text(
"Easy",
style: context.textTheme.bodyMedium,
),
),
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.