gird_sai simplifies image and file selection in Flutter, offering camera, gallery, file browsing, cropping, and multi-file support.
Features
The gird_sai package simplifies the process of selecting images and files in Flutter applications. It provides an easy-to-use interface for picking images from the camera, gallery, or file system, with optional support for cropping images and selecting multiple files. This package is ideal for developers who need to integrate image and file selection with customizable options in their apps
Getting started
Add the following lines to your Android manifest file (android/app/src/main/AndroidManifest.xml)
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
// Make sure you import your utility class
class ImagePickerExample extends StatefulWidget {
@override
_ImagePickerExampleState createState() => _ImagePickerExampleState();
}
class _ImagePickerExampleState extends State<ImagePickerExample> {
File? _selectedImage;
Future<void> _pickImage() async {
// Call the utility class's pickImage method
var image = await ImagePickerUtil.pickImage(
context: context,
isMultipleFile: false,
// Set this to true if you want to select multiple images
isFromFile: false,
// Set this to true to browse files
isImgCropeble: true,
// Set to true if you want to allow cropping
isOnlyCamera: false, // Set to true if you want to limit the user to the camera only
);
if (image != null && mounted) {
setState(() {
_selectedImage = image is List ? image[0] : image; // Handle both single and multiple images
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Image Picker Example'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_selectedImage != null
? Image.file(_selectedImage!) // Display selected image
: Text('No image selected'),
SizedBox(height: 20),
ElevatedButton(
onPressed: _pickImage, // Call the image picker when pressed
child: Text('Pick an Image'),
),
],
),
),
);
}
}
[//]: # (```)
## Additional information