added same image check

This commit is contained in:
commitimpush 2022-08-31 12:10:58 +02:00
parent 7650150cc6
commit e9f0aaf4c2

View file

@ -1,5 +1,6 @@
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_image_picker/image_picker.dart'; import 'package:flutter_image_picker/image_picker.dart';
@ -72,10 +73,15 @@ class _ImagePickerExampleHomePageState
void pickImage() async { void pickImage() async {
Uint8List? imageInBytes = await imagePicker.showPickImageDialog(context); Uint8List? imageInBytes = await imagePicker.showPickImageDialog(context);
if (imageInBytes != null) { if (imageInBytes != null && !listEquals(image, imageInBytes)) {
setState(() { setState(() {
image = imageInBytes; image = imageInBytes;
}); });
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Selected image is already being displayed!')),
);
} }
} }
} }