Files
fcs/lib/pages/widgets/show_img.dart

49 lines
1.4 KiB
Dart
Raw Normal View History

2020-09-17 06:02:48 +06:30
import 'dart:io';
2020-10-07 02:33:06 +06:30
import 'package:fcs/helpers/theme.dart';
2020-09-17 06:02:48 +06:30
import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';
class ShowImage extends StatefulWidget {
2021-09-10 14:25:37 +06:30
final String? url;
final File? imageFile;
final String? fileName;
final String? localImage;
2020-10-16 21:38:39 +06:30
const ShowImage(
2021-09-10 14:25:37 +06:30
{Key? key, this.imageFile, this.fileName, this.url, this.localImage})
2020-09-17 06:02:48 +06:30
: super(key: key);
@override
_ShowImageState createState() => _ShowImageState();
}
class _ShowImageState extends State<ShowImage> {
@override
Widget build(BuildContext context) {
2021-09-10 14:25:37 +06:30
final ImageProvider<Object>? p;
if (widget.imageFile != null) {
p = FileImage(widget.imageFile!);
} else {
p = AssetImage(widget.localImage!);
}
2020-09-17 06:02:48 +06:30
return Scaffold(
appBar: AppBar(
2020-10-28 05:11:06 +06:30
leading: new IconButton(
icon: new Icon(Icons.close),
onPressed: () => Navigator.of(context).pop(),
),
2020-09-17 06:02:48 +06:30
backgroundColor: primaryColor,
2020-10-28 05:11:06 +06:30
shadowColor: Colors.transparent,
2020-10-16 21:38:39 +06:30
iconTheme: new IconThemeData(color: Colors.white),
2020-09-17 06:02:48 +06:30
),
body: Center(
2020-10-16 21:38:39 +06:30
child: PhotoView(
2020-10-28 05:11:06 +06:30
backgroundDecoration: const BoxDecoration(
color: primaryColor,
),
2021-09-10 14:25:37 +06:30
imageProvider: widget.url != null ? NetworkImage(widget.url!) : p,
2020-10-16 21:38:39 +06:30
minScale: PhotoViewComputedScale.contained * 1)),
2020-09-17 06:02:48 +06:30
);
}
}