more code improvements and added some documentation in the readme

This commit is contained in:
commitimpush 2022-08-31 16:54:45 +02:00
parent 21c70fb6be
commit a569e91520
9 changed files with 37 additions and 24 deletions

View file

@ -16,21 +16,29 @@ Flutter Image Picker is a package you can use to implement an Image Picker in yo
## Features
TODO: List what your package can do. Maybe include images, gifs, or videos.
## Getting started
TODO: List prerequisites and provide or point to information on how to
start using the package.
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.
## Usage
TODO: Include short and useful examples for package users. Add longer examples
to `/example` folder.
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).
```dart
const like = 'sample';
```
## Example
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

View file

@ -14,7 +14,7 @@ class ImagePickerExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
title: 'Flutter Image Picker Example',
theme: ThemeData(
primarySwatch: Colors.blue,
),
@ -38,9 +38,9 @@ class ImagePickerExampleHomePage extends StatefulWidget {
class _ImagePickerExampleHomePageState
extends State<ImagePickerExampleHomePage> {
Uint8List? image;
ImagePicker imagePicker = ImagePicker();
double whiteSpace = 20;
double imageWidth = 300;
final ImagePicker imagePicker = ImagePicker();
final double whiteSpace = 20;
final double imageWidth = 300;
@override
Widget build(BuildContext context) {
@ -84,7 +84,7 @@ class _ImagePickerExampleHomePageState
}
void pickImage() async {
Uint8List? imageInBytes = await imagePicker.showPickImageDialog(context);
Uint8List? imageInBytes = await imagePicker.showImagePickerDialog(context);
if (imageInBytes != null) {
if (!listEquals(image, imageInBytes)) {
setState(() {

View file

View file

@ -1,11 +1,11 @@
import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'src/screens/image_picker_ui.dart';
import 'src/models/image_picker_settings.dart';
import 'src/ui/image_picker_ui.dart';
class ImagePicker {
Future<Uint8List?> showPickImageDialog(BuildContext context,
Future<Uint8List?> showImagePickerDialog(BuildContext context,
{String title = ImagePickerDefaultParameters.title,
double titleTextSize = ImagePickerDefaultParameters.titleTextSize,
double iconSize = ImagePickerDefaultParameters.iconSize,

View file

@ -35,13 +35,13 @@ class ImagePickerUI {
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
generateColumn(context, selectImageIcon, iconSize, iconTextSize,
ImageSource.gallery, selectImageText),
generateIconButtonWithText(context, selectImageIcon, iconSize,
iconTextSize, ImageSource.gallery, selectImageText),
SizedBox(
width: spaceBetweenIcons,
),
generateColumn(context, makePhotoIcon, iconSize, iconTextSize,
ImageSource.camera, makePhotoText),
generateIconButtonWithText(context, makePhotoIcon, iconSize,
iconTextSize, ImageSource.camera, makePhotoText),
],
),
Row(
@ -65,8 +65,13 @@ class ImagePickerUI {
);
}
Column generateColumn(BuildContext context, IconData icon, double iconSize,
double iconTextSize, ImageSource imageSource, String bottomText) {
Column generateIconButtonWithText(
BuildContext context,
IconData icon,
double iconSize,
double iconTextSize,
ImageSource imageSource,
String bottomText) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[

View file

View file