flutter_box_transform 0.4.6 copy "flutter_box_transform: ^0.4.6" to clipboard
flutter_box_transform: ^0.4.6 copied to clipboard

A Flutter implementation of box_transform package that provides easy 2D box transform operations with advanced resizing of rect in UI.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Box Transform Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Colors.deepPurple,
          brightness: Brightness.dark,
        ),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late Rect rect = Rect.fromCenter(
    center: MediaQuery.of(context).size.center(Offset.zero),
    width: 400,
    height: 300,
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Stack(
        fit: StackFit.expand,
        children: [
          TransformableBox(
            rect: rect,
            clampingRect: Offset.zero & MediaQuery.sizeOf(context),
            onChanged: (result, event) {
              setState(() {
                rect = result.rect;
              });
            },
            contentBuilder: (context, rect, flip) {
              return DecoratedBox(
                decoration: BoxDecoration(
                  border: Border.all(
                    color: Theme.of(context).colorScheme.primary,
                  ),
                  image: const DecorationImage(
                    image: AssetImage('assets/image1.png'),
                    fit: BoxFit.fill,
                  ),
                ),
              );
            },
          ),
        ],
      ),
    );
  }
}
93
likes
150
pub points
92%
popularity

Publisher

verified publisherhyperdesigned.dev

A Flutter implementation of box_transform package that provides easy 2D box transform operations with advanced resizing of rect in UI.

Repository (GitHub)
View/report issues
Contributing

Topics

#rectangle #box #transform #utility #flutter

Documentation

Documentation
API reference

License

Apache-2.0 (license)

Dependencies

box_transform, flutter, vector_math

More

Packages that depend on flutter_box_transform