Hello, I try to add this custom action :
// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/structs/index.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'dart:typed_data';
import 'package:file_picker/file_picker.dart';
import 'package:ankit_testing/auth/firebase_auth/auth_util.dart';
Future<FFUploadedFile?> documentPicker() async {
// Add your function code here!
final selectedFiles = await selectFiles(
allowedExtensions: ['pdf', 'png', 'jpg'],
multiFile: false,
);
if (selectedFiles != null) {
var selectedUploadedFiles = <FFUploadedFile>[];
selectedUploadedFiles = selectedFiles
.map((m) => FFUploadedFile(
name: m.storagePath.split('/').last,
bytes: m.bytes,
))
.toList();
FFAppState().fileName = selectedUploadedFiles.first.name!;
if (selectedUploadedFiles.length == selectedFiles.length) {
return selectedUploadedFiles.first;
} else {
return null;
}
}
}
Future<SelectedFile?> selectFile(
{String? storageFolderPath,
List<String>? allowedExtensions,
BuildContext? c}) =>
selectFiles(
storageFolderPath: storageFolderPath,
allowedExtensions: allowedExtensions,
multiFile: false,
).then((value) => value?.first);
Future<List<SelectedFile>?> selectFiles({
String? storageFolderPath,
List<String>? allowedExtensions,
bool multiFile = false,
}) async {
final pickedFiles = await FilePicker.platform.pickFiles(
type: allowedExtensions != null ? FileType.custom : FileType.any,
allowedExtensions: allowedExtensions,
withData: true,
allowMultiple: multiFile,
);
if (pickedFiles == null || pickedFiles.files.isEmpty) {
return null;
}
final file = pickedFiles.files.first;
if (file.bytes == null) {
return null;
}
final storagePath = file.name;
return [
SelectedFile(
storagePath: storagePath,
filePath: isWeb ? null : file.path,
bytes: file.bytes!,
)
];
}
class SelectedFile {
const SelectedFile({
this.storagePath = '',
this.filePath,
required this.bytes,
this.dimensions,
this.blurHash,
});
final String storagePath;
final String? filePath;
final Uint8List bytes;
final MediaDimensions? dimensions;
final String? blurHash;
}
class MediaDimensions {
const MediaDimensions({
this.height,
this.width,
});
final double? height;
final double? width;
}
String _getStoragePath(
String? pathPrefix,
String filePath,
bool isVideo, [
int? index,
]) {
pathPrefix ??= _firebasePathPrefix();
pathPrefix = _removeTrailingSlash(pathPrefix);
final timestamp = DateTime.now().microsecondsSinceEpoch;
// Workaround fixed by https://github.com/flutter/plugins/pull/3685
// (not yet in stable).
final ext = isVideo ? 'mp4' : filePath.split('.').last;
final indexStr = index != null ? '_$index' : '';
return '$pathPrefix/$timestamp$indexStr.$ext';
}
String _firebasePathPrefix() => 'users/$currentUserUid/uploads';
String? _removeTrailingSlash(String? path) => path != null && path.endsWith('/')
? path.substring(0, path.length - 1)
: path;
I have the following code errors but I don't find how to pass it :
Target of URI doesn't exist: 'package:ankit_testing/auth/firebase_auth/auth_util.dart'. Try creating the file referenced by the URI, or try using a URI for a file that does exist.
If someone have already see this error or if someone has a solution, I would take ๐
Kinds regards,
Jean-Junior