null safety
This commit is contained in:
@@ -6,12 +6,12 @@ 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;
|
||||
final String? url;
|
||||
final File? imageFile;
|
||||
final String? fileName;
|
||||
final String? localImage;
|
||||
const ShowImage(
|
||||
{Key key, this.imageFile, this.fileName, this.url, this.localImage})
|
||||
{Key? key, this.imageFile, this.fileName, this.url, this.localImage})
|
||||
: super(key: key);
|
||||
@override
|
||||
_ShowImageState createState() => _ShowImageState();
|
||||
@@ -20,6 +20,13 @@ class ShowImage extends StatefulWidget {
|
||||
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(
|
||||
@@ -35,11 +42,7 @@ class _ShowImageState extends State<ShowImage> {
|
||||
backgroundDecoration: const BoxDecoration(
|
||||
color: primaryColor,
|
||||
),
|
||||
imageProvider: widget.url != null
|
||||
? NetworkImage(widget.url)
|
||||
: widget.imageFile != null
|
||||
? FileImage(widget.imageFile)
|
||||
: AssetImage(widget.localImage),
|
||||
imageProvider: widget.url != null ? NetworkImage(widget.url!) : p,
|
||||
minScale: PhotoViewComputedScale.contained * 1)),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user