パッケージ、リポジトリ、アプリカテゴリを検索

infinite_canvas のカバー
パッケージ詳細v0.0.10

infinite_canvas

InteractiveViewer および CustomMultiChildLayout をベースにした、Flutter 向けの拡張可能な無限キャンバスで、ウィジェットを子要素として使用し、移動または選択できます。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
395
いいね数
82
Pub ポイント
140

パッケージをインストール

flutter pub add infinite_canvas

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Infinite Canvas は、InteractiveViewer および CustomMultiChildLayout をベースにした拡張可能でインタラクティブな無限キャンバスを提供する Flutter パッケージです。開発者は任意のウィジェットを子要素として配置でき、パン、ズーム、選択によって操作できます。描画、ペイント、署名アプリに最適で、無制限のワークスペース上でコンテンツを動的に配置できます。このキャンバスはプラットフォーム間でスムーズに適応し、Android、iOS、Web、macOS、Windows、Linux で一貫した動作を提供します。

用途

  • デジタルホワイトボード
  • インタラクティブアート制作
  • 署名のキャプチャ
  • 共同設計ツール
  • 教育的図解
  • ドキュメントの注釈

主な機能

  • 任意のウィジェットを子としてサポート
  • InteractiveViewer を使用したパンとズーム
  • カスタム可能なレイアウトと CustomMultiChildLayout
  • 選択可能で移動可能な子要素
  • クロスプラットフォーム互換性
  • カスタムインタラクション用の拡張可能なアーキテクチャ

適している対象

  • 描画およびスケッチアプリ
  • インタラクティブな教育ソフトウェア
  • デザインコラボレーションツール
  • ドキュメント注釈システム
  • クリエイティブコーディングプロジェクト

注意事項

  • 多くの子ウィジェットがあるとパフォーマンスが低下する可能性があります
  • ウィジェットの状態を慎重に管理する必要があります
  • 高頻度のリアルタイム更新には最適化されていません
  • パン/ズーム以外の組み込みジェスチャー対応は限定的
  • 複雑な選択動作に対応するための追加ロジックが必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Infinite Canvas

infinite_canvas

Flutter infinite canvas that can be zoomed and panned.

There is also a menu for common actions and marquee for multiple selection.

Example

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

void main() => runApp(const MyApp());

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: const Example(),
      theme: ThemeData.light(useMaterial3: true),
      darkTheme: ThemeData.dark(useMaterial3: true),
      themeMode: ThemeMode.system,
    );
  }
}

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

  @override
  State<Example> createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  late InfiniteCanvasController controller;

  @override
  void initState() {
    super.initState();
    final rectangleNode = InfiniteCanvasNode(
      key: UniqueKey(),
      label: 'Rectangle',
      offset: const Offset(400, 300),
      size: const Size(200, 200),
      child: Builder(
        builder: (context) {
          return CustomPaint(
            isComplex: true,
            willChange: true,
            painter: InlineCustomPainter(
              brush: Paint(),
              builder: (brush, canvas, rect) {
                // Draw rect
                brush.color = Theme.of(context).colorScheme.secondary;
                canvas.drawRect(rect, brush);
              },
            ),
          );
        },
      ),
    );
    final triangleNode = InfiniteCanvasNode(
      key: UniqueKey(),
      label: 'Triangle',
      offset: const Offset(550, 300),
      size: const Size(200, 200),
      child: Builder(
        builder: (context) {
          return CustomPaint(
            painter: InlineCustomPainter(
              brush: Paint(),
              builder: (brush, canvas, rect) {
                // Draw triangle
                brush.color = Theme.of(context).colorScheme.secondaryContainer;
                final path = Path();
                path.addPolygon([
                  rect.topCenter,
                  rect.bottomLeft,
                  rect.bottomRight,
                ], true);
                canvas.drawPath(path, brush);
              },
            ),
          );
        },
      ),
    );
    final circleNode = InfiniteCanvasNode(
      key: UniqueKey(),
      label: 'Circle',
      offset: const Offset(500, 450),
      size: const Size(200, 200),
      child: Builder(
        builder: (context) {
          return CustomPaint(
            painter: InlineCustomPainter(
              brush: Paint(),
              builder: (brush, canvas, rect) {
                // Draw circle
                brush.color = Theme.of(context).colorScheme.tertiary;
                canvas.drawCircle(rect.center, rect.width / 2, brush);
              },
            ),
          );
        },
      ),
    );
    final nodes = [
      rectangleNode,
      triangleNode,
      circleNode,
    ];
    controller = InfiniteCanvasController(nodes: nodes, edges: [
      InfiniteCanvasEdge(
        from: rectangleNode.key,
        to: triangleNode.key,
        label: '4 -> 3',
      ),
      InfiniteCanvasEdge(
        from: rectangleNode.key,
        to: circleNode.key,
        label: '[] -> ()',
      ),
      InfiniteCanvasEdge(
        from: triangleNode.key,
        to: circleNode.key,
      ),
    ]);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Infinite Canvas Example'),
        centerTitle: false,
      ),
      body: InfiniteCanvas(
        controller: controller,
      ),
    );
  }
}

class InlineCustomPainter extends CustomPainter {
  const InlineCustomPainter({
    required this.brush,
    required this.builder,
    this.isAntiAlias = true,
  });
  final Paint brush;
  final bool isAntiAlias;
  final void Function(Paint paint, Canvas canvas, Rect rect) builder;

  @override
  void paint(Canvas canvas, Size size) {
    final rect = Offset.zero & size;
    brush.isAntiAlias = isAntiAlias;
    canvas.save();
    builder(brush, canvas, rect);
    canvas.restore();
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return true;
  }
}

Links

カテゴリー

依存関係

依存関係一覧 3 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。