Skip to content

Errechydy/el_responsive

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ElResponsive

Flutter package for Responsive Layout. MediaQuery alternative that triggers rebuild only when the screen type changes, You set list of the screens for the package and the rebuild get trigges only when certain breakpoint of the screens reached instead of triggering it on every screen change (pixel by pixel)

Usage

  1. Add the latest version of package to your pubspec.yaml (and rundart pub get):
dependencies:
  el_responsive: ^0.0.1
  1. Import the package and use it in your Flutter App.
import 'package:el_responsive/el_responsive.dart';

How to use

  1. Add ElResponsiveContainer widget to top level of your app, and specify list of screens List<ElScreen> you want to listen to. ElScreen has name and breakpoint value
  • name can be any type, example:
  • breakpoint is of type int
ElResponsiveContainer(
  screens: [
    ElScreen(name: "mobile", breakpoint: 480),
    ElScreen(name: "tablet", breakpoint: 768),
    ElScreen(name: "desktop", breakpoint: 1024),
  ],
  child: const MyHomePage(),
),
  1. Listen to ElResponsive inside build method the same way you use MediaQuery Notice that we casted ElResponsive.of(context)!.screen to String in this example because the type of the name we gave to ElScreen is String
  @override
  Widget build(BuildContext context) {
    final String screenType = ElResponsive.of(context)!.screen as String;

    return .......

This widget now will get rebuilt only when the screen type we provided changes instead of rebuilding on every single pixel change when using MediaQuery.

Examples

  • Checkout the full exmaple that uses screen's name as String in here
  • the full example that uses screen's name as enum in here

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages