mirror of
https://github.com/Iconica-Development/flutter_image_picker.git
synced 2025-05-18 11:43:44 +02:00
more code improvements and added some documentation in the readme
This commit is contained in:
parent
21c70fb6be
commit
a569e91520
9 changed files with 37 additions and 24 deletions
30
README.md
30
README.md
|
@ -16,21 +16,29 @@ Flutter Image Picker is a package you can use to implement an Image Picker in yo
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
TODO: List what your package can do. Maybe include images, gifs, or videos.
|
With the Flutter Image Picker you can select an existing picture from the gallery or make a picture with the camera to use in your app.
|
||||||
|
|
||||||
## Getting started
|
|
||||||
|
|
||||||
TODO: List prerequisites and provide or point to information on how to
|
|
||||||
start using the package.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
TODO: Include short and useful examples for package users. Add longer examples
|
To use this package, add `flutter_image_picker` as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/platform-integration/platform-channels).
|
||||||
to `/example` folder.
|
|
||||||
|
|
||||||
```dart
|
## Example
|
||||||
const like = 'sample';
|
|
||||||
```
|
See [Example Code](example/lib/main.dart) for an example on how to use this package.
|
||||||
|
|
||||||
|
You can add optional parameters to the `showImagePickerDialog(context)` function call. These are:
|
||||||
|
| Parameter | Explaination |
|
||||||
|
|-------------------|---------------|
|
||||||
|
| title | left-aligned |
|
||||||
|
| titleTextSize | centered |
|
||||||
|
| iconSize | right-aligned |
|
||||||
|
| iconTextSize | right-aligned |
|
||||||
|
| spaceBetweenIcons | right-aligned |
|
||||||
|
| makePhotoText | right-aligned |
|
||||||
|
| makePhotoIcon | right-aligned |
|
||||||
|
| selectImageText | right-aligned |
|
||||||
|
| selectImageIcon | right-aligned |
|
||||||
|
| closeButtonText | right-aligned |
|
||||||
|
|
||||||
## Additional information
|
## Additional information
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class ImagePickerExample extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Flutter Demo',
|
title: 'Flutter Image Picker Example',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
primarySwatch: Colors.blue,
|
primarySwatch: Colors.blue,
|
||||||
),
|
),
|
||||||
|
@ -38,9 +38,9 @@ class ImagePickerExampleHomePage extends StatefulWidget {
|
||||||
class _ImagePickerExampleHomePageState
|
class _ImagePickerExampleHomePageState
|
||||||
extends State<ImagePickerExampleHomePage> {
|
extends State<ImagePickerExampleHomePage> {
|
||||||
Uint8List? image;
|
Uint8List? image;
|
||||||
ImagePicker imagePicker = ImagePicker();
|
final ImagePicker imagePicker = ImagePicker();
|
||||||
double whiteSpace = 20;
|
final double whiteSpace = 20;
|
||||||
double imageWidth = 300;
|
final double imageWidth = 300;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -84,7 +84,7 @@ class _ImagePickerExampleHomePageState
|
||||||
}
|
}
|
||||||
|
|
||||||
void pickImage() async {
|
void pickImage() async {
|
||||||
Uint8List? imageInBytes = await imagePicker.showPickImageDialog(context);
|
Uint8List? imageInBytes = await imagePicker.showImagePickerDialog(context);
|
||||||
if (imageInBytes != null) {
|
if (imageInBytes != null) {
|
||||||
if (!listEquals(image, imageInBytes)) {
|
if (!listEquals(image, imageInBytes)) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
0
example/test/main_test.dart
Normal file
0
example/test/main_test.dart
Normal file
|
@ -1,11 +1,11 @@
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
import 'src/screens/image_picker_ui.dart';
|
|
||||||
import 'src/models/image_picker_settings.dart';
|
import 'src/models/image_picker_settings.dart';
|
||||||
|
import 'src/ui/image_picker_ui.dart';
|
||||||
|
|
||||||
class ImagePicker {
|
class ImagePicker {
|
||||||
Future<Uint8List?> showPickImageDialog(BuildContext context,
|
Future<Uint8List?> showImagePickerDialog(BuildContext context,
|
||||||
{String title = ImagePickerDefaultParameters.title,
|
{String title = ImagePickerDefaultParameters.title,
|
||||||
double titleTextSize = ImagePickerDefaultParameters.titleTextSize,
|
double titleTextSize = ImagePickerDefaultParameters.titleTextSize,
|
||||||
double iconSize = ImagePickerDefaultParameters.iconSize,
|
double iconSize = ImagePickerDefaultParameters.iconSize,
|
||||||
|
|
|
@ -35,13 +35,13 @@ class ImagePickerUI {
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
generateColumn(context, selectImageIcon, iconSize, iconTextSize,
|
generateIconButtonWithText(context, selectImageIcon, iconSize,
|
||||||
ImageSource.gallery, selectImageText),
|
iconTextSize, ImageSource.gallery, selectImageText),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: spaceBetweenIcons,
|
width: spaceBetweenIcons,
|
||||||
),
|
),
|
||||||
generateColumn(context, makePhotoIcon, iconSize, iconTextSize,
|
generateIconButtonWithText(context, makePhotoIcon, iconSize,
|
||||||
ImageSource.camera, makePhotoText),
|
iconTextSize, ImageSource.camera, makePhotoText),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
|
@ -65,8 +65,13 @@ class ImagePickerUI {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Column generateColumn(BuildContext context, IconData icon, double iconSize,
|
Column generateIconButtonWithText(
|
||||||
double iconTextSize, ImageSource imageSource, String bottomText) {
|
BuildContext context,
|
||||||
|
IconData icon,
|
||||||
|
double iconSize,
|
||||||
|
double iconTextSize,
|
||||||
|
ImageSource imageSource,
|
||||||
|
String bottomText) {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
0
test/image_picker_test.dart
Normal file
0
test/image_picker_test.dart
Normal file
0
test/src/models/image_picker_settings_test.dart
Normal file
0
test/src/models/image_picker_settings_test.dart
Normal file
0
test/src/services/image_picker_service_test.dart
Normal file
0
test/src/services/image_picker_service_test.dart
Normal file
0
test/src/ui/image_picker_ui_test.dart
Normal file
0
test/src/ui/image_picker_ui_test.dart
Normal file
Loading…
Reference in a new issue