el_responsive 0.0.2 copy "el_responsive: ^0.0.2" to clipboard
el_responsive: ^0.0.2 copied to clipboard

MediaQuery alternative that triggers rebuild only at the breakpoints that you provided to the package instead of triggering it on every screen change (pixel by pixel)

example/example.dart

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

void main() {
  runApp(
    const MyApp(),
  );
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        useMaterial3: true,
      ),
      home: ElResponsiveContainer(
        screens: [
          ElScreen(name: "mobile", breakpoint: 480),
          ElScreen(name: "tablet", breakpoint: 768),
          ElScreen(name: "desktop", breakpoint: 1024),
        ],
        child: const MyHomePage(),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    debugPrint("ChildScreen got build");

    final String screenType = ElResponsive.of(context)!.screen as String;

    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text("Widget title"),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          screenType == "mobile"
              ? const Icon(Icons.phone_android)
              : screenType == "tablet"
                  ? const Icon(Icons.tablet_android)
                  : const Icon(Icons.desktop_windows),
          const SizedBox(height: 24.0),
          Text(
            '$screenType Screen',
            style: Theme.of(context).textTheme.headlineMedium,
          ),
        ],
      ),
    );
  }
}
4
likes
140
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

MediaQuery alternative that triggers rebuild only at the breakpoints that you provided to the package instead of triggering it on every screen change (pixel by pixel)

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

flutter

More

Packages that depend on el_responsive