context_helpers 1.0.0 copy "context_helpers: ^1.0.0" to clipboard
context_helpers: ^1.0.0 copied to clipboard

Simplify Flutter development with context extensions — width, theme, navigation, localization, and responsive helpers.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:context_helpers/context_helpers.dart';
import 'package:flutter_localizations/flutter_localizations.dart';


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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Context Helpers Demo',
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: const [
        Locale('en', 'US'),
        Locale('hi', 'IN'),
      ],
      home: const HomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Width: ${context.width.toStringAsFixed(0)}')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text('Current locale: ${context.locale.languageCode.toUpperCase()}'),
            Text('Mode: ${context.isDarkMode ? 'Dark' : 'Light'}'),
            ElevatedButton(
              onPressed: () => context.showSnackBar('Hello from context!'),
              child: const Text('Show Snackbar'),
            ),
            ElevatedButton(
              onPressed: () => context.push(const SecondPage()),
              child: const Text('Go to Next Page'),
            ),
          ],
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Second Page')),
      body: Center(
        child: ElevatedButton(
          onPressed: () => context.pop(),
          child: const Text('Back'),
        ),
      ),
    );
  }
}
0
likes
130
points
--
downloads

Publisher

unverified uploader

Weekly Downloads

Simplify Flutter development with context extensions — width, theme, navigation, localization, and responsive helpers.

Repository (GitHub)
View/report issues

Topics

#context #extensions #utilities #navigation #responsive

Documentation

API reference

License

unknown (license)

Dependencies

flutter, flutter_localizations

More

Packages that depend on context_helpers