mk_sizer 1.0.1 copy "mk_sizer: ^1.0.1" to clipboard
mk_sizer: ^1.0.1 copied to clipboard

Adaptive Size helper created using concept of responsive_sizer and flutter_screen_util package.

MK Sizer #

MK Size helper created using concept of responsive_sizer and flutter_screen_util package.

Installation #



dependencies:
  mk_sizer: ^1.0.1

Usage #



Import the package #

import 'package:mk_sizer/mk_sizer.dart';

Wrap MaterialApp with MKSizer widget #



MKSizer( 
  builder: (context) {
    return MaterialApp(
      home: HomePage(),
    );
  },
);

Widget Size #



Container(
  width: 20.w,   
  height: 30.5.h     
)

Text Size #



Text(
  'MK Sizer', 
  style: TextStyle(fontSize: 15.sp), 
)

Gap #



Column(
  children: [
    Text('Above'),
    10.gap,
    Text('Below'),
  ],
)

10.gap is a responsive Gap-like widget: it detects whether its parent Flex is a Row or Column and scales with .w or .h accordingly, so the same call works in either direction.

Notes #


  • .w/.h/.sp/.r scale 1:1 until an MKSizer has laid out.
  • .sp scales by width only; .r uses the smaller of the width/height scales.
  • Default design size is 360x690; pass designSize: to change it.
  • Sizes are recalculated whenever the available size changes (rotation, window resize), and the whole subtree rebuilds so 10.w is correct everywhere, including const widgets.
  • For fewer rebuilds, pass rebuildOnChange: false and use the context form (context.w(20), context.h(30), context.sp(15)); each widget then rebuilds only when its own axis changes. 10.w is not tracked in that mode.
0
likes
150
points
--
downloads

Documentation

API reference

Publisher

verified publisherkishormainali.com

Weekly Downloads

Adaptive Size helper created using concept of responsive_sizer and flutter_screen_util package.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on mk_sizer