blueprint_system 0.0.2 copy "blueprint_system: ^0.0.2" to clipboard
blueprint_system: ^0.0.2 copied to clipboard

outdated

A flutter library that creates blueprint widgets with nodes (child widgets) that may be added to them. These nodes can be moved, resized, and modified.

example/lib/main.dart

import 'package:blueprint_system/blueprint.dart';
import 'package:blueprint_system/blueprint_controller.dart';
import 'package:blueprint_system/widgets/draggable_node/draggable_node.dart';
import 'package:blueprint_system/widgets/fixed_node/fixed_node.dart';
import 'package:blueprint_system/widgets/node/node_controller.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Blueprint Example',
      home: MyHomePage(title: 'Blueprint Example'),
      debugShowCheckedModeBanner: false,
    );
  }
}

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  BlueprintController controller = BlueprintController();

  bool _snapToGrid = false;
  bool _showGrid = true;

  snapToGrid(bool value) => setState(() {
        _snapToGrid = value;
        controller.snapToGrid = value;
      });

  showGrid() => setState(() {
        _showGrid = !_showGrid;
        controller.showGrid = _showGrid;
      });

  @override
  void initState() {
    controller.addNodes([
      FixedNode(child: node),
      DraggableNode(
        initPosition: const Offset(1200, 1200),
        initSize: const Size(200, 100),
        child: node,
      ),
      DraggableNode(
        initPosition: const Offset(50, 300),
        initSize: const Size(100, 200),
        child: node,
      ),
    ]);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        actions: [
          Switch(
            value: _snapToGrid,
            onChanged: snapToGrid,
          ),
          IconButton(
            onPressed: showGrid,
            icon: Icon(
              _showGrid ? Icons.grid_off_outlined : Icons.grid_on_outlined,
            ),
          ),
        ],
      ),
      body: Row(
        children: [
          // SizedBox(width: MediaQuery.of(context).size.width * 0.3),
          Blueprint(controller),
          // SizedBox(width: MediaQuery.of(context).size.width * 0.3),
        ],
      ),
    );
  }

  Widget node(NodeController controller) {
    var pos = controller.position;
    return Container(
      color: Colors.red,
      child:
          Text("[${pos.dx.toStringAsFixed(2)}, ${pos.dy.toStringAsFixed(2)}]"),
    );
  }
}
11
likes
0
points
35
downloads

Publisher

unverified uploader

Weekly Downloads

A flutter library that creates blueprint widgets with nodes (child widgets) that may be added to them. These nodes can be moved, resized, and modified.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, get, uuid, vector_math

More

Packages that depend on blueprint_system