https://github.com/alnitak/magnifying_glass
Flutter real-time magnifying glass lens widget with Barrel/Pincushion distortion
https://github.com/alnitak/magnifying_glass
flutter flutter-package flutter-ui flutter-widgets glass lens
Last synced: 2 months ago
JSON representation
Flutter real-time magnifying glass lens widget with Barrel/Pincushion distortion
- Host: GitHub
- URL: https://github.com/alnitak/magnifying_glass
- Owner: alnitak
- License: apache-2.0
- Created: 2021-12-28T18:07:12.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-09-28T09:03:44.000Z (9 months ago)
- Last Synced: 2025-04-17T19:16:59.433Z (2 months ago)
- Topics: flutter, flutter-package, flutter-ui, flutter-widgets, glass, lens
- Language: Dart
- Homepage:
- Size: 7.8 MB
- Stars: 23
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# MagnifyingGlass Flutter plugin
Flutter real-time magnifying glass lens widget with Barrel/Pincushion distortion.

## Getting Started
Make [MagnifyingGlass] widget as the parent of the widget you wish to be used (usually MyHomePage).
```dart
@override
Widget build(BuildContext context) {
MagnifyingGlassController magnifyingGlassController = MagnifyingGlassController();
return MagnifyingGlass(
controller: magnifyingGlassController,
glassPosition: GlassPosition.touchPosition,
borderThickness: 8.0,
borderColor: Colors.grey,
glassParams: GlassParams(
startingPosition: Offset(150, 150),
diameter: 150,
distortion: 1.0,
magnification: 1.2,
padding: EdgeInsets.all(10),
),
child: Scaffold(
body: ...,floatingActionButton: FloatingActionButton(
onPressed: () => magnifyingGlassController.openGlass(),
child: const Icon(Icons.search),
),
)
);
```## MagnifyingGlass properties
|Name|Type|Description|
|:-------|:----------|:-----------|
**controller**|MagnifyingGlassController|Let you control the glass state and parameters:
**openGlass()**
**closeGlass()**
**setDistortion(** *double distortion, double magnification* **)**
**setDiameter(** *int diameter* **)**
**refresh()**|
**glassPosition**|enum|enum to set the touch behavior or sticky position|
**glassParams**|GlassParams|class to set lens parameters|
**borderColor**|Color|border color|
**borderThickness**|double|border thickness|
**elevation**|double|shadow elevation|
**shadowOffset**|Offset|shadow offset|
**GlassPosition class**
|Name|Description|
|:-------|:-----------|
**touchPosition**|move the glass with finger touch|
**topLeft**|sticky position to top left corner of the screen|
**topRight**|sticky position to top rigth corner of the screen|
**bottomLeft**|sticky position to bottom left corner of the screen|
**bottomRight**|sticky position to bottom right corner of the screen|
**GlassParams class**
|Name|Description|
|:-------|:-----------|
**startingPosition**|the startin glass position. If not given the lens will be placed at the center of the screen.|
**diameter**|the diameter of the glass|
**magnification**|the magnification of the lens
1 means no magnification
>1 means magnification
<1 means shrinking|
**distortion**|Barrel/Pincushion distortion power
0 means no distortion|
**padding**|the padding surrounding the glass to enlarge touching area||  |  |  |
|:--:|:--:|:--:|
| *distorsion 0.5
mag 1.0* | *distorsion 0.5
mag 1.4* | *distorsion 2.0
mag 1.7* |