contextions 0.2.0 copy "contextions: ^0.2.0" to clipboard
contextions: ^0.2.0 copied to clipboard

A Flutter package that adds extension methods on BuildContext for easy access to Navigator, Theme, and MediaQuery functions.

example/lib/main.dart

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

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Material App',
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  const Home({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Material App Bar'),
      ),
      body: Center(
        child: Column(
          children: [
            TextButton(
              onPressed: () {
                context.to(const ScreenTwo());
              },
              child: const Text('Go to Screen Two'),
            ),
            const SizedBox(
              height: 20,
            ),
            TextButton(
              onPressed: () {
                context.showSnackbar('Hello World');
              },
              child: const Text('Show Snackbar'),
            ),
            const SizedBox(
              height: 20,
            ),
          ],
        ),
      ),
    );
  }
}

class ScreenTwo extends StatelessWidget {
  const ScreenTwo({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Material App Bar'),
      ),
      body: Center(
        child: Column(
          children: [
            const Text('Hello World'),
            const SizedBox(
              height: 20,
            ),
            TextButton(
              onPressed: () {
                Navigator.pop(context);
              },
              child: const Text('Go Back'),
            ),
          ],
        ),
      ),
    );
  }
}
9
likes
150
points
25
downloads

Publisher

verified publishersamfan.dev

Weekly Downloads

A Flutter package that adds extension methods on BuildContext for easy access to Navigator, Theme, and MediaQuery functions.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on contextions