Last updated:
0 purchases
image picker package
Image Picker Package #
image_picker_package is a Flutter package that provides a way to pick images from the camera or gallery without relying on third-party dependencies.
Features #
Pick images from the camera.
Pick images from the gallery.
Simple and easy-to-use API.
Installation #
Add the following dependency to your pubspec.yaml file:
-by Raman Daksh
dependencies:
image_picker_package:
git:
url: https://github.com/dakshraman/image_picker_package.git
copied to clipboard
Usage
Import the Package
Import the package into your Dart code:
import 'package:image_picker_package/image_picker_package.dart';
Example
Here’s an example of how to use the ImagePickerService to pick an image:
import 'package:flutter/material.dart';
import 'package:image_picker_package/image_picker_package.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Image Picker Example')),
body: Center(child: ImagePickerExample()),
),
);
}
}
class ImagePickerExample extends StatefulWidget {
@override
_ImagePickerExampleState createState() => _ImagePickerExampleState();
}
class _ImagePickerExampleState extends State<ImagePickerExample> {
final ImagePickerService _imagePickerService = ImagePickerService();
File? _image;
Future<void> _pickImage() async {
final image = await _imagePickerService.pickImage(source: ImageSource.gallery);
setState(() {
_image = image;
});
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (_image != null)
Image.file(_image!)
else
Text('No image selected.'),
ElevatedButton(
onPressed: _pickImage,
child: Text('Pick Image'),
),
],
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.