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
14c9301d24
3 changed files with 72 additions and 38 deletions
|
@ -10,6 +10,27 @@ import '../../flutter_media_picker.dart';
|
||||||
|
|
||||||
/// Input for file used by [MediaPicker].
|
/// Input for file used by [MediaPicker].
|
||||||
class MediaPickerInputFile implements MediaPickerInput {
|
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({
|
MediaPickerInputFile({
|
||||||
this.label = 'File',
|
this.label = 'File',
|
||||||
this.widget,
|
this.widget,
|
||||||
|
@ -19,17 +40,7 @@ class MediaPickerInputFile implements MediaPickerInput {
|
||||||
this.pickFile,
|
this.pickFile,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Future<FilePickerResult?> Function(List<String>)? pickFile;
|
/// Method to handle button press for picking a file.
|
||||||
final List<String> fileExtensions;
|
|
||||||
final VideoPlayerFactory videoPlayerFactory = MediaPickerVideoPlayerFactory();
|
|
||||||
final AudioService audioService = MediaPickerAudioService();
|
|
||||||
|
|
||||||
@override
|
|
||||||
String label;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget? widget;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<MediaResult> onPressed(BuildContext context) async {
|
Future<MediaResult> onPressed(BuildContext context) async {
|
||||||
var filePicked = await pickFile?.call(fileExtensions);
|
var filePicked = await pickFile?.call(fileExtensions);
|
||||||
|
@ -47,6 +58,7 @@ class MediaPickerInputFile implements MediaPickerInput {
|
||||||
return MediaResult();
|
return MediaResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Method to display the result of picking a file.
|
||||||
@override
|
@override
|
||||||
Future<Widget> displayResult(MediaResult result) async {
|
Future<Widget> displayResult(MediaResult result) async {
|
||||||
if (result.fileValue != null) {
|
if (result.fileValue != null) {
|
||||||
|
@ -92,9 +104,11 @@ class MediaPickerInputFile implements MediaPickerInput {
|
||||||
return Text(result.fileName!);
|
return Text(result.fileName!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Map for checking page settings.
|
||||||
@override
|
@override
|
||||||
Map<String, dynamic>? checkPageSettings;
|
Map<String, dynamic>? checkPageSettings;
|
||||||
|
|
||||||
|
/// Callback function when the input is completed.
|
||||||
@override
|
@override
|
||||||
void Function(MediaResult value)? onComplete;
|
void Function(MediaResult value)? onComplete;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,22 +9,40 @@ import 'package:mime/mime.dart';
|
||||||
|
|
||||||
/// Input for photo used by [MediaPicker].
|
/// Input for photo used by [MediaPicker].
|
||||||
class MediaPickerInputPhoto implements MediaPickerInput {
|
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({
|
MediaPickerInputPhoto({
|
||||||
|
this.pickFile,
|
||||||
this.label = 'Photo',
|
this.label = 'Photo',
|
||||||
this.widget,
|
this.widget,
|
||||||
this.checkPageSettings,
|
this.checkPageSettings,
|
||||||
this.onComplete,
|
this.onComplete,
|
||||||
this.pickFile,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final Future<MediaResult?> Function()? pickFile;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String label;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget? widget;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<MediaResult> onPressed(BuildContext context) async {
|
Future<MediaResult> onPressed(BuildContext context) async {
|
||||||
var image = await pickFile?.call();
|
var image = await pickFile?.call();
|
||||||
|
@ -52,10 +70,4 @@ class MediaPickerInputPhoto implements MediaPickerInput {
|
||||||
|
|
||||||
return Container();
|
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].
|
/// Input for text used by [MediaPicker].
|
||||||
class MediaPickerInputText implements MediaPickerInput {
|
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({
|
MediaPickerInputText({
|
||||||
this.label = 'Text',
|
this.label = 'Text',
|
||||||
this.widget,
|
this.widget,
|
||||||
|
@ -16,29 +33,20 @@ class MediaPickerInputText implements MediaPickerInput {
|
||||||
this.onComplete,
|
this.onComplete,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
/// Method to handle button press for picking text.
|
||||||
String label;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget? widget;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<MediaResult> onPressed(BuildContext context) async {
|
Future<MediaResult> onPressed(BuildContext context) async {
|
||||||
return MediaResult(mimeType: 'plain/text');
|
return MediaResult(mimeType: 'plain/text');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Method to display the result of picking text.
|
||||||
@override
|
@override
|
||||||
Future<Widget> displayResult(MediaResult result) async {
|
Future<Widget> displayResult(MediaResult result) async {
|
||||||
return const DisplayText();
|
return const DisplayText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Map<String, dynamic>? checkPageSettings;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void Function(MediaResult value)? onComplete;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Widget to display text input.
|
||||||
class DisplayText extends StatefulWidget {
|
class DisplayText extends StatefulWidget {
|
||||||
const DisplayText({Key? key}) : super(key: key);
|
const DisplayText({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue