AutoScalable Container is a Flutter package that provides a dynamically resizable container. It automatically adjusts its height and width based on its content, with support for gradient colors and various customization options.

Features

  1. Dynamic Sizing: Adjusts container size based on content.
  2. Customizable Gradients: Set gradient colors for the container background.
  3. Flexible Customization: Configure padding, border radius, borders, and margins.
  4. Intrinsic Size Support: Ensures proper resizing with content.
  5. Adjustable Scaling Factors: Specify scaling factors for width and height adjustments.

Getting started

Installation : Add the following to your pubspec.yaml file:

dependencies:
autoscalable_container: ^0.0.1

Then Run :

flutter pub get

Usage

import 'package:flutter/material.dart';
import 'package:autoscalable_container/autoscalable_container.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('AutoScalable Container Example')),
        body: Center(
          child: AutoScalableContainer(
            gradient: LinearGradient(colors: [Colors.orange, Colors.red]),
            borderRadius: 15.0,
            border: Border.all(color: Colors.black, width: 2),
            padding: EdgeInsets.all(16),
            widthScalingFactor: 0.9,
            heightScalingFactor: 0.6,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                Text(
                  'This container adjusts its size based on the content.',
                  style: TextStyle(fontSize: 16, color: Colors.white),
                ),
                SizedBox(height: 10),
                Text(
                  'You can add more widgets inside.',
                  style: TextStyle(fontSize: 16, color: Colors.white),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

Attributes

  1. child
    Type: Widget
    Description: The widget to display inside the container. This is the main content of the container.
  2. gradient
    Type: Gradient?
    Description: The gradient colors to apply to the container's background. If not provided, a default gradient will be used.
  3. padding
    Type: EdgeInsetsGeometry
    Default: EdgeInsets.all(8.0)
    Description: Padding inside the container. Adjusts the space around the child widget.
  4. borderRadius
    Type: double
    Default: 10.0
    Description: Radius of the container's corners. Determines how rounded the corners of the container are.
  5. border
    Type: BoxBorder?
    Description: Border to apply around the container. Use this to customize the container's border style and color.
  6. margin
    Type: EdgeInsetsGeometry
    Default: EdgeInsets.all(8.0)
    Description: Margin around the container. Adjusts the space outside the container.
  7. widthScalingFactor
    Type: double
    Default: 0.95
    Description: Scaling factor for the width of the container. The width will be adjusted by this factor relative to the available width.
  8. heightScalingFactor
    Type: double
    Default: 0.50
    Description: Scaling factor for the height of the container. The height will be adjusted by this factor relative to the available height.