我正在尝试用 PhotoView 做一个简单的任务。我有一个 AssetImage,我正在尝试显示图像,用户可以放大/缩小比例。
我正在使用 Pubspec 依赖项:
照片视图:^0.9.2
我在网上找到了这个测试代码,但似乎也不起作用:(
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
class KodetrApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Photo View',
home: Scaffold(
appBar: AppBar(
title: Text('Photo View'),
),
body: Center(
child: AspectRatio(
aspectRatio: 16 / 9,
child: ClipRect(
child: PhotoView(
imageProvider: NetworkImage(
'https://kodetr.herokuapp.com/banners/post/flutter/flutter_photoview.webp',
),
minScale: PhotoViewComputedScale.contained * 0.8,
maxScale: PhotoViewComputedScale.covered * 2,
enableRotation: true,
),
),
),
),
),
);
}
}