|
1 | 1 | # yin_drag_sacle
|
2 | 2 |
|
3 |
| -A new Flutter package. |
| 3 | +Image zooming in, zooming out, dragging, you can customize the zoom scale, the project is from flutter_drag_scale, the modification is published to meet their own project |
4 | 4 |
|
5 | 5 | ## Getting Started
|
6 | 6 |
|
7 |
| -This project is a starting point for a Dart |
8 |
| -[package](https://flutter.dev/developing-packages/), |
9 |
| -a library module containing code that can be shared easily across |
10 |
| -multiple Flutter or Dart projects. |
| 7 | +- amplification |
| 8 | + - gesture magnification |
| 9 | + - double click to enlarge |
| 10 | +- to reduce the |
| 11 | +- drag |
11 | 12 |
|
12 |
| -For help getting started with Flutter, view our |
13 |
| -[online documentation](https://flutter.dev/docs), which offers tutorials, |
14 |
| -samples, guidance on mobile development, and a full API reference. |
| 13 | + |
| 14 | +It can be used with Swiper |
| 15 | + |
| 16 | + |
| 17 | +``` |
| 18 | +import 'package:flutter/material.dart'; |
| 19 | +import 'package:flutter_swiper/flutter_swiper.dart'; |
| 20 | +import 'package:yin_drag_sacle/yin_drag_sacle.dart'; |
| 21 | +
|
| 22 | +void main() => runApp(MyApp()); |
| 23 | +
|
| 24 | +class MyApp extends StatefulWidget { |
| 25 | + @override |
| 26 | + MyAppState createState() => new MyAppState(); |
| 27 | +} |
| 28 | +
|
| 29 | +class MyAppState extends State<MyApp> { |
| 30 | + List<String> path = [ |
| 31 | + 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1575024212241&di=b017d085f3982d951b9a365fbc9cfdd4&imgtype=0&src=http%3A%2F%2Fimg2.mukewang.com%2F5c18cf540001ac8206000338.jpg', |
| 32 | + 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1575024212240&di=a69285fddbc441702f83a707a2d2af17&imgtype=0&src=http%3A%2F%2Fdingyue.nosdn.127.net%2FetqmQabSGrqHXhTvzaS91gV006NWCPDnEgLHRoAVony8E1543979039684.png', |
| 33 | + 'http://h.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=0d023672312ac65c67506e77cec29e27/9f2f070828381f30dea167bbad014c086e06f06c.jpg', |
| 34 | + ]; |
| 35 | +
|
| 36 | + ///item 视图 |
| 37 | + Widget itemView(BuildContext context, int index) { |
| 38 | + String value = path[index]; |
| 39 | + return DragScaleContainer( |
| 40 | + child: Image(image: NetworkImage(value)), |
| 41 | + doubleTapStillScale: false, |
| 42 | + maxScale: 4, //放大最大倍数 |
| 43 | + ); |
| 44 | + } |
| 45 | +
|
| 46 | + @override |
| 47 | + Widget build(BuildContext context) { |
| 48 | + return MaterialApp( |
| 49 | + home: Scaffold( |
| 50 | + appBar: AppBar(title: Text('图片显示')), |
| 51 | + body: Swiper( |
| 52 | + itemBuilder: itemView, |
| 53 | + itemCount: path.length, |
| 54 | + pagination: SwiperPagination(), |
| 55 | + control: SwiperControl(), |
| 56 | + ), |
| 57 | + ), |
| 58 | + ); |
| 59 | + } |
| 60 | +} |
| 61 | +
|
| 62 | +``` |
0 commit comments