buildFile method
Widget
buildFile(
- int index,
- ValueNotifier<
List< listFiles,PlatformFile> > - ValueNotifier<
List> selectedList, - ValueNotifier<
bool> isSelecting,
Implementation
Widget buildFile(int index, ValueNotifier<List<PlatformFile>> listFiles,
ValueNotifier<List> selectedList, ValueNotifier<bool> isSelecting) {
final PlatformFile file = listFiles.value[index];
final kb = file.size / 1024;
final mb = kb / 1024;
final fileSize =
mb >= 1 ? '${mb.toStringAsFixed(2)} MB' : '${kb.toStringAsFixed(2)} KB';
final extension = file.extension ?? 'none';
return GestureDetector(
onTap: () {
if (isSelecting.value) {
handleSelect(selectedList, file);
}
},
// onLongPress: () {
// handleSelect(selectedList, file);
// },
child: Card(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
side: BorderSide(
color: selectedList.value.contains(file)
? Colors.blue
: outlineColor)),
margin: const EdgeInsets.all(5),
child: Padding(
padding: const EdgeInsets.all(8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Stack(
children: [
Container(
alignment: Alignment.center,
width: double.infinity,
child: FilePickerLogic.buildIcon(file, extension),
),
Align(
alignment: Alignment.topRight,
child: Visibility(
visible: selectedList.value.contains(file),
child: const Padding(
padding: EdgeInsets.all(2.0),
child: Icon(
Icons.check_circle_rounded,
color: Colors.blue,
),
),
)),
],
)),
// const SizedBox(height: 8),
Text(
file.name,
maxLines: 2,
style: const TextStyle(fontSize: 12),
overflow: TextOverflow.ellipsis,
),
Text(
fileSize,
style: const TextStyle(fontSize: 10),
),
],
),
),
),
);
}