Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

sizer

sizer is helps you to create responsive ui easily.

a flutter plugin for easily make flutter apps responsive. automatically adapt ui to different screen sizes. responsiveness made simple.

alt text

alt text

content

existing user

hello existing users, i have updated the package for supporting flutter 2.0 and solving many bugs then whenever you update 1.x.x to 2.x.x will be got many errors so please update the package with the new below code.

installation ⬇️

add to pubspec.yaml.

dependencies:
  ...
  sizer: ^2.0.14

parameters ⚙️

  • .h – returns a calculated height based on the device
  • .w – returns a calculated width based on the device
  • .sp – returns a calculated sp based on the device
  • sizerutil.orientation – for screen orientation portrait or landscape
  • sizerutil.devicetype – for device type mobile or tablet

usage ��

add the following imports to your dart code:

import 'package:sizer/sizer.dart';

wrap materialapp with responsivesizer widget

responsivesizer(
      builder: (context, orientation, devicetype) {
        return materialapp();
      }
 )

whenever you use height and width first import sizer package.

import 'package:sizer/sizer.dart';

widget size ��

    container(
      width: 20.w,    //it will take a 20% of screen width
      height:30.h     //it will take a 30% of screen height
    )

padding ⏹

    padding(
      padding: edgeinsets.symmetric(vertical: 5.h, horizontal: 3.h),
      child: container(),
    );

font size ��

    text(
      'sizer',style: textstyle(fontsize: 15.sp),
    );

square widget ��

if you want to make square size widget then give height or width in both height and width.

    container(
            width: 30.h,      //it will take a 30% of screen height
            height: 30.h,     //it will take a 30% of screen height
    );

orientation ��

if you want to support both portrait and landscape orientations

device.orientation == orientation.portrait
  ? container(   // widget for portrait
      width: 100.w,
      height: 20.5.h,
   )
  : container(   // widget for landscape
      width: 100.w,
      height: 12.5.h,
   )

devicetype ��

if you want the same layout to look different in tablet and mobile, use the sizerutil.devicetype method:

sizerutil.devicetype == devicetype.mobile
  ? container(   // widget for mobile
      width: 100.w,
      height: 20.5.h,
   )
  : container(   // widget for tablet
      width: 100.w,
      height: 12.5.h,
   )

suggestion

orientation

if you want to give support for both portrait and landscape then make separate widget for both like orientation example.

devicetype

if you want to give support for both mobile and tablet then make separate widget for both like devicetype example.

note

you need to import sizer package in order to access number.h, number.w, and number.sp

auto import in vscode and android studio doesn’t work for dart extension methods. typing 10.h would not bring up auto import suggestion for this package

one workaround is to type device so that the auto import suggestion would show up:

import 'package:sizer/sizer.dart';

issue and feedback ��

if you have any suggestion for including a feature or if something doesn’t work, feel free to open a github issue for us to have a discussion on it.


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.