Files
fcs/lib/pages/widgets/show_img.dart
phyothandar 079c9a135d null safety
2021-09-10 14:25:37 +06:30

50 lines
1.4 KiB
Dart

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