size_config 1.0.3 copy "size_config: ^1.0.3" to clipboard
size_config: ^1.0.3 copied to clipboard

Responsive UI is a must in today's world that does not break on any device size. We at Techy Panther tried to make responsive UI more easy to use for developers using this SizeConfig package.

example/lib/main.dart

import 'package:flutter/material.dart';
void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Size Config Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Size Config Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return SizeConfigInit(
      referenceHeight: 900,
      referenceWidth: 360,
      child: Scaffold(
          body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            // using .h and .w for responsive width and height
            Image.asset(
              "assets/image.png",
              height: 200.h,
              width: 200.w,
              scale: 0.5,
            ),
            // using .sp for responsive font size
            Text(
              "Login",
              style: TextStyle(fontSize: 22.sp),
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: TextFormField(
                decoration: InputDecoration(
                    hintStyle: TextStyle(fontSize: 12.sp),
                    constraints:
                        BoxConstraints(maxWidth: 200.w, maxHeight: 30.h),
                    hintText: "Enter Email"),
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: TextFormField(
                style: TextStyle(fontSize: 12.sp),
                obscureText: true,
                decoration: InputDecoration(
                    hintStyle: TextStyle(
                      fontSize: 12.sp,
                    ),
                    constraints:
                        BoxConstraints(maxWidth: 200.w, maxHeight: 30.h),
                    hintText: "Enter Password"),
              ),
            ),
            MaterialButton(
              onPressed: () {
                print("Logged in successfully");
              },
              height: 20.h,
              minWidth: 100.h,
            )
          ],
        ),
      )),
    );
  }
}
17
likes
120
points
142
downloads

Publisher

verified publishertechypanther.com

Weekly Downloads

Responsive UI is a must in today's world that does not break on any device size. We at Techy Panther tried to make responsive UI more easy to use for developers using this SizeConfig package.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on size_config