You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansu_ui/lib/utils/photo_viewer.dart

50 lines
1.2 KiB

4 years ago
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:ansu_ui/extension/num_extension.dart';
4 years ago
class PhotoViewer extends StatefulWidget {
final File file;
final String tag;
PhotoViewer({Key key, this.file, this.tag}) : super(key: key);
@override
_PhotoViewerState createState() => _PhotoViewerState();
}
class _PhotoViewerState extends State<PhotoViewer> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black54,
body: GestureDetector(
onTap: () => Navigator.pop(context),
child: Center(
child: InteractiveViewer(
boundaryMargin: 100.edge,
child: Hero(
tag: widget.tag,
child: Image.file(widget.file),
),
),
),
),
);
}
}
toPhotoViewer(BuildContext context, {String tag, File file}) {
Navigator.push(
context,
PageRouteBuilder(
pageBuilder: (context, animation, secondAnimation) {
return PhotoViewer(file: file, tag: tag);
},
opaque: false,
transitionsBuilder: (context, animation, secondaryAnimation, child) {
return FadeTransition(opacity: animation, child: child);
},
),
);
}