apptomate_custom_sized_box 0.0.1 copy "apptomate_custom_sized_box: ^0.0.1" to clipboard
apptomate_custom_sized_box: ^0.0.1 copied to clipboard

An enhanced version of Flutter's `SizedBox` with additional sizing constraints, aspect ratio control, and debugging capabilities.

example/lib/main.dart

import 'package:apptomate_custom_sized_box/apptomate_custom_sized_box.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) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const CustomSizedBoxWidget(),
    );
  }
}

/// Demo widget showcasing the [CustomSizedBox] capabilities.
class CustomSizedBoxWidget extends StatelessWidget {
  const CustomSizedBoxWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Custom SizedBox'),
        centerTitle: true,
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            _buildDemoBox(
              title: 'Basic SizedBox',
              width: 200,
              height: 100,
              color: Colors.blue,
            ),
            _buildDemoBox(
              title: 'With Aspect Ratio (16:9)',
              aspectRatio: 16 / 9,
              color: Colors.green,
            ),
            _buildDemoBox(
              title: 'With Size Constraints',
              minWidth: 100,
              maxWidth: 300,
              minHeight: 50,
              color: Colors.orange,
              debugPaint: true,
            ),
            _buildDemoBox(
              title: 'Empty SizedBox (Spacer)',
              width: 50,
              height: 50,
              child: const SizedBox(),
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildDemoBox({
    required String title,
    double? width,
    double? height,
    double? aspectRatio,
    double? minWidth,
    double? maxWidth,
    double? minHeight,
    Color color = Colors.blue,
    bool debugPaint = false,
    Widget? child,
  }) {
    return Column(
      children: [
        Text(
          title,
          style: const TextStyle(
            fontSize: 14,
            fontWeight: FontWeight.bold,
            color: Colors.grey,
          ),
        ),
        const SizedBox(height: 8),
        CustomSizedBox(
          width: width,
          height: height,
          aspectRatio: aspectRatio,
          minWidth: minWidth,
          maxWidth: maxWidth,
          minHeight: minHeight,
          debugPaint: debugPaint,
          child: child ?? Container(
            color: color,
            child: Center(
              child: Text(
                title,
                style: const TextStyle(
                  color: Colors.white,
                  fontSize: 16,
                ),
              ),
            ),
          ),
        ),
      ],
    );
  }
}
0
likes
150
points
27
downloads

Publisher

unverified uploader

Weekly Downloads

An enhanced version of Flutter's `SizedBox` with additional sizing constraints, aspect ratio control, and debugging capabilities.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on apptomate_custom_sized_box