A custom Flutter widget that provides advanced layout options including padding, margin, decoration, alignment, and relative sizing based on screen dimensions.
- Automatic Size Adjustments: Eliminates the need for using MediaQuery in the parent widget, simplifying the code.
- Responsive Sizing: Automatically adjusts the width and height of the container based on the screen size, using widthFactor and heightFactor.
- Custom Padding and Margin: Easily apply padding and margin to the container with the padding and margin properties.
- Decorations: Apply custom decorations such as background color, border, and border radius using the decoration property.
- Alignment: Align the child widget within the container using the alignment property.
- Flexible Child Widget: Supports any child widget, making it versatile for various use cases.
dependencies:
advanced_container:
git:
url: https://github.com/shaaradnj/advanced_container.git
ref: main
flutter pub get
import 'package:flutter/material.dart';
import 'package:advanced_container/advanced_container.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Advanced Container Example')),
body: Center(
child: AdvancedContainer(
widthFactor: 0.5,
heightFactor: 0.3,
padding: EdgeInsets.all(20),
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(10),
),
alignment: Alignment.center,
child: Text('Hello, World!', style: TextStyle(color: Colors.white)),
),
),
),
);
}
}
Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request.