搜索插件、代码仓与 APP 分类

GitHub 代码仓semakers/zoom-widget

zoom-widget

semakers/zoom-widget open-source repository details.

zoom-widget 项目封面
星标
43
复刻
39
最近推送(UTC)
2023年7月18日
项目状态
未归档

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

Flutter zoom widget

With this widget you can create a customizable canvas in which you can zoom in flutter.

It is possible to customize virtually all the canvases of the canvas such as color, background color, acitvate and deactivate scrolls, change the color of scrolls, modify the sensitivity of the zoom, the initial zoom enters other aspects found in the construction of the Zoom class.

Installation

Add to pubspec.yaml:

dependencies:
zoom_widget: ^2.0.0

How to use

You only need to create an instance of the Zoom class in the child of your Scaffold or within the widget of your choice, within the child attribute, put the widget that you want to zoom in and the width and height of the canvas where it will be made zoom.

Import
import 'package:zoom_widget/zoom_widget.dart';
Simple examples

Center flutter logo using all space of view port:

 Zoom(
        initTotalZoomOut: true,
        child: Center(
          child: FlutterLogo(
            size: 1000,
          ),
        ),
      );

Center text with max width and max height:

Zoom(
    maxZoomWidth: 1800,
    maxZoomHeight: 1800,
    child: Center(
        child: Text("Happy zoom!!"),
    )
);
Callbacks

It is possible to obtain the x and y position of our canvas with respect to the scrolls and and the zoom and scale of our canvas using two simple callbacks in our Zoom instance.

Zoom(
    maxZoomWidth: 1800,
    maxZoomHeight: 1800,
    onTap: (){
        print("Widget clicked");
    },
    onPositionUpdate: (Offset position){
        print(position);
    },
    onScaleUpdate: (double scale,double zoom){
        print("$scale  $zoom");
    },
    child: Center(
        child: Text("Happy zoom!!"),
    )
);
Customize properties

Customizing the properties you can get amazing results.

  • width (Depreceted) double.
  • height (Depreceted) double.
  • maxZoomWidth double.
  • maxZoomHeight double.
  • backgroundColor Color.
  • canvasColor Color.
  • onPositionUpdate() Callaback.
  • onScaleUpdate() Callaback.
  • onTap() Callaback.
  • scrollWeight double.
  • opacityScrollBars double 0.0-1.0.
  • colorScrollBars Color.
  • centerOnScale bool.
  • initZoom (Depreceted) double.
  • initPosition Offset.
  • initScale double
  • enableScroll bool.
  • zoomSensibility double.
  • doubleTapZoom bool.
  • transformationController TransformationController.
  • radiusScrollBars double.
  • doubleTapScaleChange double.
  • doubleTapAnimDuration Duration.
  • initTotalZoomOut bool.
Customized properties example
Zoom(
    maxZoomWidth: 1800,
    maxZoomHeight: 1800,
    canvasColor: Colors.grey,
    backgroundColor: Colors.orange,
    colorScrollBars: Colors.purple,
    opacityScrollBars: 0.9,
    scrollWeight: 10.0,
    centerOnScale: true,
    enableScroll: true,
    doubleTapZoom: true,
    zoomSensibility: 0.05,
    onTap: (){ 
        print("Widget clicked");
    }
    onPositionUpdate: (position){
        setState(() {
            x=position.dx;
            y=position.dy;
        });
    },
    onScaleUpdate: (scale,zoom){
        setState(() {
            _zoom=zoom;
        });
    },
    child: Center(
        child: Text("x:${x.toStringAsFixed(2)} y:${y.toStringAsFixed(2)} zoom:${_zoom.toStringAsFixed(2)}",style: TextStyle(color: Colors.deepPurple,fontSize: 50),),
    ),
);
Complex example

It can be used for more complex things like an image gallery.

All examples of gifs are inside the example

semakers GitHub avatar
GitHub 作者

semakers ↗

Nairda Robot Programming developer.

Nairda Robot ProgrammingPuebla, México
语言DartC++CMakeHTMLMakefileCSwiftKotlinObjective-C

此仓库发布的插件

使用的依赖

依赖清单 3 项

  • flutter{"sdk":"flutter"}
  • vector_math^2.1.1
  • flutter_test开发依赖{"sdk":"flutter"}

如何选择适合项目的代码仓?

先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。

  1. 通过仓库名、作者或描述搜索,再按技术分类缩小范围。
  2. 结合星标、复刻与最近推送比较项目;星标反映社区关注,不代表质量保证。
  3. 使用前在 GitHub 核对 README、许可证与 Issues。

来源与维护

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗