mirror of
https://github.com/Iconica-Development/flutter_media_picker.git
synced 2025-05-19 00:43:45 +02:00
doc: create documentation for files
This commit is contained in:
parent
f7925a1a48
commit
3b7bd588ff
3 changed files with 72 additions and 38 deletions
|
@ -10,6 +10,27 @@ import '../../flutter_media_picker.dart';
|
|||
|
||||
/// Input for file used by [MediaPicker].
|
||||
class MediaPickerInputFile implements MediaPickerInput {
|
||||
/// Label for the file input.
|
||||
@override
|
||||
String label;
|
||||
|
||||
/// Widget for the file input.
|
||||
@override
|
||||
Widget? widget;
|
||||
|
||||
/// List of file extensions allowed.
|
||||
final List<String> fileExtensions;
|
||||
|
||||
/// Factory for creating video players.
|
||||
final VideoPlayerFactory videoPlayerFactory = MediaPickerVideoPlayerFactory();
|
||||
|
||||
/// Service for handling audio operations.
|
||||
final AudioService audioService = MediaPickerAudioService();
|
||||
|
||||
/// Callback to pick a file.
|
||||
final Future<FilePickerResult?> Function(List<String>)? pickFile;
|
||||
|
||||
/// Constructor for [MediaPickerInputFile].
|
||||
MediaPickerInputFile({
|
||||
this.label = 'File',
|
||||
this.widget,
|
||||
|
@ -19,17 +40,7 @@ class MediaPickerInputFile implements MediaPickerInput {
|
|||
this.pickFile,
|
||||
});
|
||||
|
||||
final Future<FilePickerResult?> Function(List<String>)? pickFile;
|
||||
final List<String> fileExtensions;
|
||||
final VideoPlayerFactory videoPlayerFactory = MediaPickerVideoPlayerFactory();
|
||||
final AudioService audioService = MediaPickerAudioService();
|
||||
|
||||
@override
|
||||
String label;
|
||||
|
||||
@override
|
||||
Widget? widget;
|
||||
|
||||
/// Method to handle button press for picking a file.
|
||||
@override
|
||||
Future<MediaResult> onPressed(BuildContext context) async {
|
||||
var filePicked = await pickFile?.call(fileExtensions);
|
||||
|
@ -47,6 +58,7 @@ class MediaPickerInputFile implements MediaPickerInput {
|
|||
return MediaResult();
|
||||
}
|
||||
|
||||
/// Method to display the result of picking a file.
|
||||
@override
|
||||
Future<Widget> displayResult(MediaResult result) async {
|
||||
if (result.fileValue != null) {
|
||||
|
@ -92,9 +104,11 @@ class MediaPickerInputFile implements MediaPickerInput {
|
|||
return Text(result.fileName!);
|
||||
}
|
||||
|
||||
/// Map for checking page settings.
|
||||
@override
|
||||
Map<String, dynamic>? checkPageSettings;
|
||||
|
||||
/// Callback function when the input is completed.
|
||||
@override
|
||||
void Function(MediaResult value)? onComplete;
|
||||
}
|
||||
|
|
|
@ -9,22 +9,40 @@ import 'package:mime/mime.dart';
|
|||
|
||||
/// Input for photo used by [MediaPicker].
|
||||
class MediaPickerInputPhoto implements MediaPickerInput {
|
||||
/// Function to pick a file for photo input.
|
||||
final Future<MediaResult?> Function()? pickFile;
|
||||
|
||||
/// Label for the photo input.
|
||||
@override
|
||||
String label;
|
||||
|
||||
/// Widget representing the photo input.
|
||||
@override
|
||||
Widget? widget;
|
||||
|
||||
/// Map containing settings to check the page.
|
||||
@override
|
||||
Map<String, dynamic>? checkPageSettings;
|
||||
|
||||
/// Callback function called when the photo input is completed.
|
||||
@override
|
||||
void Function(MediaResult value)? onComplete;
|
||||
|
||||
/// Constructor for [MediaPickerInputPhoto].
|
||||
///
|
||||
/// [pickFile]: Function to pick a file for photo input.
|
||||
/// [label]: Label for the photo input. Defaults to 'Photo'.
|
||||
/// [widget]: Widget representing the photo input.
|
||||
/// [checkPageSettings]: Map containing settings to check the page.
|
||||
/// [onComplete]: Callback function called when the photo input is completed.
|
||||
MediaPickerInputPhoto({
|
||||
this.pickFile,
|
||||
this.label = 'Photo',
|
||||
this.widget,
|
||||
this.checkPageSettings,
|
||||
this.onComplete,
|
||||
this.pickFile,
|
||||
});
|
||||
|
||||
final Future<MediaResult?> Function()? pickFile;
|
||||
|
||||
@override
|
||||
String label;
|
||||
|
||||
@override
|
||||
Widget? widget;
|
||||
|
||||
@override
|
||||
Future<MediaResult> onPressed(BuildContext context) async {
|
||||
var image = await pickFile?.call();
|
||||
|
@ -52,10 +70,4 @@ class MediaPickerInputPhoto implements MediaPickerInput {
|
|||
|
||||
return Container();
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic>? checkPageSettings;
|
||||
|
||||
@override
|
||||
void Function(MediaResult value)? onComplete;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,23 @@ import 'package:flutter_media_picker/src/media_result.dart';
|
|||
|
||||
/// Input for text used by [MediaPicker].
|
||||
class MediaPickerInputText implements MediaPickerInput {
|
||||
/// Label for the text input.
|
||||
@override
|
||||
String label;
|
||||
|
||||
/// Widget for the text input.
|
||||
@override
|
||||
Widget? widget;
|
||||
|
||||
/// Map for checking page settings.
|
||||
@override
|
||||
Map<String, dynamic>? checkPageSettings;
|
||||
|
||||
/// Callback function when the input is completed.
|
||||
@override
|
||||
void Function(MediaResult value)? onComplete;
|
||||
|
||||
/// Constructor for [MediaPickerInputText].
|
||||
MediaPickerInputText({
|
||||
this.label = 'Text',
|
||||
this.widget,
|
||||
|
@ -16,29 +33,20 @@ class MediaPickerInputText implements MediaPickerInput {
|
|||
this.onComplete,
|
||||
});
|
||||
|
||||
@override
|
||||
String label;
|
||||
|
||||
@override
|
||||
Widget? widget;
|
||||
|
||||
/// Method to handle button press for picking text.
|
||||
@override
|
||||
Future<MediaResult> onPressed(BuildContext context) async {
|
||||
return MediaResult(mimeType: 'plain/text');
|
||||
}
|
||||
|
||||
/// Method to display the result of picking text.
|
||||
@override
|
||||
Future<Widget> displayResult(MediaResult result) async {
|
||||
return const DisplayText();
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic>? checkPageSettings;
|
||||
|
||||
@override
|
||||
void Function(MediaResult value)? onComplete;
|
||||
}
|
||||
|
||||
/// Widget to display text input.
|
||||
class DisplayText extends StatefulWidget {
|
||||
const DisplayText({Key? key}) : super(key: key);
|
||||
|
||||
|
|
Loading…
Reference in a new issue