Coder Social home page Coder Social logo

zoom-widget's Introduction

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: ^0.1.3

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 example

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 double 0.0-1.0.
  • enableScroll bool.
  • zoomSensibility double.
  • doubleTapZoom 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: 2.3,
    initZoom: 0.0,
    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),),
    ),
);

Examples

Mobile

In the example/mobile folder you will find the example ready to run with Flutter using the commands.

flutter pub get
flutter run

Desktop

In the example/desktop folder you will find the example ready to run with Hover.

Hover - Run Flutter apps on the desktop with hot-reload

zoom-widget's People

Contributors

gedw99 avatar semakers avatar

Watchers

James Cloos avatar  avatar

Forkers

lushan1314

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.