|
|
|
|
@ -12,6 +12,7 @@ import 'package:file_picker/file_picker.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:car_provider_app/extensions/int_extensions.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DefineLicensePage extends StatefulWidget {
|
|
|
|
|
@override
|
|
|
|
|
State<DefineLicensePage> createState() => _DefineLicensePageState();
|
|
|
|
|
@ -76,22 +77,28 @@ class _DefineLicensePageState extends State<DefineLicensePage> {
|
|
|
|
|
? Text("Something went wrong")
|
|
|
|
|
: ListView.separated(
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
return Row(
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Flexible(
|
|
|
|
|
child: TxtField(
|
|
|
|
|
hint: "Select Attachment",
|
|
|
|
|
value: document?.data![index].documentUrl ?? "",
|
|
|
|
|
isNeedClickAll: true,
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
),
|
|
|
|
|
Text(document?.data![index].documentName ?? ""),
|
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Flexible(
|
|
|
|
|
child: TxtField(
|
|
|
|
|
hint: "Select Attachment",
|
|
|
|
|
value: document?.data![index].documentUrl ?? "",
|
|
|
|
|
isNeedClickAll: true,
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
selectFile(index);
|
|
|
|
|
},
|
|
|
|
|
icon: Icon(Icons.insert_link_rounded),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
onPressed: () {
|
|
|
|
|
selectFile(index);
|
|
|
|
|
},
|
|
|
|
|
icon: Icon(Icons.insert_link_rounded),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
@ -115,17 +122,15 @@ class _DefineLicensePageState extends State<DefineLicensePage> {
|
|
|
|
|
File file = File(result.files.single.path ?? "");
|
|
|
|
|
int sizeInBytes = file.lengthSync();
|
|
|
|
|
// double sizeInMb = sizeInBytes / (1024 * 1024);
|
|
|
|
|
if (sizeInBytes > 1000){
|
|
|
|
|
if (sizeInBytes > 1000) {
|
|
|
|
|
Utils.showToast("File is larger then 1KB");
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
document!.data![index].document = convertFileToBase64(file);
|
|
|
|
|
document!.data![index].fileExt = checkFileExt(file.path);
|
|
|
|
|
setState(() {
|
|
|
|
|
document!.data![index].documentUrl = result.files.single.path ?? "";
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// User canceled the picker
|
|
|
|
|
}
|
|
|
|
|
|