Skip to content

A flutter extension based package which allows developers to access all flutter widgets and actions like navigation, mediaquery, snackbar etc from the current widget context

License

Notifications You must be signed in to change notification settings

abiodundotdev/contextual

Repository files navigation

Flutter Contexual

Access of flutter common context based widgets and properties using the context (BuildContext)

🎖 Installing

dependencies:
  contextual : ^1.0.0

⚡️ Import

import 'package:contextual/contextual.dart';

🎮 How To Use

import 'package:contextual/contextual.dart';
import 'package:flutter/material.dart';

 class App extends StatefulWidget {
  const App({super.key});

  @override
  State<App> createState() => _AppState();
}

class _AppState extends State<App> {
  @override
  Widget build(BuildContext context) {
    final screenSize = context.screenSize;
    final mediaQuery = context.mediaQuery;
    return Container();
  }
}

Widgets, properties and its corresponding contextual property

Property Equivalent Description
context.mediaQuery MediaQuery.of(context) Returns the mediaquerydata for nearest Mediaquery
context.size MediaQuery.of(context).size Returns the current screen size
context.theme Theme.of(context) Get the nearest theme
context.navigator Navigator.of(context) Returns the nearest Navigator
context.navigate.to(Widget page) Navigator.of(context).push Navigates to the page argument
context.showSnackBar(SnackBar snackBar) ScaffoldMessenger.of(this).showSnackBar() Show snackbar
context.scaffold Scaffold.of(context) Get the nearest Scaffold
context.overlay Overlay.of(context) || Navigator.of(context).overlay Get the nearest overlay
context.focus Focus.of(context) Get the nearest Focus widget FocusNode
context.overlay Overlay.of(context) || Navigator.of(context).overlay Get the nearest overlay
context.form Form.of(context) Get the nearest form widget
context.defaultTextStyle DefaultTextStyle.of(context) Get the nearest DefaultTextStyle

🐛 Bugs/Requests

If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket on Github and I'll look into it. Pull request are also welcome.

About

A flutter extension based package which allows developers to access all flutter widgets and actions like navigation, mediaquery, snackbar etc from the current widget context

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages