Absolute Sizer
Make your Flutter apps truly responsive with ease!
Absolute Sizer is a lightweight and dynamic Flutter package that calculates widget's height and width based on the screen size dynamically, ensuring your app looks great on all devices.
🚀 Features
- Dynamic Responsiveness: Automatically adjusts widgets' height and width to fit any screen.
- Lightweight: Minimal performance overhead.
- Simple and Intuitive: Easy-to-use API for seamless integration.
- Customizable: Tailor your design to fit unique needs while maintaining responsiveness.
Getting started
At first Add dependency
To use absolute_sizer, add the following line to your pubspec.yaml file:
dependencies:
absolute_sizer: ^0.0.1
Usage
Then import
import 'package:absolute_sizer/absolute_sizer.dart';
Then use this code
import 'package:absolute_sizer/absolute_sizer.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
AppSizes().init(context);
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a purple toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: Home(),
);
}
}
class Home extends StatelessWidget{
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
body: Center(
child: Container(
height: getHeight(20),
width: getWidth(20),
color: Colors.blue,
),
),
);
}
}
Additional information
Customization
The absolute_sizer package is designed to make your design highly customizable and responsive.
Compatibility
This package is compatible with Flutter apps targeting both Android and iOS platforms. It has been tested on multiple devices and screen sizes to ensure a smooth user experience. The package is also optimized for performance, making it suitable for apps with large date ranges.
Installation
To use the absolute_sizer, add the following to your pubspec.yaml:
dependencies:
absolute_sizer: ^0.0.1