mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 15:18:56 +03:30
bog fix
This commit is contained in:
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"editor.inlineSuggest.showToolbar": "onHover"
|
||||||
|
}
|
||||||
+1
-2
@@ -66,7 +66,6 @@ import 'providers/labels.dart';
|
|||||||
import 'providers/my_info.dart';
|
import 'providers/my_info.dart';
|
||||||
import 'providers/test_results.dart';
|
import 'providers/test_results.dart';
|
||||||
import 'widgets/Global/splash_screen.dart';
|
import 'widgets/Global/splash_screen.dart';
|
||||||
import 'widgets/TestResultScreens/Add/capture_image.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
@@ -165,7 +164,7 @@ class MyApp extends StatelessWidget {
|
|||||||
Routes.testScanScreen: (ctx) => TestScanScreen(),
|
Routes.testScanScreen: (ctx) => TestScanScreen(),
|
||||||
Routes.sendCodeScreen: (ctx) => VerifyPassScreen(),
|
Routes.sendCodeScreen: (ctx) => VerifyPassScreen(),
|
||||||
Routes.rePassScreen: (ctx) => RePassScreen(),
|
Routes.rePassScreen: (ctx) => RePassScreen(),
|
||||||
Routes.captureImageScreen: (ctx) => CaptureImage(),
|
// Routes.captureImageScreen: (ctx) => CaptureImage(),
|
||||||
Routes.packageAddScreen: (ctx) => PackageAddScreen(),
|
Routes.packageAddScreen: (ctx) => PackageAddScreen(),
|
||||||
Routes.packageResultScreen: (ctx) => PackageResultScreen(),
|
Routes.packageResultScreen: (ctx) => PackageResultScreen(),
|
||||||
Routes.packageDetailScreen: (ctx) => PackageDetailScreen(),
|
Routes.packageDetailScreen: (ctx) => PackageDetailScreen(),
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class ItemResultObject extends Equatable {
|
|||||||
final int status;
|
final int status;
|
||||||
final String? batchId;
|
final String? batchId;
|
||||||
final String? udi;
|
final String? udi;
|
||||||
|
final String? udi_name;
|
||||||
|
|
||||||
ItemResultObject({
|
ItemResultObject({
|
||||||
required this.id,
|
required this.id,
|
||||||
@@ -18,6 +19,7 @@ class ItemResultObject extends Equatable {
|
|||||||
required this.status,
|
required this.status,
|
||||||
this.batchId,
|
this.batchId,
|
||||||
this.udi,
|
this.udi,
|
||||||
|
this.udi_name,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -29,6 +31,7 @@ class ItemResultObject extends Equatable {
|
|||||||
status,
|
status,
|
||||||
batchId!,
|
batchId!,
|
||||||
udi!,
|
udi!,
|
||||||
|
udi_name!,
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class MyItemResultObject extends Equatable {
|
|||||||
final String id;
|
final String id;
|
||||||
final String name;
|
final String name;
|
||||||
final String size;
|
final String size;
|
||||||
|
final String? udi;
|
||||||
final String? userName;
|
final String? userName;
|
||||||
final String? requestId;
|
final String? requestId;
|
||||||
|
|
||||||
@@ -14,6 +15,7 @@ class MyItemResultObject extends Equatable {
|
|||||||
required this.size,
|
required this.size,
|
||||||
this.userName,
|
this.userName,
|
||||||
this.requestId,
|
this.requestId,
|
||||||
|
this.udi,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -23,6 +25,7 @@ class MyItemResultObject extends Equatable {
|
|||||||
size,
|
size,
|
||||||
userName!,
|
userName!,
|
||||||
requestId!,
|
requestId!,
|
||||||
|
udi!,
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -324,6 +324,7 @@ class _ItemAddScreenState extends State<ItemAddScreen> {
|
|||||||
batchId: batchId,
|
batchId: batchId,
|
||||||
dateValue: dateCTRL.text,
|
dateValue: dateCTRL.text,
|
||||||
deviceBlockSize: _deviceBlockSize,
|
deviceBlockSize: _deviceBlockSize,
|
||||||
|
isLoading: isInit,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 100,
|
height: 100,
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class ItemProvider extends ChangeNotifier {
|
|||||||
return 'Added';
|
return 'Added';
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> createItemResult(
|
Future<String> createItemResult(
|
||||||
name,
|
name,
|
||||||
size,
|
size,
|
||||||
specific,
|
specific,
|
||||||
@@ -149,6 +149,12 @@ class ItemProvider extends ChangeNotifier {
|
|||||||
"Accept": "application/json"
|
"Accept": "application/json"
|
||||||
});
|
});
|
||||||
print(response.body);
|
print(response.body);
|
||||||
|
if (response.statusCode == 200 || response.statusCode == 201) {
|
||||||
|
catchImages = [];
|
||||||
|
return 'done';
|
||||||
|
} else {
|
||||||
|
return 'error';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateItemResult(
|
Future<void> updateItemResult(
|
||||||
@@ -281,6 +287,7 @@ class ItemProvider extends ChangeNotifier {
|
|||||||
size: item['size'].toString(),
|
size: item['size'].toString(),
|
||||||
userName: item['user'] != null ? item['user']['name'] : '',
|
userName: item['user'] != null ? item['user']['name'] : '',
|
||||||
status: item['status'],
|
status: item['status'],
|
||||||
|
udi: item['udi'],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ class MyItemProvider extends ChangeNotifier {
|
|||||||
name: item['name'],
|
name: item['name'],
|
||||||
id: item['id'].toString(),
|
id: item['id'].toString(),
|
||||||
size: item['size'].toString(),
|
size: item['size'].toString(),
|
||||||
|
udi: item['udi'],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -170,6 +171,7 @@ class MyItemProvider extends ChangeNotifier {
|
|||||||
id: item['id'].toString(),
|
id: item['id'].toString(),
|
||||||
size: item['size'].toString(),
|
size: item['size'].toString(),
|
||||||
userName: item['user'] != null ? item['user']['name'] : '',
|
userName: item['user'] != null ? item['user']['name'] : '',
|
||||||
|
udi: item['udi'],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-10
@@ -41,7 +41,11 @@ class PackageProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
changeItemVal(String value, int index) {
|
changeItemVal(String value, int index) {
|
||||||
itemValues[index].text = value;
|
for (var item in filteredItems!) {
|
||||||
|
if (item.udi_name == value) {
|
||||||
|
itemValues[index].text = item.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,18 +108,12 @@ class PackageProvider extends ChangeNotifier {
|
|||||||
'Authorization': User.token,
|
'Authorization': User.token,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
// List<Map<String, dynamic>> result = [];
|
|
||||||
List<String> result = [];
|
List<String> result = [];
|
||||||
filteredItems = [];
|
filteredItems = [];
|
||||||
var filterData = json.decode(response.body);
|
var filterData = json.decode(response.body);
|
||||||
for (var item in filterData['data']) {
|
for (var item in filterData['data']) {
|
||||||
// result.add("${item['name']} - ${item['udi'] != null ? item['udi'] : ''}");
|
result.add("${item['name']} - ${item['udi'] != null ? item['udi'] : ''}");
|
||||||
result.add(item['id'].toString());
|
// result.add(item['id'].toString());
|
||||||
// result.add({
|
|
||||||
// 'name-udi':
|
|
||||||
// "${item['name']} - ${item['udi'] != null ? item['udi'] : ''}",
|
|
||||||
// 'id': item['id'].toString()
|
|
||||||
// });
|
|
||||||
filteredItems!.add(
|
filteredItems!.add(
|
||||||
ItemResultObject(
|
ItemResultObject(
|
||||||
name: item['name'],
|
name: item['name'],
|
||||||
@@ -124,6 +122,8 @@ class PackageProvider extends ChangeNotifier {
|
|||||||
userName: item['user'] != null ? item['user']['name'] : '',
|
userName: item['user'] != null ? item['user']['name'] : '',
|
||||||
status: item['status'],
|
status: item['status'],
|
||||||
udi: item['udi'] != null ? item['udi'] : '',
|
udi: item['udi'] != null ? item['udi'] : '',
|
||||||
|
udi_name:
|
||||||
|
"${item['name']} - ${item['udi'] != null ? item['udi'] : ''}",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -312,7 +312,8 @@ class PackageProvider extends ChangeNotifier {
|
|||||||
var data = json.decode(response.body)['data'];
|
var data = json.decode(response.body)['data'];
|
||||||
List<String> itemsList = [];
|
List<String> itemsList = [];
|
||||||
for (var item in data['items']) {
|
for (var item in data['items']) {
|
||||||
itemsList.add(item['id'].toString());
|
itemsList
|
||||||
|
.add("${item['name']} - ${item['udi'] != null ? item['udi'] : ''}");
|
||||||
}
|
}
|
||||||
print(data);
|
print(data);
|
||||||
result = PackageDetailObject(
|
result = PackageDetailObject(
|
||||||
|
|||||||
@@ -37,19 +37,19 @@ class CycleItemBox extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
// Container(
|
||||||
padding: const EdgeInsets.all(6),
|
// padding: const EdgeInsets.all(6),
|
||||||
child: Text(
|
// child: Text(
|
||||||
item!.id,
|
// item!.id,
|
||||||
style: TextStyle(
|
// style: TextStyle(
|
||||||
fontWeight: FontWeight.w700,
|
// fontWeight: FontWeight.w700,
|
||||||
fontSize: 5 * _deviceBlockSize,
|
// fontSize: 5 * _deviceBlockSize,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
width: 3 * _deviceBlockSize,
|
// width: 3 * _deviceBlockSize,
|
||||||
),
|
// ),
|
||||||
// Spacer(),
|
// Spacer(),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@@ -34,21 +34,27 @@ class _AppDrawerState extends State<AppDrawer> {
|
|||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ListTile(
|
Text(
|
||||||
leading: CircleAvatar(
|
'WELCOME',
|
||||||
backgroundColor: kLightBlue,
|
style: TextStyle(
|
||||||
child: Icon(
|
color: Colors.white,
|
||||||
Icons.person,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
title: Text(
|
),
|
||||||
user?['name'] != null ? user!['name'] : '',
|
SizedBox(
|
||||||
style: TextStyle(
|
height: 5.0,
|
||||||
color: Colors.white,
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
user?['name'] != null ? user!['name'] : '',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
Divider(
|
Divider(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// ignore_for_file: must_be_immutable
|
||||||
|
|
||||||
import 'package:cssd/config/colors.dart';
|
import 'package:cssd/config/colors.dart';
|
||||||
import 'package:cssd/providers/items.dart';
|
import 'package:cssd/providers/items.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -5,8 +7,8 @@ import 'package:provider/provider.dart';
|
|||||||
|
|
||||||
import '../../../config/routes.dart';
|
import '../../../config/routes.dart';
|
||||||
|
|
||||||
class ItemAddSaveButton extends StatelessWidget {
|
class ItemAddSaveButton extends StatefulWidget {
|
||||||
const ItemAddSaveButton({
|
ItemAddSaveButton({
|
||||||
Key? key,
|
Key? key,
|
||||||
required GlobalKey<FormState> form,
|
required GlobalKey<FormState> form,
|
||||||
this.batchId,
|
this.batchId,
|
||||||
@@ -17,6 +19,7 @@ class ItemAddSaveButton extends StatelessWidget {
|
|||||||
required this.sizeCTRL,
|
required this.sizeCTRL,
|
||||||
required this.specificCTRL,
|
required this.specificCTRL,
|
||||||
required this.dateValue,
|
required this.dateValue,
|
||||||
|
required this.isLoading,
|
||||||
}) : _form = form,
|
}) : _form = form,
|
||||||
_deviceBlockSize = deviceBlockSize,
|
_deviceBlockSize = deviceBlockSize,
|
||||||
super(key: key);
|
super(key: key);
|
||||||
@@ -30,21 +33,55 @@ class ItemAddSaveButton extends StatelessWidget {
|
|||||||
final String dateValue;
|
final String dateValue;
|
||||||
final String? batchId;
|
final String? batchId;
|
||||||
final double _deviceBlockSize;
|
final double _deviceBlockSize;
|
||||||
|
bool isLoading;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<ItemAddSaveButton> createState() => _ItemAddSaveButtonState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ItemAddSaveButtonState extends State<ItemAddSaveButton> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!_form.currentState!.validate()) {
|
if (!widget._form.currentState!.validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Provider.of<ItemProvider>(context, listen: false).createItemResult(
|
setState(() {
|
||||||
nameCTRL.text,
|
widget.isLoading = true;
|
||||||
sizeCTRL.text,
|
});
|
||||||
specificCTRL.text,
|
Provider.of<ItemProvider>(context, listen: false)
|
||||||
udiCTRL.text,
|
.createItemResult(
|
||||||
descriptionCTRL.text,
|
widget.nameCTRL.text,
|
||||||
batchId,
|
widget.sizeCTRL.text,
|
||||||
|
widget.specificCTRL.text,
|
||||||
|
widget.udiCTRL.text,
|
||||||
|
widget.descriptionCTRL.text,
|
||||||
|
widget.batchId,
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
(result) {
|
||||||
|
setState(() {
|
||||||
|
widget.isLoading = false;
|
||||||
|
});
|
||||||
|
if (result == 'done') {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => AlertDialog(
|
||||||
|
content: Text('Item added.'),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(ctx).pop();
|
||||||
|
},
|
||||||
|
child: Text('Ok'),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
).then((value) => Navigator.of(context)
|
||||||
|
.popAndPushNamed(Routes.testResultScreen));
|
||||||
|
}
|
||||||
|
},
|
||||||
);
|
);
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -65,7 +102,7 @@ class ItemAddSaveButton extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
horizontal: 5 * _deviceBlockSize,
|
horizontal: 5 * widget._deviceBlockSize,
|
||||||
vertical: 10,
|
vertical: 10,
|
||||||
),
|
),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -80,7 +117,7 @@ class ItemAddSaveButton extends StatelessWidget {
|
|||||||
'Save',
|
'Save',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 5 * _deviceBlockSize,
|
fontSize: 5 * widget._deviceBlockSize,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class _UploaderImageState extends State<UploaderImage> {
|
|||||||
|
|
||||||
Future<void> loadAssetsFromCamera(BuildContext context) async {
|
Future<void> loadAssetsFromCamera(BuildContext context) async {
|
||||||
var providerObject = Provider.of<ItemProvider>(context, listen: false);
|
var providerObject = Provider.of<ItemProvider>(context, listen: false);
|
||||||
List<PlatformFile> _catchImages = [];
|
List<PlatformFile> _catchImages = providerObject.catchImages;
|
||||||
var image = await ImagePicker.platform.pickImage(
|
var image = await ImagePicker.platform.pickImage(
|
||||||
source: ImageSource.camera,
|
source: ImageSource.camera,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -35,19 +35,21 @@ class ItemItemBox extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
if (item!.udi != null)
|
||||||
padding: const EdgeInsets.all(6.0),
|
Container(
|
||||||
child: Text(
|
padding: const EdgeInsets.all(6.0),
|
||||||
item!.id,
|
child: Text(
|
||||||
style: TextStyle(
|
item!.udi!,
|
||||||
fontWeight: FontWeight.w700,
|
style: TextStyle(
|
||||||
fontSize: 5 * _deviceBlockSize,
|
fontWeight: FontWeight.w700,
|
||||||
|
fontSize: 3 * _deviceBlockSize,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (item!.udi != null)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 3 * _deviceBlockSize,
|
width: 3 * _deviceBlockSize,
|
||||||
),
|
),
|
||||||
// Spacer(),
|
// Spacer(),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@@ -33,19 +33,19 @@ class LabelItemBox extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
// Container(
|
||||||
padding: const EdgeInsets.all(6),
|
// padding: const EdgeInsets.all(6),
|
||||||
child: Text(
|
// child: Text(
|
||||||
item!.id,
|
// item!.id,
|
||||||
style: TextStyle(
|
// style: TextStyle(
|
||||||
fontWeight: FontWeight.w700,
|
// fontWeight: FontWeight.w700,
|
||||||
fontSize: 5 * _deviceBlockSize,
|
// fontSize: 5 * _deviceBlockSize,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
width: 3 * _deviceBlockSize,
|
// width: 3 * _deviceBlockSize,
|
||||||
),
|
// ),
|
||||||
// Spacer(),
|
// Spacer(),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@@ -65,6 +65,10 @@ class LabelItemBox extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
item!.package,
|
item!.package,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w700,
|
||||||
|
fontSize: 3 * _deviceBlockSize,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
Container(
|
||||||
|
|||||||
@@ -37,19 +37,21 @@ class MyItemsItemDataBox extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
if (items!.udi != null)
|
||||||
padding: const EdgeInsets.all(6.0),
|
Container(
|
||||||
child: Text(
|
padding: const EdgeInsets.all(6.0),
|
||||||
items!.id,
|
child: Text(
|
||||||
style: TextStyle(
|
items!.udi!,
|
||||||
fontWeight: FontWeight.w700,
|
style: TextStyle(
|
||||||
fontSize: 5 * _deviceBlockSize,
|
fontWeight: FontWeight.w700,
|
||||||
|
fontSize: 3 * _deviceBlockSize,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (items!.udi != null)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 3 * _deviceBlockSize,
|
width: 3 * _deviceBlockSize,
|
||||||
),
|
),
|
||||||
// Spacer(),
|
// Spacer(),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@@ -38,19 +38,19 @@ class MyPackagesItemDataBox extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
// Container(
|
||||||
padding: const EdgeInsets.all(6.0),
|
// padding: const EdgeInsets.all(6.0),
|
||||||
child: Text(
|
// child: Text(
|
||||||
packages!.id,
|
// packages!.id,
|
||||||
style: TextStyle(
|
// style: TextStyle(
|
||||||
fontWeight: FontWeight.w700,
|
// fontWeight: FontWeight.w700,
|
||||||
fontSize: 5 * _deviceBlockSize,
|
// fontSize: 5 * _deviceBlockSize,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
width: 3 * _deviceBlockSize,
|
// width: 3 * _deviceBlockSize,
|
||||||
),
|
// ),
|
||||||
// Spacer(),
|
// Spacer(),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ class PackageDetailsDataBox extends StatelessWidget {
|
|||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
itemBuilder: (ctx, index) => RichText(
|
itemBuilder: (ctx, index) => RichText(
|
||||||
text: TextSpan(
|
text: TextSpan(
|
||||||
text: 'Item ID ',
|
text: 'Item ',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
fontFamily: 'montserrat',
|
fontFamily: 'montserrat',
|
||||||
|
|||||||
@@ -35,19 +35,19 @@ class PackageItemBox extends StatelessWidget {
|
|||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
// Container(
|
||||||
padding: const EdgeInsets.all(6.0),
|
// padding: const EdgeInsets.all(6.0),
|
||||||
child: Text(
|
// child: Text(
|
||||||
item!.id,
|
// item!.id,
|
||||||
style: TextStyle(
|
// style: TextStyle(
|
||||||
fontWeight: FontWeight.w700,
|
// fontWeight: FontWeight.w700,
|
||||||
fontSize: 5 * _deviceBlockSize,
|
// fontSize: 5 * _deviceBlockSize,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
width: 3 * _deviceBlockSize,
|
// width: 3 * _deviceBlockSize,
|
||||||
),
|
// ),
|
||||||
// Spacer(),
|
// Spacer(),
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|||||||
@@ -1,328 +1,328 @@
|
|||||||
// ignore_for_file: dead_code
|
// // ignore_for_file: dead_code
|
||||||
|
|
||||||
import 'dart:async';
|
// import 'dart:async';
|
||||||
import 'dart:io';
|
// import 'dart:io';
|
||||||
|
|
||||||
import 'package:camera/camera.dart';
|
// import 'package:camera/camera.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
// import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
// import 'package:flutter/material.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
// import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:provider/provider.dart';
|
// import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../../providers/test_results.dart';
|
// import '../../../providers/test_results.dart';
|
||||||
|
|
||||||
class CaptureImage extends StatefulWidget {
|
// class CaptureImage extends StatefulWidget {
|
||||||
@override
|
// @override
|
||||||
_CaptureImageState createState() {
|
// _CaptureImageState createState() {
|
||||||
return _CaptureImageState();
|
// return _CaptureImageState();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/// Returns a suitable camera icon for [direction].
|
// /// Returns a suitable camera icon for [direction].
|
||||||
IconData getCameraLensIcon(CameraLensDirection direction) {
|
// IconData getCameraLensIcon(CameraLensDirection direction) {
|
||||||
switch (direction) {
|
// switch (direction) {
|
||||||
case CameraLensDirection.back:
|
// case CameraLensDirection.back:
|
||||||
return Icons.camera_rear;
|
// return Icons.camera_rear;
|
||||||
case CameraLensDirection.front:
|
// case CameraLensDirection.front:
|
||||||
return Icons.camera_front;
|
// return Icons.camera_front;
|
||||||
case CameraLensDirection.external:
|
// case CameraLensDirection.external:
|
||||||
return Icons.camera;
|
// return Icons.camera;
|
||||||
}
|
// }
|
||||||
throw ArgumentError('Unknown lens direction');
|
// throw ArgumentError('Unknown lens direction');
|
||||||
}
|
// }
|
||||||
|
|
||||||
void logError(String code, String message) =>
|
// void logError(String code, String message) =>
|
||||||
print('Error: $code\nError Message: $message');
|
// print('Error: $code\nError Message: $message');
|
||||||
|
|
||||||
class _CaptureImageState extends State<CaptureImage>
|
// class _CaptureImageState extends State<CaptureImage>
|
||||||
with WidgetsBindingObserver {
|
// with WidgetsBindingObserver {
|
||||||
CameraController? controller;
|
// CameraController? controller;
|
||||||
String? imagePath;
|
// String? imagePath;
|
||||||
// String videoPath;
|
// // String videoPath;
|
||||||
VoidCallback? videoPlayerListener;
|
// VoidCallback? videoPlayerListener;
|
||||||
bool isInit = true;
|
// bool isInit = true;
|
||||||
int curCamera = 0;
|
// int curCamera = 0;
|
||||||
var cameras;
|
// var cameras;
|
||||||
@override
|
// @override
|
||||||
void initState() {
|
// void initState() {
|
||||||
super.initState();
|
// super.initState();
|
||||||
WidgetsBinding.instance.addObserver(this);
|
// WidgetsBinding.instance.addObserver(this);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
// @override
|
||||||
void didChangeDependencies() async {
|
// void didChangeDependencies() async {
|
||||||
if (isInit) {
|
// if (isInit) {
|
||||||
cameras = await availableCameras();
|
// cameras = await availableCameras();
|
||||||
onNewCameraSelected(cameras[curCamera]);
|
// onNewCameraSelected(cameras[curCamera]);
|
||||||
setState(() {
|
// setState(() {
|
||||||
isInit = false;
|
// isInit = false;
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
super.didChangeDependencies();
|
// super.didChangeDependencies();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
// @override
|
||||||
void dispose() {
|
// void dispose() {
|
||||||
WidgetsBinding.instance.removeObserver(this);
|
// WidgetsBinding.instance.removeObserver(this);
|
||||||
super.dispose();
|
// super.dispose();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
// @override
|
||||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
// void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
// App state changed before we got the chance to initialize.
|
// // App state changed before we got the chance to initialize.
|
||||||
if (controller == null || !controller!.value.isInitialized) {
|
// if (controller == null || !controller!.value.isInitialized) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (state == AppLifecycleState.inactive) {
|
// if (state == AppLifecycleState.inactive) {
|
||||||
controller?.dispose();
|
// controller?.dispose();
|
||||||
} else if (state == AppLifecycleState.resumed) {
|
// } else if (state == AppLifecycleState.resumed) {
|
||||||
if (controller != null) {
|
// if (controller != null) {
|
||||||
onNewCameraSelected(controller!.description);
|
// onNewCameraSelected(controller!.description);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
// final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SafeArea(
|
|
||||||
child: Scaffold(
|
|
||||||
key: _scaffoldKey,
|
|
||||||
// appBar: AppBar(
|
|
||||||
// title: const Text('Take Picture'),
|
|
||||||
// ),
|
|
||||||
body: isInit
|
|
||||||
? Center(
|
|
||||||
child: CircularProgressIndicator(
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Stack(children: <Widget>[
|
|
||||||
_cameraPreviewWidget(),
|
|
||||||
Positioned(
|
|
||||||
bottom: 100, left: 100, child: _captureControlRowWidget()),
|
|
||||||
Positioned(
|
|
||||||
bottom: 100,
|
|
||||||
right: 100,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () {
|
|
||||||
if (curCamera == 0) {
|
|
||||||
try {
|
|
||||||
onNewCameraSelected(cameras[1]);
|
|
||||||
setState(() {
|
|
||||||
curCamera = 1;
|
|
||||||
});
|
|
||||||
} catch (e) {}
|
|
||||||
} else {
|
|
||||||
onNewCameraSelected(cameras[0]);
|
|
||||||
setState(() {
|
|
||||||
curCamera = 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Icon(
|
|
||||||
curCamera == 0 ? Icons.camera_rear : Icons.camera_front,
|
|
||||||
size: 40,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// _cameraTogglesRowWidget(cameras),
|
|
||||||
]),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Display the preview from the camera (or a message if the preview is not available).
|
|
||||||
Widget _cameraPreviewWidget() {
|
|
||||||
if (controller == null || !controller!.value.isInitialized) {
|
|
||||||
return const Text(
|
|
||||||
'Tap a camera',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 24.0,
|
|
||||||
fontWeight: FontWeight.w900,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Container(
|
|
||||||
width: double.infinity,
|
|
||||||
child: CameraPreview(controller!),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Toggle recording audio
|
|
||||||
|
|
||||||
/// Display the control bar with buttons to take pictures and record videos.
|
|
||||||
Widget _captureControlRowWidget() {
|
|
||||||
return Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: <Widget>[
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(
|
|
||||||
Icons.camera_alt,
|
|
||||||
size: 40,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
// color: Colors.blue,
|
|
||||||
onPressed: controller != null &&
|
|
||||||
controller!.value.isInitialized &&
|
|
||||||
!controller!.value.isRecordingVideo
|
|
||||||
? onTakePictureButtonPressed
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getCameras() async {
|
|
||||||
return await availableCameras();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Display a row of toggle to select the camera (or a message if no camera is available).
|
|
||||||
// Widget _cameraTogglesRowWidget(var cameras) {
|
|
||||||
// final List<Widget> toggles = <Widget>[];
|
|
||||||
|
|
||||||
// if (cameras.isEmpty) {
|
|
||||||
// return const Text('No camera found');
|
|
||||||
// } else {
|
|
||||||
// for (CameraDescription cameraDescription in cameras) {
|
|
||||||
// print("${cameraDescription.name}");
|
|
||||||
// toggles.add(
|
|
||||||
// SizedBox(
|
|
||||||
// width: 90.0,
|
|
||||||
// child: RadioListTile<CameraDescription>(
|
|
||||||
// title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
|
|
||||||
// groupValue: controller?.description,
|
|
||||||
// value: cameraDescription,
|
|
||||||
// onChanged: controller != null && controller.value.isRecordingVideo
|
|
||||||
// ? null
|
|
||||||
// : onNewCameraSelected,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return Row(children: toggles);
|
|
||||||
// }
|
|
||||||
|
|
||||||
String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();
|
|
||||||
|
|
||||||
void showInSnackBar(String message) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(
|
|
||||||
content: Text(message),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onNewCameraSelected(CameraDescription cameraDescription) async {
|
|
||||||
print(cameraDescription.lensDirection.toString());
|
|
||||||
if (controller != null) {
|
|
||||||
await controller!.dispose();
|
|
||||||
}
|
|
||||||
controller = CameraController(
|
|
||||||
cameraDescription,
|
|
||||||
ResolutionPreset.medium,
|
|
||||||
// enableAudio: enableAudio,
|
|
||||||
);
|
|
||||||
|
|
||||||
// If the controller is updated then update the UI.
|
|
||||||
controller!.addListener(() {
|
|
||||||
if (mounted) setState(() {});
|
|
||||||
if (controller!.value.hasError) {
|
|
||||||
showInSnackBar('Camera error ${controller!.value.errorDescription}');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
|
||||||
await controller!.initialize();
|
|
||||||
} on CameraException catch (e) {
|
|
||||||
_showCameraException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void onTakePictureButtonPressed() {
|
|
||||||
takePicture().then((String? filePath) {
|
|
||||||
if (mounted) {
|
|
||||||
setState(() {
|
|
||||||
imagePath = filePath;
|
|
||||||
var profileProviderObject =
|
|
||||||
Provider.of<TestResultsProvider>(context, listen: false);
|
|
||||||
List<PlatformFile> files = profileProviderObject.catchImages;
|
|
||||||
print(imagePath);
|
|
||||||
files.add(PlatformFile(
|
|
||||||
name: 'test',
|
|
||||||
size: 0,
|
|
||||||
path: imagePath,
|
|
||||||
bytes: File(imagePath!).readAsBytesSync()));
|
|
||||||
profileProviderObject.setCatchImages(files);
|
|
||||||
profileProviderObject.setImages();
|
|
||||||
print(imagePath);
|
|
||||||
});
|
|
||||||
if (filePath != null) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
// showInSnackBar('Picture saved to $filePath');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String?> takePicture() async {
|
|
||||||
if (!controller!.value.isInitialized) {
|
|
||||||
showInSnackBar('Error: select a camera first.');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final Directory extDir = await getApplicationDocumentsDirectory();
|
|
||||||
final String dirPath = '${extDir.path}/Pictures/flutter_test';
|
|
||||||
await Directory(dirPath).create(recursive: true);
|
|
||||||
final String filePath = '$dirPath/${timestamp()}.jpg';
|
|
||||||
|
|
||||||
if (controller!.value.isTakingPicture) {
|
|
||||||
// A capture is already pending, do nothing.
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await controller!.takePicture();
|
|
||||||
} on CameraException catch (e) {
|
|
||||||
_showCameraException(e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
void _showCameraException(CameraException e) {
|
|
||||||
logError(e.code, e.description!);
|
|
||||||
showInSnackBar('Error: ${e.code}\n${e.description}');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// class CameraApp extends StatelessWidget {
|
|
||||||
// @override
|
// @override
|
||||||
// Widget build(BuildContext context) {
|
// Widget build(BuildContext context) {
|
||||||
// return MaterialApp(
|
// return SafeArea(
|
||||||
// home: CaptureImage(),
|
// child: Scaffold(
|
||||||
|
// key: _scaffoldKey,
|
||||||
|
// // appBar: AppBar(
|
||||||
|
// // title: const Text('Take Picture'),
|
||||||
|
// // ),
|
||||||
|
// body: isInit
|
||||||
|
// ? Center(
|
||||||
|
// child: CircularProgressIndicator(
|
||||||
|
// color: Colors.black,
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
// : Stack(children: <Widget>[
|
||||||
|
// _cameraPreviewWidget(),
|
||||||
|
// Positioned(
|
||||||
|
// bottom: 100, left: 100, child: _captureControlRowWidget()),
|
||||||
|
// Positioned(
|
||||||
|
// bottom: 100,
|
||||||
|
// right: 100,
|
||||||
|
// child: InkWell(
|
||||||
|
// onTap: () {
|
||||||
|
// if (curCamera == 0) {
|
||||||
|
// try {
|
||||||
|
// onNewCameraSelected(cameras[1]);
|
||||||
|
// setState(() {
|
||||||
|
// curCamera = 1;
|
||||||
|
// });
|
||||||
|
// } catch (e) {}
|
||||||
|
// } else {
|
||||||
|
// onNewCameraSelected(cameras[0]);
|
||||||
|
// setState(() {
|
||||||
|
// curCamera = 0;
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// child: Icon(
|
||||||
|
// curCamera == 0 ? Icons.camera_rear : Icons.camera_front,
|
||||||
|
// size: 40,
|
||||||
|
// color: Colors.white,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// // _cameraTogglesRowWidget(cameras),
|
||||||
|
// ]),
|
||||||
|
// ),
|
||||||
// );
|
// );
|
||||||
// }
|
// }
|
||||||
// }
|
|
||||||
|
|
||||||
// List<CameraDescription> cameras = [];
|
// /// Display the preview from the camera (or a message if the preview is not available).
|
||||||
|
// Widget _cameraPreviewWidget() {
|
||||||
// Future<void> main() async {
|
// if (controller == null || !controller!.value.isInitialized) {
|
||||||
// // Fetch the available cameras before initializing the app.
|
// return const Text(
|
||||||
// try {
|
// 'Tap a camera',
|
||||||
// WidgetsFlutterBinding.ensureInitialized();
|
// style: TextStyle(
|
||||||
// } on CameraException catch (e) {
|
// color: Colors.white,
|
||||||
// logError(e.code, e.description);
|
// fontSize: 24.0,
|
||||||
|
// fontWeight: FontWeight.w900,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// return Container(
|
||||||
|
// width: double.infinity,
|
||||||
|
// child: CameraPreview(controller!),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// /// Toggle recording audio
|
||||||
|
|
||||||
|
// /// Display the control bar with buttons to take pictures and record videos.
|
||||||
|
// Widget _captureControlRowWidget() {
|
||||||
|
// return Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
// mainAxisSize: MainAxisSize.max,
|
||||||
|
// children: <Widget>[
|
||||||
|
// IconButton(
|
||||||
|
// icon: const Icon(
|
||||||
|
// Icons.camera_alt,
|
||||||
|
// size: 40,
|
||||||
|
// color: Colors.white,
|
||||||
|
// ),
|
||||||
|
// // color: Colors.blue,
|
||||||
|
// onPressed: controller != null &&
|
||||||
|
// controller!.value.isInitialized &&
|
||||||
|
// !controller!.value.isRecordingVideo
|
||||||
|
// ? onTakePictureButtonPressed
|
||||||
|
// : null,
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// getCameras() async {
|
||||||
|
// return await availableCameras();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// /// Display a row of toggle to select the camera (or a message if no camera is available).
|
||||||
|
// // Widget _cameraTogglesRowWidget(var cameras) {
|
||||||
|
// // final List<Widget> toggles = <Widget>[];
|
||||||
|
|
||||||
|
// // if (cameras.isEmpty) {
|
||||||
|
// // return const Text('No camera found');
|
||||||
|
// // } else {
|
||||||
|
// // for (CameraDescription cameraDescription in cameras) {
|
||||||
|
// // print("${cameraDescription.name}");
|
||||||
|
// // toggles.add(
|
||||||
|
// // SizedBox(
|
||||||
|
// // width: 90.0,
|
||||||
|
// // child: RadioListTile<CameraDescription>(
|
||||||
|
// // title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
|
||||||
|
// // groupValue: controller?.description,
|
||||||
|
// // value: cameraDescription,
|
||||||
|
// // onChanged: controller != null && controller.value.isRecordingVideo
|
||||||
|
// // ? null
|
||||||
|
// // : onNewCameraSelected,
|
||||||
|
// // ),
|
||||||
|
// // ),
|
||||||
|
// // );
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // return Row(children: toggles);
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();
|
||||||
|
|
||||||
|
// void showInSnackBar(String message) {
|
||||||
|
// ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
// SnackBar(
|
||||||
|
// content: Text(message),
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void onNewCameraSelected(CameraDescription cameraDescription) async {
|
||||||
|
// print(cameraDescription.lensDirection.toString());
|
||||||
|
// if (controller != null) {
|
||||||
|
// await controller!.dispose();
|
||||||
|
// }
|
||||||
|
// controller = CameraController(
|
||||||
|
// cameraDescription,
|
||||||
|
// ResolutionPreset.medium,
|
||||||
|
// // enableAudio: enableAudio,
|
||||||
|
// );
|
||||||
|
|
||||||
|
// // If the controller is updated then update the UI.
|
||||||
|
// controller!.addListener(() {
|
||||||
|
// if (mounted) setState(() {});
|
||||||
|
// if (controller!.value.hasError) {
|
||||||
|
// showInSnackBar('Camera error ${controller!.value.errorDescription}');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// await controller!.initialize();
|
||||||
|
// } on CameraException catch (e) {
|
||||||
|
// _showCameraException(e);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (mounted) {
|
||||||
|
// setState(() {});
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void onTakePictureButtonPressed() {
|
||||||
|
// takePicture().then((String? filePath) {
|
||||||
|
// if (mounted) {
|
||||||
|
// setState(() {
|
||||||
|
// imagePath = filePath;
|
||||||
|
// var profileProviderObject =
|
||||||
|
// Provider.of<TestResultsProvider>(context, listen: false);
|
||||||
|
// List<PlatformFile> files = profileProviderObject.catchImages;
|
||||||
|
// print(imagePath);
|
||||||
|
// files.add(PlatformFile(
|
||||||
|
// name: 'test',
|
||||||
|
// size: 0,
|
||||||
|
// path: imagePath,
|
||||||
|
// bytes: File(imagePath!).readAsBytesSync()));
|
||||||
|
// profileProviderObject.setCatchImages(files);
|
||||||
|
// profileProviderObject.setImages();
|
||||||
|
// print(imagePath);
|
||||||
|
// });
|
||||||
|
// if (filePath != null) {
|
||||||
|
// Navigator.of(context).pop();
|
||||||
|
// // showInSnackBar('Picture saved to $filePath');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Future<String?> takePicture() async {
|
||||||
|
// if (!controller!.value.isInitialized) {
|
||||||
|
// showInSnackBar('Error: select a camera first.');
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// final Directory extDir = await getApplicationDocumentsDirectory();
|
||||||
|
// final String dirPath = '${extDir.path}/Pictures/flutter_test';
|
||||||
|
// await Directory(dirPath).create(recursive: true);
|
||||||
|
// final String filePath = '$dirPath/${timestamp()}.jpg';
|
||||||
|
|
||||||
|
// if (controller!.value.isTakingPicture) {
|
||||||
|
// // A capture is already pending, do nothing.
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// await controller!.takePicture();
|
||||||
|
// } on CameraException catch (e) {
|
||||||
|
// _showCameraException(e);
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// return filePath;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void _showCameraException(CameraException e) {
|
||||||
|
// logError(e.code, e.description!);
|
||||||
|
// showInSnackBar('Error: ${e.code}\n${e.description}');
|
||||||
// }
|
// }
|
||||||
// runApp(CameraApp());
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// // class CameraApp extends StatelessWidget {
|
||||||
|
// // @override
|
||||||
|
// // Widget build(BuildContext context) {
|
||||||
|
// // return MaterialApp(
|
||||||
|
// // home: CaptureImage(),
|
||||||
|
// // );
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // List<CameraDescription> cameras = [];
|
||||||
|
|
||||||
|
// // Future<void> main() async {
|
||||||
|
// // // Fetch the available cameras before initializing the app.
|
||||||
|
// // try {
|
||||||
|
// // WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
// // } on CameraException catch (e) {
|
||||||
|
// // logError(e.code, e.description);
|
||||||
|
// // }
|
||||||
|
// // runApp(CameraApp());
|
||||||
|
// // }
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
|
// ignore_for_file: deprecated_member_use, invalid_use_of_visible_for_testing_member
|
||||||
|
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:barcode_scan2/barcode_scan2.dart';
|
import 'package:barcode_scan2/barcode_scan2.dart';
|
||||||
import 'package:cssd/config/colors.dart';
|
import 'package:cssd/config/colors.dart';
|
||||||
import 'package:cssd/providers/input.dart';
|
import 'package:cssd/providers/input.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:image_picker/image_picker.dart';
|
||||||
import 'package:image_picker_gallery_camera/image_picker_gallery_camera.dart';
|
import 'package:image_picker_gallery_camera/image_picker_gallery_camera.dart';
|
||||||
import 'package:multiselect_formfield/multiselect_formfield.dart';
|
import 'package:multiselect_formfield/multiselect_formfield.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../../../config/routes.dart';
|
|
||||||
import '../../../providers/test_results.dart';
|
import '../../../providers/test_results.dart';
|
||||||
|
|
||||||
class FormCreator extends StatefulWidget {
|
class FormCreator extends StatefulWidget {
|
||||||
@@ -124,8 +128,7 @@ class _FormCreatorState extends State<FormCreator> {
|
|||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
await Navigator.of(context)
|
await loadAssetsFromCamera(context);
|
||||||
.pushNamed(Routes.captureImageScreen);
|
|
||||||
// await captureImage(context);
|
// await captureImage(context);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
@@ -589,6 +592,27 @@ class _FormCreatorState extends State<FormCreator> {
|
|||||||
// profileProviderObject.addImage();
|
// profileProviderObject.addImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> loadAssetsFromCamera(BuildContext context) async {
|
||||||
|
var providerObject =
|
||||||
|
Provider.of<TestResultsProvider>(context, listen: false);
|
||||||
|
List<PlatformFile> _catchImages = providerObject.catchImages;
|
||||||
|
var image = await ImagePicker.platform.pickImage(
|
||||||
|
source: ImageSource.camera,
|
||||||
|
);
|
||||||
|
if (image != null) {
|
||||||
|
_catchImages.add(
|
||||||
|
PlatformFile(
|
||||||
|
path: image.path,
|
||||||
|
name: "item_image",
|
||||||
|
bytes: File(image.path).readAsBytesSync(),
|
||||||
|
size: File(image.path).lengthSync(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
providerObject.setCatchImages(_catchImages);
|
||||||
|
providerObject.setImages();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// _FormCreatorState(this.formItems);
|
// _FormCreatorState(this.formItems);
|
||||||
|
|
||||||
void _handleChanged() {
|
void _handleChanged() {
|
||||||
|
|||||||
@@ -39,5 +39,8 @@ end
|
|||||||
post_install do |installer|
|
post_install do |installer|
|
||||||
installer.pods_project.targets.each do |target|
|
installer.pods_project.targets.each do |target|
|
||||||
flutter_additional_macos_build_settings(target)
|
flutter_additional_macos_build_settings(target)
|
||||||
|
target.build_configurations.each do |config|
|
||||||
|
config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.15'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+1
-1
@@ -44,6 +44,6 @@ SPEC CHECKSUMS:
|
|||||||
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
|
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
|
||||||
url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95
|
url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95
|
||||||
|
|
||||||
PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
|
PODFILE CHECKSUM: 6f49d33c4364341a4e32f6ba81035dd192444660
|
||||||
|
|
||||||
COCOAPODS: 1.13.0
|
COCOAPODS: 1.13.0
|
||||||
|
|||||||
Reference in New Issue
Block a user