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

outdated

A package for making responsive UI for applications easy.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:size_config/size_config.dart';
import 'package:size_config/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(
            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(
                  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
142
downloads

Publisher

verified publishertechypanther.com

Weekly Downloads

A package for making responsive UI for applications easy.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on size_config