mirror of
https://github.com/Iconica-Development/flutter_image_picker.git
synced 2025-05-18 19:53:45 +02:00
added optional parameters
This commit is contained in:
parent
c2c73819c6
commit
1f2af6b0b2
3 changed files with 34 additions and 9 deletions
|
@ -2,9 +2,17 @@ import 'dart:typed_data';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
import 'src/screens/image_picker_ui.dart';
|
import 'src/screens/image_picker_ui.dart';
|
||||||
|
import 'src/models/image_picker_settings.dart';
|
||||||
|
|
||||||
class ImagePicker {
|
class ImagePicker {
|
||||||
Future<Uint8List?> showPickImageDialog(BuildContext context) {
|
Future<Uint8List?> showPickImageDialog(BuildContext context,
|
||||||
return ImagePickerUI().pickImageDialog(context);
|
{String title = ImagePickerSettings.title,
|
||||||
|
String makePhotoText = ImagePickerSettings.makePhotoText,
|
||||||
|
IconData makePhotoIcon = ImagePickerSettings.makePhotoIcon,
|
||||||
|
String selectImageText = ImagePickerSettings.selectImageText,
|
||||||
|
IconData selectImageIcon = ImagePickerSettings.selectImageIcon,
|
||||||
|
String closeButtonText = ImagePickerSettings.closeButtonText}) {
|
||||||
|
return ImagePickerUI().pickImageDialog(context, title, makePhotoText,
|
||||||
|
makePhotoIcon, selectImageText, selectImageIcon, closeButtonText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
lib/src/models/image_picker_settings.dart
Normal file
10
lib/src/models/image_picker_settings.dart
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class ImagePickerSettings {
|
||||||
|
static const String title = "Upload Image";
|
||||||
|
static const String makePhotoText = "Take a Picture";
|
||||||
|
static const IconData makePhotoIcon = Icons.camera_alt_rounded;
|
||||||
|
static const String selectImageText = "Select File";
|
||||||
|
static const IconData selectImageIcon = Icons.image;
|
||||||
|
static const String closeButtonText = "Close";
|
||||||
|
}
|
|
@ -8,7 +8,14 @@ class ImagePickerUI {
|
||||||
final ImagePickerService _imagePickerService = ImagePickerService();
|
final ImagePickerService _imagePickerService = ImagePickerService();
|
||||||
final double iconSize = 150;
|
final double iconSize = 150;
|
||||||
|
|
||||||
Future<Uint8List?> pickImageDialog(BuildContext context) async {
|
Future<Uint8List?> pickImageDialog(
|
||||||
|
BuildContext context,
|
||||||
|
String title,
|
||||||
|
String makePhotoText,
|
||||||
|
IconData makePhotoIcon,
|
||||||
|
String selectImageText,
|
||||||
|
IconData selectImageIcon,
|
||||||
|
String closeButtonText) async {
|
||||||
return await showModalBottomSheet<Uint8List?>(
|
return await showModalBottomSheet<Uint8List?>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
@ -16,22 +23,22 @@ class ImagePickerUI {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
const Text(
|
Text(
|
||||||
"Upload Image",
|
title,
|
||||||
textScaleFactor: 2,
|
textScaleFactor: 2,
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
generateColumn(context, selectImageIcon, ImageSource.gallery,
|
||||||
|
selectImageText),
|
||||||
generateColumn(
|
generateColumn(
|
||||||
context, Icons.image, ImageSource.gallery, "Select File"),
|
context, makePhotoIcon, ImageSource.camera, makePhotoText),
|
||||||
generateColumn(context, Icons.camera_alt_rounded,
|
|
||||||
ImageSource.camera, "Take a picture"),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
child: const Text("Close")),
|
child: Text(closeButtonText)),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue