📐 SizeConfig
A simple, lightweight, and clean responsive size & typography helper for Flutter.
SizeConfig helps you scale fonts, spacing, and UI elements consistently across small phones, large devices, and tablets — with one-time initialization and clean extension syntax like 16.sp.
✨ Features
- 📱 Responsive font scaling
- 📏 Consistent padding & spacing
- 🧠 Device detection (small device / tablet)
- ⚡ One-time initialization
- 🧩 Clean extensions (
.sp,.title,.scale) - 🚫 No repeated
MediaQuerycalls - 🌍 Works on Android, iOS, Web & Desktop
🚀 Installation
Add the package to your pubspec.yaml:
dependencies:
size_config: ^1.0.0
Then run:
flutter pub get
⚙️ Initialization (Required)
Initialize once at the root of your app (recommended in main.dart):
import 'package:flutter/material.dart';
import 'package:size_config/size_config.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
// 🔥 Initialize SizeConfig once
SizeConfig.init(context);
return MaterialApp(
home: const HomeScreen(),
);
}
}
⚠️ Do not call SizeConfig.init() inside every widget ✅ Call it only once at app startup
🧑💻 Usage
- Responsive Text Text( 'Hello', style: TextStyle(fontSize: 16.sp), );
- Titles Text( 'Dashboard', style: TextStyle( fontSize: 20.title, fontWeight: FontWeight.bold, ), );
- Spacing & Layout Scaling
SizedBox(height: 24.scale);
Padding( padding: EdgeInsets.all(16.scale), child: Text('Responsive padding'), );
Container( width: 120.scale, height: 60.scale, );