make_image_square
Tiny helper that turns any image size into a 1:1 layout plan: square canvas size plus left/right/top/bottom padding so you can fit without cropping.
Useful when you need the math for letterboxing / pillarboxing before you draw to a canvas, generate CSS object-fit-style boxes, or prep assets for Instagram and profile photos.
Install
dart pub add make_image_square
Usage
import 'package:make_image_square/make_image_square.dart';
// 1200×800 landscape → 1200×1200 with top/bottom pads
final layout = makeImageSquare(1200, 800);
// canvas 1200, padTop 200, padBottom 200
// Force a specific square edge (e.g. 1080 for feed posts)
final ig = makeImageSquare(1200, 800, canvasSize: 1080);
// Padding-only helper
final pads = squarePadding(800, 1200); // portrait → pad left/right
Modes
| Mode | Behavior |
|---|---|
fit (default) |
Entire image visible; empty bands become padding |
fill |
Image covers the square; caller is expected to crop overflow |
Notes
- This package only returns numbers. It does not decode or rewrite image files.
- Prefer not to wire up
dart:uiyourself? There is an in-browser padder for 1:1 posts that can letterbox, blur the frame, or crop without a Flutter project.
License
MIT
Libraries
- make_image_square
- Layout math for fitting an image into a 1:1 canvas.