Flutter Native Device Features
2 min readApr 14, 2020
Camera: Image can be taken from device gallery or device camera by adding Privacy keys. NSPhotoLibraryUsageDescription key used to access image from gallery and NSCameraUsageDescription key for camera access permission. To use add ImageInput() widget on your screen.
class _ImageInputState extends State<ImageInput> {
File _storedImage;
Future<void> _takePicture() async{
final imageFile = await ImagePicker.pickImage(
source: ImageSource.camera,
maxWidth: 600,
);
}
@override
Widget build(BuildContext context) {
return Row(
children: <Widget>[
Container(
width:100,
height:100,
decoration: BoxDecoration(
border: Border.all(width:1, color: Colors.grey,),
),
child: _storedImage !=null ?
Image.file(_storedImage, fit: BoxFit.cover,) : Text('No Image Taken',textAlign: TextAlign.center,) ,
alignment: Alignment.center,
),
SizedBox(width:10),
Expanded(
child:
FlatButton.icon(
onPressed: _takePicture ,
icon: Icon(Icons.camera),
label: Text('Take Photo')),
),
],
);
}
}
Save File: To work with file system we get dependency packages path and path provider to work with file system.
path_provider: ^1.1.0
path: ^1.6.2
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart' as syspaths;
final appDir = await…