-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/plugins
#3783Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 2.3Found to occur in 2.3Found to occur in 2.3has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: image_pickerThe Image Picker plugin.The Image Picker plugin.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Problem
if no image selected, the process never return/end/complete.
Sample Code
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: LabScreen(title: 'Flutter Demo Home Page'),
);
}
}
class LabScreen extends StatefulWidget {
LabScreen({Key? key, required this.title}) : super(key: key);
final String title;
@override
_LabScreenState createState() => _LabScreenState();
}
class _LabScreenState extends State<LabScreen> {
bool _loading = false;
File? _imageFile;
void _selectedImage() async {
print('start select image');
setState(() {
_loading = true;
});
final selectedImage = await ImagePicker().getImage(
source: ImageSource.gallery,
maxHeight: 480,
maxWidth: 480,
);
if (selectedImage != null) {
print('image selected: ${selectedImage.path}');
setState(() {
_imageFile = File(selectedImage.path);
_loading = false;
});
} else {
print('no image selected');
setState(() {
_loading = false;
});
}
print('end select image');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: _loading
? CircularProgressIndicator()
: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
_imageFile != null ? _imageFile!.path.toString() : 'no file',
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _selectedImage,
tooltip: 'change image',
child: Icon(Icons.add),
),
);
}
}
expected:
flutter: start select image
flutter: no image selected
flutter: end select imageactual:
flutter: start select imageChristianGaertner, kreativityapps, stepushchik-denis-gismart, Desno365, fanwgwg and 1 more
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 2.3Found to occur in 2.3Found to occur in 2.3has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: image_pickerThe Image Picker plugin.The Image Picker plugin.packageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version