-
Notifications
You must be signed in to change notification settings - Fork 1
/
image_file_viewer.dart
63 lines (59 loc) · 2.28 KB
/
image_file_viewer.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:kartal/src/context_extension.dart';
class FileImageView extends StatelessWidget {
const FileImageView({
Key? key,
required this.imagePaths,
required this.filePickerResults,
}) : super(key: key);
final List<String>? imagePaths;
final FilePickerResult? filePickerResults;
@override
Widget build(BuildContext context) {
return SizedBox(
height: context.dynamicHeight(0.1),
child: SizedBox(
height: context.dynamicHeight(0.02),
child: imagePaths?.isNotEmpty ?? false
? SizedBox(
child: ListView.builder(
shrinkWrap: true,
itemCount: imagePaths?.length ?? 0,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return SizedBox(
width: context.dynamicWidth(0.4),
child: Column(
children: [
Expanded(
child: Image.file(
File(
imagePaths?[index] ?? '',
),
height: context.dynamicHeight(0.1),
),
),
Text(
'${imagePaths?[index].split('/').last}',
overflow: TextOverflow.ellipsis,
)
],
));
},
))
: SizedBox(
child: ListView.builder(
shrinkWrap: true,
itemCount: filePickerResults?.count,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return Column(
children: [const Icon(Icons.picture_as_pdf_outlined), Text('${filePickerResults?.names}')],
);
},
),
)));
}
}