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

outdated

A Flutter widget that has pre-defined design for scaling, rotating, moving interaction.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:interactive_box/interactive_box.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(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: Stack(
        children: [
          ...List.generate(
            1,
            (index) => MyHomePage(
              title: 'Flutter Demo Home Page',
              i: index,
            ),
          )
        ],
      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({
    super.key,
    required this.title,
    required this.i,
  });

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;
  final int i;

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

class _MyHomePageState extends State<MyHomePage> {
  double xPosition = 100.0; // default should be 0
  double yPosition = 100.0; // default should be 0
  double width = 150;
  double height = 150;
  double maxWidth = 200;
  double maxHeight = 200;
  double rotate = 0;

  final ScrollController controller = ScrollController();

  @override
  void initState() {
    xPosition = xPosition + (widget.i * 10);
    yPosition = yPosition + (widget.i * 10);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return InteractiveBox(
      initialWidth: width,
      initialHeight: height,
      maxWidth: maxWidth,
      maxHeight: maxHeight,
      initialX: xPosition,
      initialY: yPosition,
      initialRotateAngle: rotate,
      includedActions: const [
        ControlActionType.copy,
        ControlActionType.rotate,
        ControlActionType.scale,
        ControlActionType.delete,
        // ControlActionType.delete,
        ControlActionType.move,
      ],
      // circularMenuSpreadMultiplier: 1,
      circularMenuDegree: 230,
      circularMenuIconColor: Colors.green,
      initialShowActionIcons: false,
      iconSize: 40,
      scaleDotColor: Colors.purple[600]!,
      overScaleDotColor: Colors.red[400]!,
      defaultScaleBorderDecoration: BoxDecoration(
        border: Border.all(
          width: 5,
          color: Colors.purple[700]!,
        ),
        shape: BoxShape.rectangle,
      ),
      overScaleBorderDecoration: BoxDecoration(
        border: Border.all(
          width: 5,
          color: Colors.red[700]!,
        ),
        shape: BoxShape.rectangle,
      ),

      onActionSelected: (ControlActionType action) {
        debugPrint("Select $action");
      },

      /// since this is more an example of how we can use [ControllableItem] widget,
      /// so we use magic string here.
      child: Image.asset(
        "assets/table.png",
        fit: BoxFit.fill,
      ),
    );
  }
}
21
likes
0
points
93
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter widget that has pre-defined design for scaling, rotating, moving interaction.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on interactive_box