Commit 9d51c707 by Ramesh Babu Puvvadi

added

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