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

outdated

Responsive UI is a must in today's world. We have devices of several sizes, like smart phones and tablets which differ in sizes and there we require a responsive UI which changes it's size based on si [...]

example/lib/main.dart

import 'package:flutter/material.dart';
import 'size_config.dart';
import '/util/size_extention.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 Scaffold(
      body: LayoutBuilder(builder: (context, constraint) {
        SizeConfig().init(
            minFontSize: 30,
            context: context,
            safeAreaBox: constraint,
            referenceHeight: 800,
            referenceWidth: 360
        );
        return 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
0
points
139
downloads

Publisher

verified publishertechypanther.com

Weekly Downloads

Responsive UI is a must in today's world. We have devices of several sizes, like smart phones and tablets which differ in sizes and there we require a responsive UI which changes it's size based on size of device. Also using flutter we can build web and desktop applications too along with mobile applications which also requires the UI to be responsive based on different screen sizes.So we at Techy Panther tried to make responsive UI more easy to use for developers using this SizeConfig package.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on size_config