responsive_x 0.1.1 copy "responsive_x: ^0.1.1" to clipboard
responsive_x: ^0.1.1 copied to clipboard

A simple Flutter package to handle responsiveness using extensions

GitHub Pub Version

ResponsiveX #

A simple Flutter package to handle responsiveness.


Overview #

The package consists of the followings:

  • SizeConfig - is the simple class that makes calculation for responsiveness.
  • Extensions - are functions to calculation dynamic height, width and font size.

Example #

First of all, you should initialize SizeConfig class using it's init method and giving the your design sizes (Height and Width given by your designer as screen size):

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (context, constraints) {
        return OrientationBuilder(
          builder: (context, orientation) {
            SizeConfig(
              designScreenWidth: 360,
              designScreenHeight: 640,
            ).init(constraints, orientation);

            return MaterialApp(
              title: 'Flutter Demo',
              theme: ThemeData(
                primarySwatch: Colors.blue,
                visualDensity: VisualDensity.adaptivePlatformDensity,
              ),
              home: MyHomePage(title: 'Flutter Demo Home Page'),
            );
          },
        );
      },
    );
  }
}

Then you can use extension methods to calculate height, width and font size dynamically:

Container(
  height: 100.height,
  width: 100.width,
  color: Colors.pink,
),

You can calculate font size as following:

Container(
  height: 100.height,
  width: 100.width,
  color: Colors.pink,
  child: Center(
    child: Text(
      'ResponsiveX',
      style: TextStyle(
        fontSize: 14.fontSize,
        color: Colors.white,
        ),
      ),
    ),
),

Dart Versions #

  • Dart 2: >= 2.7.0

Maintainers #

14
likes
40
pub points
0%
popularity

Publisher

unverified uploader

A simple Flutter package to handle responsiveness using extensions

Repository (GitHub)
View/report issues

License

BSD-2-Clause (license)

Dependencies

flutter

More

Packages that depend on responsive_x