Commit 9d51c707 by Ramesh Babu Puvvadi

added

parent 59f975ac
......@@ -82,7 +82,8 @@ class _Identifystylecode extends State<Identifystylecode> {
Future<void> initializeCamera() async {
final cameras = await availableCameras();
final frontCamera = cameras.firstWhere((camera) => camera.lensDirection == CameraLensDirection.back);
final frontCamera = cameras.firstWhere(
(camera) => camera.lensDirection == CameraLensDirection.back);
if (frontCamera == null) {
if (kDebugMode) {
print('No front camera found');
......@@ -95,10 +96,11 @@ class _Identifystylecode extends State<Identifystylecode> {
Future<void> _navigateToCameraScreen() async {
try {
final imageFile1 = await Navigator.push<File>(context, MaterialPageRoute(builder: (context) => CameraScreen()));
final imageFile1 = await Navigator.push<File>(
context, MaterialPageRoute(builder: (context) => CameraScreen()));
if (imageFile1 != null) {
imagefile = imageFile1;
final bytes = await imageFile1.readAsBytes();
imagefile = imageFile1;
final bytes = await imageFile1.readAsBytes();
final base64String1 = base64Encode(bytes);
setState(() {
_base64Image = base64String1;
......@@ -406,7 +408,7 @@ class _Identifystylecode extends State<Identifystylecode> {
height: 8,
),
Text(
'Similarity Percentage\t: ${closestStylecodes![index].SimilarityPercentage ?? 'None'}${closestStylecodes![index].SimilarityPercentage != 'None' ? '%' : ''}',
'Similarity Percentage\t: ${closestStylecodes![index].similarityPercentage ?? 'None'}${closestStylecodes![index].similarityPercentage != 'None' ? '%' : ''}',
style: Constants.headerfontStyle,
),
],
......@@ -418,10 +420,14 @@ class _Identifystylecode extends State<Identifystylecode> {
children: [
ElevatedButton(
onPressed: () {
Constants.Showindicator(context, 'Loading Data ...');
Constants.Showindicator(
context, 'Loading Data ...');
getStock(closestStylecodes![index].styleCode);
},
style: ElevatedButton.styleFrom(backgroundColor: const Color.fromARGB(255, 69, 66, 121),),
style: ElevatedButton.styleFrom(
backgroundColor:
const Color.fromARGB(255, 69, 66, 121),
),
child: const Text(
'Stock',
style: TextStyle(color: Colors.white),
......@@ -430,16 +436,21 @@ class _Identifystylecode extends State<Identifystylecode> {
const SizedBox(width: 16),
ElevatedButton(
onPressed: () {
Constants.Showindicator(context, 'Loading Data ...');
Constants.Showindicator(
context, 'Loading Data ...');
getSale(closestStylecodes![index].styleCode);
},
style: ElevatedButton.styleFrom(backgroundColor:const Color.fromARGB(255, 69, 66, 121)),
child: const Text('\tSale\t',style: TextStyle(color: Colors.white)),
style: ElevatedButton.styleFrom(
backgroundColor:
const Color.fromARGB(255, 69, 66, 121)),
child: const Text('\tSale\t',
style: TextStyle(color: Colors.white)),
),
const SizedBox(width: 16),
ElevatedButton(
onPressed: () {
if (closestStylecodes![index].similarImagePath !=
if (closestStylecodes![index]
.similarImagePath !=
'No Saree') {
showDialog(
context: context,
......@@ -456,7 +467,7 @@ class _Identifystylecode extends State<Identifystylecode> {
style: Constants.headerfontStyle,
),
Text(
'Similarity Percentage: ${closestStylecodes![index].SimilarityPercentage ?? 'None'}${closestStylecodes![index].SimilarityPercentage != 'None' ? '%' : ''}',
'Similarity Percentage: ${closestStylecodes![index].similarityPercentage ?? 'None'}${closestStylecodes![index].similarityPercentage != 'None' ? '%' : ''}',
style: Constants.headerfontStyle,
),
Image.network(
......@@ -781,7 +792,7 @@ class _Identifystylecode extends State<Identifystylecode> {
}
void getupdate(var jsonResponse) {
print('Hitting ot npt $jsonResponse');
//print('Hitting ot npt $jsonResponse');
Navigator.of(context).pop();
setState(() {
isloading = false;
......@@ -796,7 +807,6 @@ class _Identifystylecode extends State<Identifystylecode> {
}).toList();
//closestStylecodes = [Stylecode.fromJson(json)];
});
print('Hitting ot npt $jsonResponse');
}
......@@ -823,19 +833,19 @@ class _Identifystylecode extends State<Identifystylecode> {
}
class Stylecode {
final int? SimilarityPercentage;
final int? similarityPercentage;
final String? similarImagePath;
final String? styleCode;
Stylecode({
this.SimilarityPercentage,
this.similarityPercentage,
this.similarImagePath,
this.styleCode,
});
factory Stylecode.fromJson(Map<String, dynamic> json) {
return Stylecode(
SimilarityPercentage: json['Similarity Percentage'] ?? '',
similarityPercentage: json['Similarity Percentage'] ?? '',
similarImagePath: json['imageURL'] ?? '',
styleCode: json['Stylecode'] ?? '',
);
......
......@@ -21,7 +21,6 @@ class _Uploadstylecode extends State<Uploadstylecode> {
final ImagePicker _picker = ImagePicker();
late List<File> arraylist = [];
final TextEditingController _stylecode = TextEditingController();
XFile? image;
bool isloading = false;
bool isVisible = true;
......@@ -60,8 +59,8 @@ class _Uploadstylecode extends State<Uploadstylecode> {
// if (kDebugMode) {
// print(imageInput);
// }
// // Creating matrix representation, [300, 300, 3]
// final imageMatrix = List.generate(
// // Creating matrix representation, [300, 300, 3]
// final imageMatrix = List.generate(
// imageInput.height,
// (y) => List.generate(
// imageInput.width,
......@@ -109,9 +108,6 @@ class _Uploadstylecode extends State<Uploadstylecode> {
});
if (imageFile1 != null) {
print('Camera Capture ==========> $imageFile1');
//setState((){
// imagefile = imageFile1;
//});
setState(() {
isloading = true; // Set loading state to true
});
......@@ -219,7 +215,9 @@ class _Uploadstylecode extends State<Uploadstylecode> {
});
}
} catch (e) {
print("Error while picking image from camera: $e");
if (kDebugMode) {
print("Error while picking image from camera: $e");
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment