0 purchases
contextions
Contextions #
Contextions is a Flutter package which makes use of extension methods on BuildContext to easily access Navigator functions, theme functions, and other BuildContext-based functions. This package enhances convenience and readability in Flutter app development.
Features #
Navigation #
Easily navigate to new pages and manage navigation stack:
context.to(YourPage());
context.navigateAndReplace(YourPage());
context.pop();
copied to clipboard
Theme and MediaQuery #
Access theme data and media query properties directly from BuildContext:
ThemeData theme = context.theme;
TextTheme textTheme = context.textTheme;
Size screenSize = context.screenSize;
double screenHeight = context.screenHeight;
double screenWidth = context.screenWidth;
copied to clipboard
Snackbar #
Show snackbar messages with a single line of code:
context.showSnackbar('Message');
copied to clipboard
Dialog #
Display dialogs with custom content and actions:
context.showDialogX(
AlertDialog(
title: Text('Dialog Title'),
content: Text('Dialog Content'),
actions: [
TextButton(
onPressed: () => context.pop(),
child: Text('OK'),
),
],
),
);
copied to clipboard
Drawer #
Open and close the drawer:
context.openDrawer();
context.closeDrawer();
copied to clipboard
Modal Bottom Sheet #
Show a modal bottom sheet:
context.showModalBottomSheetX(
Container(
child: Text('Bottom Sheet Content'),
),
);
copied to clipboard
Bottom Sheet #
Show a customizable bottom sheet:
context.showBottomSheetX(
builder: (BuildContext context) => Container(
child: Text('Custom Bottom Sheet Content'),
),
);
copied to clipboard
Search #
Show a search interface:
context.showSearchX(
delegate: CustomSearchDelegate(),
);
copied to clipboard
Dialog with Custom Content and Actions #
Show a dialog with custom content and actions:
context.showDialogXY(
title: 'Custom Dialog Title',
content: 'Custom Dialog Content',
actions: [
TextButton(
onPressed: () => context.pop(),
child: Text('OK'),
),
],
);
copied to clipboard
Keyboard Visibility #
Check if the keyboard is visible:
bool isKeyboardVisible = context.isKeyboardVisible;
copied to clipboard
Screen Orientation #
Check if the screen is in landscape or portrait mode:
bool isLandscape = context.isLandscape;
bool isPortrait = context.isPortrait;
copied to clipboard
Example #
Here's a basic example demonstrating the usage of contextions:
import 'package:flutter/material.dart';
import 'package:contextions/context_extensions.dart';
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Context Extensions Example'),
),
body: Center(
child: ElevatedButton(
onPressed: () {
context.showSnackbar('Hello from Context Extensions!');
},
child: Text('Show Snackbar'),
),
),
);
}
}
void main() {
runApp(MaterialApp(
home: MyWidget(),
));
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.