Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
Vasthram
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ramesh Babu Puvvadi
Vasthram
Commits
59f975ac
Commit
59f975ac
authored
Jul 05, 2024
by
Ramesh Babu Puvvadi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Stock, Sale and View List
parent
25d9c72d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
620 additions
and
672 deletions
+620
-672
Constants.dart
lib/Constants.dart
+34
-7
Home.dart
lib/Home.dart
+10
-11
Identifyproduct.dart
lib/Identifyproduct.dart
+208
-352
Identifystylecode.dart
lib/Identifystylecode.dart
+222
-232
RemoteData.dart
lib/RemoteData.dart
+116
-22
Searchbybarcode.dart
lib/Searchbybarcode.dart
+11
-18
SplashScreen.dart
lib/SplashScreen.dart
+4
-14
Uploadstylecode.dart
lib/Uploadstylecode.dart
+15
-16
No files found.
lib/Constants.dart
View file @
59f975ac
...
@@ -153,11 +153,10 @@ class Constants {
...
@@ -153,11 +153,10 @@ class Constants {
static
showLoader
(
BuildContext
ctx
)
{
static
showLoader
(
BuildContext
ctx
)
{
showDialog
(
showDialog
(
context:
ctx
,
context:
ctx
,
builder:
(
context
)
{
builder:
(
context
)
{
return
const
Center
(
child:
CircularProgressIndicator
());
return
const
Center
(
child:
CircularProgressIndicator
());
}
});
);
}
}
static
Future
<
void
>
dismissAlertDialog1
(
BuildContext
context
)
async
{
static
Future
<
void
>
dismissAlertDialog1
(
BuildContext
context
)
async
{
...
@@ -232,8 +231,7 @@ class Constants {
...
@@ -232,8 +231,7 @@ class Constants {
child:
const
Text
(
"Cancel"
),
child:
const
Text
(
"Cancel"
),
onPressed:
()
{
onPressed:
()
{
Navigator
.
of
(
context
).
pop
();
Navigator
.
of
(
context
).
pop
();
}
});
);
AlertDialog
alert
=
AlertDialog
(
AlertDialog
alert
=
AlertDialog
(
title:
Text
(
title
),
title:
Text
(
title
),
content:
Text
(
message
),
content:
Text
(
message
),
...
@@ -255,6 +253,35 @@ class Constants {
...
@@ -255,6 +253,35 @@ class Constants {
return
dropdownItemHeight
;
return
dropdownItemHeight
;
}
}
static
Showindicator
(
BuildContext
context
,
String
loadertext
)
{
showDialog
(
context:
context
,
barrierDismissible:
false
,
builder:
(
context
)
{
return
Center
(
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
children:
[
const
CircularProgressIndicator
(
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
),
const
SizedBox
(
height:
16
),
// Add some spacing
Text
(
'
$loadertext
...'
,
// Use the dynamic text here
style:
const
TextStyle
(
fontSize:
16
,
decoration:
TextDecoration
.
none
,
color:
Colors
.
white
,
// Set the text color to your preference
),
),
const
SizedBox
(
height:
16
),
],
),
);
});
}
showAlertDialog
(
BuildContext
context
,
bool
val
)
{
showAlertDialog
(
BuildContext
context
,
bool
val
)
{
Widget
okButton
=
TextButton
(
Widget
okButton
=
TextButton
(
child:
const
Text
(
"Cancel"
),
child:
const
Text
(
"Cancel"
),
...
...
lib/Home.dart
View file @
59f975ac
...
@@ -166,6 +166,7 @@ class _Home extends State<Home> {
...
@@ -166,6 +166,7 @@ class _Home extends State<Home> {
),
),
const
Padding
(
padding:
EdgeInsets
.
only
(
left:
10
,
bottom:
10
)),
const
Padding
(
padding:
EdgeInsets
.
only
(
left:
10
,
bottom:
10
)),
Row
(
Row
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
[
children:
[
...
@@ -236,6 +237,7 @@ class _Home extends State<Home> {
...
@@ -236,6 +237,7 @@ class _Home extends State<Home> {
),
),
const
Padding
(
padding:
EdgeInsets
.
only
(
left:
10
,
bottom:
10
)),
const
Padding
(
padding:
EdgeInsets
.
only
(
left:
10
,
bottom:
10
)),
Row
(
Row
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
[
children:
[
...
@@ -324,8 +326,7 @@ class _Home extends State<Home> {
...
@@ -324,8 +326,7 @@ class _Home extends State<Home> {
),
),
padding:
const
EdgeInsets
.
all
(
12
),
padding:
const
EdgeInsets
.
all
(
12
),
child:
const
Column
(
child:
const
Column
(
mainAxisAlignment:
MainAxisAlignment
mainAxisAlignment:
MainAxisAlignment
.
end
,
// Align content at the bottom
.
end
,
// Align content at the bottom
crossAxisAlignment:
CrossAxisAlignment
.
end
,
crossAxisAlignment:
CrossAxisAlignment
.
end
,
children:
[
children:
[
Text
(
Text
(
...
@@ -869,16 +870,14 @@ class _Home extends State<Home> {
...
@@ -869,16 +870,14 @@ class _Home extends State<Home> {
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.90
,
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.90
,
child:
GestureDetector
(
child:
GestureDetector
(
onTap:
()
{
onTap:
()
{
// Navigator.push(
Navigator
.
push
(
context
,
// context,
MaterialPageRoute
(
// MaterialPageRoute(
builder:
(
context
)
=>
// builder: (context) =>
const
Identifyproduct
()),
// const Identifyproduct()),
);
// );
},
},
child:
Container
(
child:
Container
(
margin:
const
EdgeInsets
.
only
(
margin:
const
EdgeInsets
.
only
(
left:
20
,
top:
0
,
right:
2
,
bottom:
0
),
left:
20
,
top:
0
,
right:
2
,
bottom:
0
),
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.100
,
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.100
,
height:
MediaQuery
.
of
(
context
).
size
.
width
*
0.22
,
height:
MediaQuery
.
of
(
context
).
size
.
width
*
0.22
,
padding:
const
EdgeInsets
.
all
(
5
),
padding:
const
EdgeInsets
.
all
(
5
),
...
@@ -902,7 +901,7 @@ class _Home extends State<Home> {
...
@@ -902,7 +901,7 @@ class _Home extends State<Home> {
height:
42
,
height:
42
,
),
// replace with your image
),
// replace with your image
const
Text
(
const
Text
(
'
\t\t\t\t\t\t
IDENTIFY PRODUCT
'
,
'
\t\t\t\t\t\t
DETECT ATTRIBUTES
'
,
style:
Constants
.
buttonsfontStyle
,
style:
Constants
.
buttonsfontStyle
,
)
)
],
],
...
...
lib/Identifyproduct.dart
View file @
59f975ac
...
@@ -7,6 +7,7 @@ import 'package:image_picker/image_picker.dart';
...
@@ -7,6 +7,7 @@ import 'package:image_picker/image_picker.dart';
import
'package:vasthram/Constants.dart'
;
import
'package:vasthram/Constants.dart'
;
import
'package:vasthram/CustomAlertDialog.dart'
;
import
'package:vasthram/CustomAlertDialog.dart'
;
import
'package:vasthram/RemoteData.dart'
;
import
'package:vasthram/RemoteData.dart'
;
import
'CameraScreen.dart'
;
class
Identifyproduct
extends
StatefulWidget
{
class
Identifyproduct
extends
StatefulWidget
{
const
Identifyproduct
({
super
.
key
});
const
Identifyproduct
({
super
.
key
});
...
@@ -21,24 +22,21 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -21,24 +22,21 @@ class _Identifyproduct extends State<Identifyproduct> {
XFile
?
image
;
XFile
?
image
;
bool
isloading
=
false
;
bool
isloading
=
false
;
bool
isVisible
=
true
;
bool
isVisible
=
true
;
bool
isData
=
false
;
bool
isData
=
false
;
String
?
graph
;
String
?
graph
;
String
?
graph1
;
String
?
graph1
;
Uint8List
?
bytes
;
Uint8List
?
bytes
;
Uint8List
?
bytes1
;
Uint8List
?
bytes1
;
var
bodycolor
=
''
;
var
bodycolor
=
''
;
var
bodydesigncolor
=
''
;
var
bordercolor
=
''
;
var
bordercolor
=
''
;
var
bordersize
=
''
;
double
bordersize
=
0.0
;
var
borderworkcolor
=
''
;
var
stylecode
=
''
;
var
stylecode
=
''
;
var
status
=
''
;
var
status
=
''
;
int
similarsale
=
0
;
int
similarstock
=
0
;
late
PageController
_pageController
;
late
PageController
_pageController
;
List
<
Widget
>
pages
=
[];
List
<
Widget
>
pages
=
[];
Uint8List
?
imageBytes
;
Uint8List
?
imageBytes
;
List
<
dynamic
>?
embedding
;
List
<
dynamic
>?
embedding
;
String
?
_base64Image
;
void
_showPicker
(
BuildContext
context
)
{
void
_showPicker
(
BuildContext
context
)
{
showDialog
(
showDialog
(
...
@@ -58,8 +56,8 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -58,8 +56,8 @@ class _Identifyproduct extends State<Identifyproduct> {
style:
Constants
.
dialogbuttonstyle
,
style:
Constants
.
dialogbuttonstyle
,
),
),
onTap:
()
{
onTap:
()
{
_getImageFromCamera
(
0
);
Navigator
.
of
(
context
).
pop
();
Navigator
.
of
(
context
).
pop
();
_navigateToCameraScreen
();
},
},
),
),
const
Padding
(
padding:
EdgeInsets
.
all
(
8.0
)),
const
Padding
(
padding:
EdgeInsets
.
all
(
8.0
)),
...
@@ -81,17 +79,52 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -81,17 +79,52 @@ class _Identifyproduct extends State<Identifyproduct> {
);
);
}
}
Future
<
void
>
_getImageFromCamera
(
int
index
)
async
{
Future
<
void
>
_navigateToCameraScreen
()
async
{
image
=
await
_picker
.
pickImage
(
source
:
ImageSource
.
camera
);
if
(
kDebugMode
)
{
if
(
image
!=
null
)
{
print
(
'Hitting or not'
);
setState
(()
{
}
imagefile
=
File
(
image
!.
path
);
try
{
isVisible
=
true
;
final
imageFile1
=
await
Navigator
.
push
<
File
>(
isData
=
false
;
context
,
//getImage(imagefile);
MaterialPageRoute
(
builder:
(
context
)
=>
CameraScreen
()),
});
);
if
(
imageFile1
!=
null
)
{
if
(
kDebugMode
)
{
print
(
'Camera Capture ==========>
$imageFile1
'
);
}
imagefile
=
imageFile1
;
final
bytes
=
await
imageFile1
.
readAsBytes
();
final
base64String1
=
base64Encode
(
bytes
);
setState
(()
{
_base64Image
=
base64String1
;
});
getStatus
(
imagefile
,
'camera'
);
}
}
catch
(
e
)
{
if
(
kDebugMode
)
{
print
(
'Error navigating to CameraScreen:
$e
'
);
}
}
}
Future
<
void
>
getStatus
(
File
?
imagefile
,
String
type
)
async
{
setState
(()
{
isloading
=
true
;
// Set loading state to true
});
bool
isInternetConnected
=
await
Constants
.
checkInternetConnectivity
();
if
(
isInternetConnected
)
{
Constants
.
Showindicator
(
context
,
'Detecting Saree'
);
var
upload1
=
await
RemoteData
().
uploadimage
(
imagefile
!,
''
);
if
(
upload1
!=
null
)
{
setState
(()
{
isloading
=
false
;
});
var
jsonResponse
=
jsonDecode
(
upload1
);
await
Future
.
delayed
(
const
Duration
(
seconds:
1
));
updateUI
(
jsonResponse
,
type
);
}
}
else
{
}
else
{
image
=
await
_picker
.
pickImage
(
source
:
ImageSource
.
camera
);
setDialog
(
'Check your internet connection'
);
}
}
}
}
...
@@ -106,6 +139,7 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -106,6 +139,7 @@ class _Identifyproduct extends State<Identifyproduct> {
isVisible
=
true
;
isVisible
=
true
;
isData
=
false
;
isData
=
false
;
});
});
getStatus
(
imagefile
,
'gallery'
);
}
}
}
}
...
@@ -177,11 +211,11 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -177,11 +211,11 @@ class _Identifyproduct extends State<Identifyproduct> {
),
),
),
),
padding:
const
EdgeInsets
.
all
(
12
),
padding:
const
EdgeInsets
.
all
(
12
),
child:
Column
(
child:
const
Column
(
children:
[
children:
[
Text
(
Text
(
similarstock
.
toString
()
,
''
,
style:
const
TextStyle
(
style:
TextStyle
(
fontSize:
15
,
fontSize:
15
,
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
),
),
...
@@ -193,13 +227,6 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -193,13 +227,6 @@ class _Identifyproduct extends State<Identifyproduct> {
],
],
),
),
const
Padding
(
padding:
EdgeInsets
.
only
(
left:
10
,
top:
10
)),
const
Padding
(
padding:
EdgeInsets
.
only
(
left:
10
,
top:
10
)),
Container
(
color:
const
Color
.
fromRGBO
(
222
,
221
,
220
,
1
),
child:
Image
.
memory
(
bytes
!,
fit:
BoxFit
.
cover
,
// Adjust as needed
),
),
],
],
),
),
);
);
...
@@ -258,11 +285,11 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -258,11 +285,11 @@ class _Identifyproduct extends State<Identifyproduct> {
),
),
),
),
padding:
const
EdgeInsets
.
all
(
12
),
padding:
const
EdgeInsets
.
all
(
12
),
child:
Column
(
child:
const
Column
(
children:
[
children:
[
Text
(
Text
(
similarsale
.
toString
()
,
''
,
style:
const
TextStyle
(
style:
TextStyle
(
fontSize:
15
,
fontSize:
15
,
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
),
),
...
@@ -290,11 +317,7 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -290,11 +317,7 @@ class _Identifyproduct extends State<Identifyproduct> {
child:
Column
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
<
Widget
>[
children:
<
Widget
>[
if
(
bodycolor
.
isNotEmpty
||
if
(
bodycolor
.
isNotEmpty
||
bordercolor
.
isNotEmpty
)
bodydesigncolor
.
isNotEmpty
||
bordercolor
.
isNotEmpty
||
bordersize
.
isNotEmpty
||
borderworkcolor
.
isNotEmpty
)
Column
(
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
[
children:
[
...
@@ -383,73 +406,6 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -383,73 +406,6 @@ class _Identifyproduct extends State<Identifyproduct> {
bottomLeft:
Radius
.
circular
(
10
),
bottomLeft:
Radius
.
circular
(
10
),
),
),
border:
Border
.
all
(
border:
Border
.
all
(
color:
Colors
.
white
,
width:
1
,
),
),
padding:
const
EdgeInsets
.
all
(
12
),
child:
const
Column
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
crossAxisAlignment:
CrossAxisAlignment
.
end
,
children:
[
Text
(
'
\t
BODY DESIGN COLOR:
\t
'
,
style:
TextStyle
(
fontSize:
14
,
color:
Colors
.
white
,
),
textAlign:
TextAlign
.
right
,
),
],
),
),
),
Flexible
(
flex:
4
,
fit:
FlexFit
.
tight
,
child:
Container
(
decoration:
BoxDecoration
(
color:
const
Color
.
fromARGB
(
255
,
255
,
255
,
255
),
borderRadius:
const
BorderRadius
.
only
(
topRight:
Radius
.
circular
(
10
),
bottomRight:
Radius
.
circular
(
10
),
),
border:
Border
.
all
(
color:
Colors
.
white
,
),
),
padding:
const
EdgeInsets
.
all
(
12
),
child:
Column
(
children:
[
Text
(
bodydesigncolor
,
style:
const
TextStyle
(
fontSize:
15
,
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
),
),
],
),
),
),
],
),
const
Padding
(
padding:
EdgeInsets
.
only
(
left:
10
,
bottom:
8
)),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
[
Flexible
(
flex:
6
,
fit:
FlexFit
.
tight
,
child:
Container
(
decoration:
BoxDecoration
(
color:
const
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
borderRadius:
const
BorderRadius
.
only
(
topLeft:
Radius
.
circular
(
10
),
bottomLeft:
Radius
.
circular
(
10
),
),
border:
Border
.
all
(
color:
Colors
.
white
,
// Set border color to white
color:
Colors
.
white
,
// Set border color to white
width:
1
,
// Set border width
width:
1
,
// Set border width
),
),
...
@@ -509,74 +465,6 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -509,74 +465,6 @@ class _Identifyproduct extends State<Identifyproduct> {
mainAxisAlignment:
MainAxisAlignment
.
start
,
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
[
children:
[
Flexible
(
Flexible
(
flex:
6
,
fit:
FlexFit
.
tight
,
child:
Container
(
decoration:
BoxDecoration
(
color:
const
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
borderRadius:
const
BorderRadius
.
only
(
topLeft:
Radius
.
circular
(
10
),
bottomLeft:
Radius
.
circular
(
10
),
),
border:
Border
.
all
(
color:
Colors
.
white
,
width:
1
,
),
),
padding:
const
EdgeInsets
.
all
(
12
),
child:
const
Column
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
crossAxisAlignment:
CrossAxisAlignment
.
end
,
children:
[
Text
(
'
\t
BORDER WORK COLOR:
\t
'
,
style:
TextStyle
(
fontSize:
14
,
color:
Colors
.
white
,
),
textAlign:
TextAlign
.
right
,
),
],
),
),
),
Flexible
(
flex:
4
,
fit:
FlexFit
.
tight
,
child:
Container
(
decoration:
BoxDecoration
(
color:
const
Color
.
fromARGB
(
255
,
255
,
255
,
255
),
borderRadius:
const
BorderRadius
.
only
(
topRight:
Radius
.
circular
(
10
),
bottomRight:
Radius
.
circular
(
10
),
),
border:
Border
.
all
(
color:
Colors
.
white
,
width:
1
,
),
),
padding:
const
EdgeInsets
.
all
(
12
),
child:
Column
(
children:
[
Text
(
borderworkcolor
,
style:
const
TextStyle
(
fontSize:
15
,
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
),
),
],
),
),
),
],
),
const
Padding
(
padding:
EdgeInsets
.
only
(
left:
10
,
bottom:
8
)),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
[
Flexible
(
flex:
6
,
// 60% of the width
flex:
6
,
// 60% of the width
fit:
FlexFit
.
tight
,
fit:
FlexFit
.
tight
,
child:
Container
(
child:
Container
(
...
@@ -628,7 +516,7 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -628,7 +516,7 @@ class _Identifyproduct extends State<Identifyproduct> {
child:
Column
(
child:
Column
(
children:
[
children:
[
Text
(
Text
(
bordersize
,
bordersize
.
toString
()
,
style:
const
TextStyle
(
style:
const
TextStyle
(
fontSize:
15
,
fontSize:
15
,
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
...
@@ -642,74 +530,74 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -642,74 +530,74 @@ class _Identifyproduct extends State<Identifyproduct> {
),
),
//stylecode.isNotEmpty
//stylecode.isNotEmpty
const
Padding
(
padding:
EdgeInsets
.
only
(
left:
10
,
bottom:
8
)),
//
const Padding(padding: EdgeInsets.only(left: 10, bottom: 8)),
Row
(
//
Row(
mainAxisAlignment:
MainAxisAlignment
.
start
,
//
mainAxisAlignment: MainAxisAlignment.start,
children:
[
//
children: [
Flexible
(
//
Flexible(
flex:
6
,
// 60% of the width
//
flex: 6, // 60% of the width
fit:
FlexFit
.
tight
,
//
fit: FlexFit.tight,
child:
Container
(
//
child: Container(
decoration:
BoxDecoration
(
//
decoration: BoxDecoration(
color:
const
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
//
color: const Color.fromARGB(255, 69, 66, 121),
borderRadius:
const
BorderRadius
.
only
(
//
borderRadius: const BorderRadius.only(
topLeft:
Radius
.
circular
(
10
),
//
topLeft: Radius.circular(10),
bottomLeft:
Radius
.
circular
(
10
),
//
bottomLeft: Radius.circular(10),
),
//
),
border:
Border
.
all
(
//
border: Border.all(
color:
Colors
.
white
,
// Set border color to white
//
color: Colors.white, // Set border color to white
width:
1
,
// Set border width
//
width: 1, // Set border width
),
//
),
),
//
),
padding:
const
EdgeInsets
.
all
(
12
),
//
padding: const EdgeInsets.all(12),
child:
const
Column
(
//
child: const Column(
mainAxisAlignment:
MainAxisAlignment
//
mainAxisAlignment: MainAxisAlignment
.
end
,
// Align content at the bottom
//
.end, // Align content at the bottom
crossAxisAlignment:
CrossAxisAlignment
.
end
,
//
crossAxisAlignment: CrossAxisAlignment.end,
children:
[
//
children: [
Text
(
//
Text(
'
\t
STYLE CODE:
\t
'
,
//
'\t STYLE CODE: \t',
style:
TextStyle
(
//
style: TextStyle(
fontSize:
14
,
//
fontSize: 14,
color:
Colors
.
white
,
//
color: Colors.white,
),
//
),
textAlign:
TextAlign
.
right
,
//
textAlign: TextAlign.right,
),
//
),
],
//
],
),
//
),
),
//
),
),
//
),
Flexible
(
//
Flexible(
flex:
4
,
// 40% of the width
//
flex: 4, // 40% of the width
fit:
FlexFit
.
tight
,
//
fit: FlexFit.tight,
child:
Container
(
//
child: Container(
decoration:
BoxDecoration
(
//
decoration: BoxDecoration(
color:
const
Color
.
fromARGB
(
255
,
255
,
255
,
255
),
//
color: const Color.fromARGB(255, 255, 255, 255),
borderRadius:
const
BorderRadius
.
only
(
//
borderRadius: const BorderRadius.only(
topRight:
Radius
.
circular
(
10
),
//
topRight: Radius.circular(10),
bottomRight:
Radius
.
circular
(
10
),
//
bottomRight: Radius.circular(10),
),
//
),
border:
Border
.
all
(
//
border: Border.all(
color:
Colors
.
white
,
// Set border color to white
//
color: Colors.white, // Set border color to white
width:
1
,
// Set border width
//
width: 1, // Set border width
),
//
),
),
//
),
padding:
const
EdgeInsets
.
all
(
12
),
//
padding: const EdgeInsets.all(12),
child:
Column
(
//
child: Column(
children:
[
//
children: [
Text
(
//
Text(
stylecode
,
//
stylecode,
style:
const
TextStyle
(
//
style: const TextStyle(
fontSize:
15
,
//
fontSize: 15,
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
//
color: Color.fromARGB(255, 69, 66, 121),
),
//
),
),
//
),
],
//
],
),
//
),
),
//
),
),
//
),
],
//
],
),
//
),
],
],
)
)
else
else
...
@@ -783,22 +671,19 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -783,22 +671,19 @@ class _Identifyproduct extends State<Identifyproduct> {
_showPicker
(
context
);
_showPicker
(
context
);
},
},
child:
SizedBox
(
child:
SizedBox
(
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.
88
,
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.
90
,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.50
,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.50
,
child:
imagefil
e
!=
null
child:
_base64Imag
e
!=
null
?
Image
.
file
(
?
Image
.
memory
(
imagefile
!
,
base64Decode
(
_base64Image
!)
,
fit:
BoxFit
.
cover
,
fit:
BoxFit
.
cover
,
)
)
:
Center
(
:
Center
(
child:
Image
.
asset
(
child:
Image
.
asset
(
'assets/images/camera.png'
,
'assets/images/camera.png'
,
width:
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.50
,
// Adjusted width
MediaQuery
.
of
(
context
).
size
.
width
*
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.35
,
// Adjusted height
0.50
,
// Adjusted width
fit:
BoxFit
.
cover
,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.35
,
// Adjusted height
),
),
),
),
),
),
...
@@ -814,97 +699,14 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -814,97 +699,14 @@ class _Identifyproduct extends State<Identifyproduct> {
controller:
_pageController
,
controller:
_pageController
,
children:
pages
=
[
children:
pages
=
[
buildPage1
(
'Page 1'
),
buildPage1
(
'Page 1'
),
buildPage2
(
'Page 2'
),
//
buildPage2('Page 2'),
buildPage3
(
'Page 3'
),
//
buildPage3('Page 3'),
],
],
),
),
),
),
SizedBox
(
SizedBox
(
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.28
,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.28
,
),
),
Visibility
(
visible:
isVisible
,
child:
SizedBox
(
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.90
,
child:
GestureDetector
(
onTap:
()
async
{
if
(
imagefile
==
null
)
{
setDialog
(
'Please Capture Image'
);
}
else
{
setState
(()
{
isloading
=
true
;
// Set loading state to true
});
bool
isInternetConnected
=
await
Constants
.
checkInternetConnectivity
();
if
(
isInternetConnected
)
{
showDialog
(
context:
context
,
barrierDismissible:
false
,
builder:
(
context
)
{
return
const
Center
(
child:
CircularProgressIndicator
(
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
),
);
});
var
upload
=
await
RemoteData
()
.
uploadimage
(
imagefile
!,
''
);
if
(
upload
!=
null
)
{
setState
(()
{
isloading
=
false
;
});
var
jsonResponse
=
jsonDecode
(
upload
);
await
Future
.
delayed
(
const
Duration
(
seconds:
1
));
updateUI
(
jsonResponse
);
}
if
(
Navigator
.
of
(
context
).
canPop
())
{
if
(
kDebugMode
)
{
print
(
'Testing =========>'
);
}
Navigator
.
of
(
context
).
pop
();
}
}
else
{
setDialog
(
'Check your internet connection'
);
}
}
},
child:
Container
(
margin:
const
EdgeInsets
.
only
(
left:
10
,
top:
0
,
right:
2
,
bottom:
0
),
width:
MediaQuery
.
of
(
context
).
size
.
width
*
0.100
,
height:
MediaQuery
.
of
(
context
).
size
.
width
*
0.13
,
padding:
const
EdgeInsets
.
all
(
5
),
decoration:
BoxDecoration
(
gradient:
const
LinearGradient
(
begin:
Alignment
.
bottomLeft
,
end:
Alignment
.
bottomRight
,
colors:
[
Color
.
fromARGB
(
255
,
227
,
144
,
214
),
//Color(0xFFC2185B),
Color
.
fromARGB
(
255
,
125
,
174
,
251
),
],
),
borderRadius:
BorderRadius
.
circular
(
50
),
),
child:
const
Row
(
children:
[
Text
(
'
\t\t
'
),
Expanded
(
child:
Center
(
child:
Text
(
'IDENTIFY PRODUCT'
,
style:
Constants
.
buttonsfontStyle
,
textAlign:
TextAlign
.
center
,
),
),
),
],
),
),
),
),
),
const
Text
(
'
\n\n
'
)
const
Text
(
'
\n\n
'
)
],
],
),
),
...
@@ -915,35 +717,89 @@ class _Identifyproduct extends State<Identifyproduct> {
...
@@ -915,35 +717,89 @@ class _Identifyproduct extends State<Identifyproduct> {
);
);
}
}
void
updateUI
(
Map
<
String
,
dynamic
>
jsonResponse
)
{
Future
<
void
>
updateUI
(
Map
<
String
,
dynamic
>
jsonResponse1
,
String
type
)
async
{
Navigator
.
of
(
context
).
pop
();
print
(
'Response Data :
$jsonResponse1
'
);
var
saree
=
jsonResponse1
[
'saree_detected'
];
if
(
kDebugMode
)
{
print
(
saree
);
}
if
(
saree
==
'Yes'
)
{
var
bodyimage
=
jsonResponse1
[
'body_metrics'
][
3
];
var
annotated_image
=
jsonResponse1
[
'annotated_image'
];
setState
(()
{
_base64Image
=
annotated_image
;
});
print
(
bodyimage
);
try
{
Constants
.
Showindicator
(
context
,
'Identify Product'
);
var
upload
=
await
RemoteData
().
detectAttributes
(
imagefile
!,
bodyimage
);
var
json
=
jsonDecode
(
upload
!);
await
Future
.
delayed
(
const
Duration
(
seconds:
1
));
getupdate
(
json
);
}
catch
(
e
)
{
print
(
'verified
$e
'
);
return
;
}
return
;
}
else
{
if
(
type
==
'camera'
)
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
CustomAlertDialog
(
titleText:
'WARNING !
\t
'
,
contentText:
'Saree Not Detected'
,
buttonText:
'No'
,
onButtonPressed:
()
{
Navigator
.
of
(
context
).
pop
();
},
secondButtonText:
'Yes'
,
onSecondButtonPressed:
()
{
Navigator
.
of
(
context
).
pop
();
Future
.
delayed
(
const
Duration
(
milliseconds:
200
),
()
{
_navigateToCameraScreen
();
});
},
icon:
const
Icon
(
Icons
.
info
),
);
},
);
}
else
{
_getImageFromGallery
(
context
);
}
}
}
void
getupdate
(
Map
<
String
,
dynamic
>
jsonResponse
)
{
print
(
'Hitting ot npt
$jsonResponse
'
);
Navigator
.
of
(
context
).
pop
();
setState
(()
{
isloading
=
false
;
});
isData
=
true
;
//isVisible = false;
setState
(()
{
setState
(()
{
isData
=
true
;
isData
=
true
;
isVisible
=
false
;
isVisible
=
false
;
status
=
jsonResponse
[
'status'
];
status
=
jsonResponse
[
'status'
]!;
print
(
status
);
if
(
status
==
'Success'
)
{
if
(
status
==
'Success'
)
{
bodycolor
=
jsonResponse
[
'body_color'
];
bodycolor
=
jsonResponse
[
'body_color'
]!;
bodydesigncolor
=
jsonResponse
[
'body_design_color'
];
bordercolor
=
jsonResponse
[
'border_color'
]!;
bordercolor
=
jsonResponse
[
'border_color'
];
bordersize
=
jsonResponse
[
'border_size'
];
bordersize
=
jsonResponse
[
'border_size'
];
borderworkcolor
=
jsonResponse
[
'border_design_color'
];
_base64Image
=
jsonResponse
[
'image'
];
stylecode
=
jsonResponse
[
'stylecode'
];
//stylecode = jsonResponse['stylecode']!;
similarsale
=
jsonResponse
[
'similarsale'
];
similarstock
=
jsonResponse
[
'similarstock'
];
bytes
=
base64
.
decode
(
jsonResponse
[
'similarstockgraph'
]);
bytes1
=
base64
.
decode
(
jsonResponse
[
'similarsalegraph'
]);
}
else
{
}
else
{
setDialog
(
'Could not found
image
'
);
setDialog
(
'Could not found
IdentifyProduct
'
);
bodycolor
=
''
;
bodycolor
=
''
;
bodydesigncolor
=
''
;
bordercolor
=
''
;
bordercolor
=
''
;
bordersize
=
''
;
bordersize
=
0.0
;
borderworkcolor
=
''
;
stylecode
=
''
;
stylecode
=
''
;
bytes
!.
clear
();
bytes1
!.
clear
();
embedding
!.
clear
();
}
}
});
});
print
(
'Hitting ot npt
$jsonResponse
'
);
}
}
void
setDialog
(
String
text
)
{
void
setDialog
(
String
text
)
{
...
...
lib/Identifystylecode.dart
View file @
59f975ac
...
@@ -5,7 +5,6 @@ import 'package:camera/camera.dart';
...
@@ -5,7 +5,6 @@ import 'package:camera/camera.dart';
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:tflite_flutter/tflite_flutter.dart'
;
import
'package:vasthram/CameraScreen.dart'
;
import
'package:vasthram/CameraScreen.dart'
;
import
'package:vasthram/Constants.dart'
;
import
'package:vasthram/Constants.dart'
;
import
'package:vasthram/RemoteData.dart'
;
import
'package:vasthram/RemoteData.dart'
;
...
@@ -42,13 +41,9 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -42,13 +41,9 @@ class _Identifystylecode extends State<Identifystylecode> {
List
<
Widget
>
pages
=
[];
List
<
Widget
>
pages
=
[];
Uint8List
?
imageBytes
;
Uint8List
?
imageBytes
;
List
<
dynamic
>?
embedding
;
List
<
dynamic
>?
embedding
;
late
Interpreter
_interpreter
;
bool
_isCameraInitialized
=
false
;
bool
_isPictureTaken
=
false
;
List
<
Stylecode
>?
closestStylecodes
;
List
<
Stylecode
>?
closestStylecodes
;
File
?
imagefile0
;
File
?
imagefile0
;
CameraController
?
controller
;
CameraController
?
controller
;
late
Future
<
void
>
_initializeControllerFuture
;
String
?
_base64Image
;
String
?
_base64Image
;
// void getImage(File? imagefile) {
// void getImage(File? imagefile) {
...
@@ -87,8 +82,7 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -87,8 +82,7 @@ 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
(
final
frontCamera
=
cameras
.
firstWhere
((
camera
)
=>
camera
.
lensDirection
==
CameraLensDirection
.
back
);
(
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'
);
...
@@ -99,36 +93,12 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -99,36 +93,12 @@ class _Identifystylecode extends State<Identifystylecode> {
await
controller
!.
initialize
();
await
controller
!.
initialize
();
}
}
Future
<
void
>
takePicture
()
async
{
if
(
controller
==
null
||
!
controller
!.
value
.
isInitialized
)
{
await
initializeCamera
();
}
// Take a picture
final
XFile
?
picture
=
await
controller
!.
takePicture
();
if
(
picture
!=
null
)
{
setState
(()
{
imagefile
=
File
(
picture
.
path
);
_isPictureTaken
=
true
;
});
}
print
(
'Picture taken at:
${picture!.path}
'
);
}
Future
<
void
>
_navigateToCameraScreen
()
async
{
Future
<
void
>
_navigateToCameraScreen
()
async
{
if
(
kDebugMode
)
{
print
(
'Hitting or not'
);
}
try
{
try
{
final
imageFile1
=
await
Navigator
.
push
<
File
>(
final
imageFile1
=
await
Navigator
.
push
<
File
>(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
CameraScreen
()));
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
CameraScreen
()),
);
if
(
imageFile1
!=
null
)
{
if
(
imageFile1
!=
null
)
{
if
(
kDebugMode
)
{
imagefile
=
imageFile1
;
print
(
'Camera Capture ==========>
$imageFile1
'
);
final
bytes
=
await
imageFile1
.
readAsBytes
();
}
imagefile
=
imageFile1
;
final
bytes
=
await
imageFile1
.
readAsBytes
();
final
base64String1
=
base64Encode
(
bytes
);
final
base64String1
=
base64Encode
(
bytes
);
setState
(()
{
setState
(()
{
_base64Image
=
base64String1
;
_base64Image
=
base64String1
;
...
@@ -184,23 +154,23 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -184,23 +154,23 @@ class _Identifystylecode extends State<Identifystylecode> {
);
);
}
}
Future
<
void
>
_getImageFromCamera
()
async
{
//
Future<void> _getImageFromCamera() async {
try
{
//
try {
final
pickedFile
=
await
_picker
.
pickImage
(
source
:
ImageSource
.
camera
);
//
final pickedFile = await _picker.pickImage(source: ImageSource.camera);
//Navigator.of(context).pop();
//
//Navigator.of(context).pop();
if
(
pickedFile
!=
null
)
{
//
if (pickedFile != null) {
setState
(()
{
//
setState(() {
imagefile
=
File
(
pickedFile
.
path
);
//
imagefile = File(pickedFile.path);
isVisible
=
true
;
//
isVisible = true;
isData
=
false
;
//
isData = false;
});
//
});
}
else
{
//
} else {
print
(
"No image picked"
);
//
print("No image picked");
}
//
}
}
catch
(
e
)
{
//
} catch (e) {
print
(
"Error while picking image from camera:
$e
"
);
//
print("Error while picking image from camera: $e");
}
//
}
}
//
}
Future
<
void
>
_getImageFromGallery
(
BuildContext
context
)
async
{
Future
<
void
>
_getImageFromGallery
(
BuildContext
context
)
async
{
image
=
await
_picker
.
pickImage
(
source
:
ImageSource
.
gallery
);
image
=
await
_picker
.
pickImage
(
source
:
ImageSource
.
gallery
);
...
@@ -224,24 +194,22 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -224,24 +194,22 @@ class _Identifystylecode extends State<Identifystylecode> {
//loadModel();
//loadModel();
}
}
Future
<
void
>
loadModel
()
async
{
// Future<void> loadModel() async {
String
?
modelPath
=
'assets/images/model.tflite'
;
// String? modelPath = 'assets/images/model.tflite';
if
(
kDebugMode
)
{
// if (kDebugMode) {
print
(
'Loading interpreter options...'
);
// print('Loading interpreter options...');
}
// }
final
interpreterOptions
=
InterpreterOptions
();
// final interpreterOptions = InterpreterOptions();
if
(
Platform
.
isAndroid
)
{
// if (Platform.isAndroid) {
interpreterOptions
.
addDelegate
(
XNNPackDelegate
());
// interpreterOptions.addDelegate(XNNPackDelegate());
}
// }
if
(
Platform
.
isIOS
)
{
// if (Platform.isIOS) {
interpreterOptions
.
addDelegate
(
GpuDelegate
());
// interpreterOptions.addDelegate(GpuDelegate());
}
// }
if
(
kDebugMode
)
{
// if (kDebugMode) {
print
(
'Loading interpreter...'
);
// print('Loading interpreter...');
}
// }
_interpreter
=
// }
await
Interpreter
.
fromAsset
(
modelPath
,
options:
interpreterOptions
);
}
@override
@override
void
dispose
()
{
void
dispose
()
{
...
@@ -323,7 +291,7 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -323,7 +291,7 @@ class _Identifystylecode extends State<Identifystylecode> {
color:
const
Color
.
fromRGBO
(
222
,
221
,
220
,
1
),
color:
const
Color
.
fromRGBO
(
222
,
221
,
220
,
1
),
child:
Image
.
memory
(
child:
Image
.
memory
(
bytes
!,
bytes
!,
fit:
BoxFit
.
co
ver
,
// Adjust as needed
fit:
BoxFit
.
co
ntain
,
// Adjust as needed
),
),
),
),
],
],
...
@@ -418,71 +386,117 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -418,71 +386,117 @@ class _Identifystylecode extends State<Identifystylecode> {
mainAxisAlignment:
MainAxisAlignment
.
start
,
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
<
Widget
>[
children:
<
Widget
>[
if
(
closestStylecodes
!.
isNotEmpty
)
if
(
closestStylecodes
!.
isNotEmpty
)
ListView
.
builder
(
Expanded
(
shrinkWrap:
true
,
// Use Expanded to ensure ListView gets the remaining space
itemCount:
closestStylecodes
!.
length
,
child:
ListView
.
builder
(
itemBuilder:
(
context
,
index
)
{
itemCount:
closestStylecodes
!.
length
,
return
Card
(
itemBuilder:
(
context
,
index
)
{
child:
ListTile
(
return
Card
(
title:
Text
(
child:
Column
(
'Style Code
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
:
${closestStylecodes![index].styleCode}
'
,
style:
Constants
.
headerfontStyle
,
),
subtitle:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
children:
[
Text
(
ListTile
(
'Similarity Percentage :
${closestStylecodes![index].SimilarityPercentage ?? 'None'}${closestStylecodes![index].SimilarityPercentage != 'None' ? '%' : ''}
'
,
title:
Text
(
style:
Constants
.
headerfontStyle
,
'Style Code
\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
:
${closestStylecodes![index].styleCode!.toUpperCase()}
'
,
style:
Constants
.
headerfontStyle
,
),
subtitle:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
const
SizedBox
(
height:
8
,
),
Text
(
'Similarity Percentage
\t
:
${closestStylecodes![index].SimilarityPercentage ?? 'None'}${closestStylecodes![index].SimilarityPercentage != 'None' ? '%' : ''}
'
,
style:
Constants
.
headerfontStyle
,
),
],
),
onTap:
()
{},
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
ElevatedButton
(
onPressed:
()
{
Constants
.
Showindicator
(
context
,
'Loading Data ...'
);
getStock
(
closestStylecodes
![
index
].
styleCode
);
},
style:
ElevatedButton
.
styleFrom
(
backgroundColor:
const
Color
.
fromARGB
(
255
,
69
,
66
,
121
),),
child:
const
Text
(
'Stock'
,
style:
TextStyle
(
color:
Colors
.
white
),
),
),
const
SizedBox
(
width:
16
),
ElevatedButton
(
onPressed:
()
{
Constants
.
Showindicator
(
context
,
'Loading Data ...'
);
getSale
(
closestStylecodes
![
index
].
styleCode
);
},
style:
ElevatedButton
.
styleFrom
(
backgroundColor:
const
Color
.
fromARGB
(
255
,
69
,
66
,
121
)),
child:
const
Text
(
'
\t
Sale
\t
'
,
style:
TextStyle
(
color:
Colors
.
white
)),
),
const
SizedBox
(
width:
16
),
ElevatedButton
(
onPressed:
()
{
if
(
closestStylecodes
![
index
].
similarImagePath
!=
'No Saree'
)
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
AlertDialog
(
title:
const
Text
(
'Style Code Details'
),
content:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
'Style Code:
${closestStylecodes![index].styleCode}
'
,
style:
Constants
.
headerfontStyle
,
),
Text
(
'Similarity Percentage:
${closestStylecodes![index].SimilarityPercentage ?? 'None'}${closestStylecodes![index].SimilarityPercentage != 'None' ? '%' : ''}
'
,
style:
Constants
.
headerfontStyle
,
),
Image
.
network
(
closestStylecodes
![
index
]
.
similarImagePath
!,
width:
200
,
height:
200
,
),
],
),
actions:
[
TextButton
(
child:
const
Text
(
'Close'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
();
},
),
],
);
},
);
}
},
style:
ElevatedButton
.
styleFrom
(
backgroundColor:
const
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
// Background color
),
child:
const
Text
(
'
\t
View
\t
'
,
style:
TextStyle
(
color:
Colors
.
white
),
),
),
],
),
),
const
SizedBox
(
height:
5
),
],
],
),
),
onTap:
()
{
);
if
(
closestStylecodes
![
index
].
similarImagePath
==
},
'None'
)
{
),
}
else
if
(
closestStylecodes
![
index
].
similarImagePath
==
'None'
)
{
}
else
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
AlertDialog
(
title:
const
Text
(
'Style Code Details'
),
content:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
'Style Code:
${closestStylecodes![index].styleCode}
'
,
style:
Constants
.
headerfontStyle
,
),
Text
(
'Similarity Percentage
\t\t\t\t
:
${closestStylecodes![index].SimilarityPercentage ?? 'None'}${closestStylecodes![index].SimilarityPercentage != 'None' ? '%' : ''}
'
,
style:
Constants
.
headerfontStyle
,
),
Image
.
network
(
closestStylecodes
![
index
].
similarImagePath
!,
width:
200
,
height:
200
,
),
],
),
actions:
[
TextButton
(
child:
const
Text
(
'Close'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
();
},
),
],
);
},
);
}
},
),
);
},
)
)
else
else
const
SizedBox
(
const
SizedBox
(
...
@@ -505,6 +519,70 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -505,6 +519,70 @@ class _Identifystylecode extends State<Identifystylecode> {
);
);
}
}
getStock
(
String
?
text
)
{
var
response
=
RemoteData
().
stockData
(
text
!);
response
.
then
((
value
)
{
Navigator
.
of
(
context
).
pop
();
final
Map
<
String
,
dynamic
>
data
=
jsonDecode
(
value
);
_showListDialog
(
context
,
data
,
'Stock Data'
);
});
}
getSale
(
String
?
text
)
{
var
response
=
RemoteData
().
saleData
(
text
!);
response
.
then
((
value
)
{
Navigator
.
of
(
context
).
pop
();
final
Map
<
String
,
dynamic
>
data
=
jsonDecode
(
value
);
_showListDialog
(
context
,
data
,
'Sale Data'
);
});
}
void
_showListDialog
(
BuildContext
context
,
Map
<
String
,
dynamic
>
data
,
String
header
)
{
showDialog
(
context:
context
,
builder:
(
BuildContext
context
)
{
return
AlertDialog
(
title:
Text
(
header
),
content:
SizedBox
(
// Set the height and width of the container
width:
double
.
maxFinite
,
child:
ListView
.
builder
(
shrinkWrap:
true
,
itemCount:
data
.
keys
.
length
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
String
key
=
data
.
keys
.
elementAt
(
index
);
String
value
=
data
[
key
].
toString
();
if
(
key
==
'Average GST Margin 90 days'
)
{
value
=
'₹
$value
'
;
}
if
(
key
==
'STORES'
)
{
value
=
value
.
substring
(
1
,
value
.
length
-
1
);
}
return
ListTile
(
title:
Text
(
key
),
subtitle:
Text
(
value
,
style:
const
TextStyle
(
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
)),
),
);
},
),
),
actions:
[
TextButton
(
child:
const
Text
(
'Close'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
();
},
),
],
);
},
);
}
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
return
Scaffold
(
...
@@ -616,85 +694,6 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -616,85 +694,6 @@ class _Identifystylecode extends State<Identifystylecode> {
SizedBox
(
SizedBox
(
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.28
,
height:
MediaQuery
.
of
(
context
).
size
.
height
*
0.28
,
),
),
// Visibility(
// visible: isVisible,
// child: SizedBox(
// width: MediaQuery.of(context).size.width * 0.90,
// child: GestureDetector(
// onTap: () async {
// if (imagefile == null) {
// setDialog('Please Capture Image');
// } else {
// setState(() {
// isloading = true; // Set loading state to true
// });
// bool isInternetConnected =
// await Constants.checkInternetConnectivity();
// if (isInternetConnected) {
// showDialog(
// context: context,
// barrierDismissible: false,
// builder: (context) {
// return const Center(
// child: CircularProgressIndicator(
// color: Color.fromARGB(255, 69, 66, 121),
// ),
// );
// });
// var upload1 = await RemoteData()
// .uploadimage(imagefile!, '');
// if (upload1 != null) {
// setState(() {
// isloading = false;
// });
// var jsonResponse = jsonDecode(upload1);
// await Future.delayed(
// const Duration(seconds: 1));
// updateUI(jsonResponse);
// }
// if (Navigator.of(context).canPop()) {
// //Navigator.of(context).pop();
// }
// } else {
// setDialog('Check your internet connection');
// }
// }
// },
// child: Container(
// margin: const EdgeInsets.only(
// left: 10, top: 0, right: 2, bottom: 0),
// width: MediaQuery.of(context).size.width * 0.100,
// height: MediaQuery.of(context).size.width * 0.13,
// padding: const EdgeInsets.all(5),
// decoration: BoxDecoration(
// gradient: const LinearGradient(
// begin: Alignment.bottomLeft,
// end: Alignment.bottomRight,
// colors: [
// Color.fromARGB(255, 227, 144, 214),
// Color.fromARGB(255, 125, 174, 251),
// ],
// ),
// borderRadius: BorderRadius.circular(50),
// ),
// child: const Row(
// children: [
// Text('\t\t'),
// Expanded(
// child: Center(
// child: Text(
// 'IDENTIFY STYLE CODE',
// style: Constants.buttonsfontStyle,
// textAlign: TextAlign.center,
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// ),
// ),
const
Text
(
'
\n\n
'
)
const
Text
(
'
\n\n
'
)
],
],
),
),
...
@@ -728,26 +727,27 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -728,26 +727,27 @@ class _Identifystylecode extends State<Identifystylecode> {
Future
<
void
>
updateUI
(
Map
<
String
,
dynamic
>
jsonResponse1
,
String
type
)
async
{
Future
<
void
>
updateUI
(
Map
<
String
,
dynamic
>
jsonResponse1
,
String
type
)
async
{
Navigator
.
of
(
context
).
pop
();
Navigator
.
of
(
context
).
pop
();
print
(
'Response Data :
$jsonResponse1
'
);
//
print('Response Data : $jsonResponse1');
var
saree
=
jsonResponse1
[
'saree_detected'
];
var
saree
=
jsonResponse1
[
'saree_detected'
];
if
(
kDebugMode
)
{
if
(
kDebugMode
)
{
print
(
saree
);
print
(
saree
);
}
}
if
(
saree
==
'Yes'
)
{
if
(
saree
==
'Yes'
)
{
var
bodyimage
=
jsonResponse1
[
'body_metrics'
][
0
];
var
bodyimage
=
jsonResponse1
[
'body_metrics'
][
3
];
var
annotated
_
image
=
jsonResponse1
[
'annotated_image'
];
var
annotatedimage
=
jsonResponse1
[
'annotated_image'
];
setState
(()
{
setState
(()
{
_base64Image
=
annotated
_
image
;
_base64Image
=
annotatedimage
;
});
});
print
(
bodyimage
);
//
print(bodyimage);
try
{
try
{
Constants
.
Showindicator
(
context
,
'Identify stylecode'
);
var
upload
=
var
upload
=
await
RemoteData
().
IdentifyStyleCode
(
imagefile
!,
bodyimage
);
await
RemoteData
().
IdentifyStyleCode
(
imagefile
!,
bodyimage
);
//var json = jsonDecode(upload!);
//var json = jsonDecode(upload!);
await
Future
.
delayed
(
const
Duration
(
seconds:
1
));
await
Future
.
delayed
(
const
Duration
(
seconds:
1
));
getupdate
(
upload
!);
getupdate
(
upload
!);
}
catch
(
e
)
{
}
catch
(
e
)
{
print
(
e
);
//
print(e);
return
;
return
;
}
}
return
;
return
;
...
@@ -782,11 +782,10 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -782,11 +782,10 @@ 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
();
var
json
=
setState
(()
{
'[{"Similarity Percentage":"12","Stylecode":"Black","imageURL":"http://google.com"}]'
;
isloading
=
false
;
//List<dynamic> closestStylecodesList = jsonDecode(jsonResponse);
});
//jsonResponse['Closest Stylecodes'];
isData
=
true
;
isData
=
true
;
//isVisible = false;
//isVisible = false;
setState
(()
{
setState
(()
{
...
@@ -807,16 +806,7 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -807,16 +806,7 @@ class _Identifystylecode extends State<Identifystylecode> {
});
});
bool
isInternetConnected
=
await
Constants
.
checkInternetConnectivity
();
bool
isInternetConnected
=
await
Constants
.
checkInternetConnectivity
();
if
(
isInternetConnected
)
{
if
(
isInternetConnected
)
{
showDialog
(
Constants
.
Showindicator
(
context
,
'Detecting Saree'
);
context:
context
,
barrierDismissible:
false
,
builder:
(
context
)
{
return
const
Center
(
child:
CircularProgressIndicator
(
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
),
);
});
var
upload1
=
await
RemoteData
().
uploadimage
(
imagefile
!,
''
);
var
upload1
=
await
RemoteData
().
uploadimage
(
imagefile
!,
''
);
if
(
upload1
!=
null
)
{
if
(
upload1
!=
null
)
{
setState
(()
{
setState
(()
{
...
@@ -833,7 +823,7 @@ class _Identifystylecode extends State<Identifystylecode> {
...
@@ -833,7 +823,7 @@ class _Identifystylecode extends State<Identifystylecode> {
}
}
class
Stylecode
{
class
Stylecode
{
final
String
?
SimilarityPercentage
;
final
int
?
SimilarityPercentage
;
final
String
?
similarImagePath
;
final
String
?
similarImagePath
;
final
String
?
styleCode
;
final
String
?
styleCode
;
...
...
lib/RemoteData.dart
View file @
59f975ac
...
@@ -6,13 +6,17 @@ import 'package:http/http.dart' as http;
...
@@ -6,13 +6,17 @@ import 'package:http/http.dart' as http;
class
RemoteData
{
class
RemoteData
{
final
String
loginUrl
=
'http://vaman.plutokm.com/login'
;
final
String
loginUrl
=
'http://vaman.plutokm.com/login'
;
final
String
Uploadimage
=
'http://vaman.plutokm.com/vasthram_mobile'
;
final
String
imageupload
=
'http://vaman.plutokm.com/vasthram_mobile'
;
final
String
I
dentifystylecode
=
'https://vaman.plutokm.com/get_vasthram_style_code'
;
final
String
i
dentifystylecode
=
'https://vaman.plutokm.com/get_vasthram_style_code'
;
final
String
registerstylecode
=
'https://vaman.plutokm.com/register_style_code'
;
final
String
registerstylecode
=
'https://vaman.plutokm.com/register_style_code'
;
final
String
detectattributes
=
'https://vaman.plutokm.com/detect_attributes'
;
final
String
sale
=
'https://vaman.plutokm.com/stylecode_sales_data'
;
final
String
stock
=
'https://vaman.plutokm.com/stylecode_stock_data'
;
final
String
type
=
'Content-Type'
;
final
String
type
=
'Content-Type'
;
final
String
appjson
=
'application/json'
;
final
String
appjson
=
'application/json'
;
Future
<
String
>
getLoginRequest
(
String
loginid
,
String
pass
,
String
token
)
async
{
Future
<
String
>
getLoginRequest
(
String
loginid
,
String
pass
,
String
token
)
async
{
Map
<
String
,
dynamic
>
body
=
{
Map
<
String
,
dynamic
>
body
=
{
'login_id'
:
loginid
,
'login_id'
:
loginid
,
'password'
:
pass
,
'password'
:
pass
,
...
@@ -36,16 +40,19 @@ class RemoteData {
...
@@ -36,16 +40,19 @@ class RemoteData {
}
}
}
}
Future
<
String
?>
uploadimage
(
File
imagepath
,
String
embedding
)
async
{
Future
<
String
>
stockData
(
String
stylecode
)
async
{
print
(
stylecode
);
try
{
try
{
final
request
=
http
.
MultipartRequest
(
'POST'
,
Uri
.
parse
(
'http://vaman.plutokm.com/detect_saree'
));
final
request
=
http
.
MultipartRequest
(
'POST'
,
Uri
.
parse
(
stock
));
request
.
files
.
add
(
await
http
.
MultipartFile
.
fromPath
(
'image'
,
imagepath
.
path
));
request
.
files
.
add
(
http
.
MultipartFile
.
fromString
(
'stylecode'
,
stylecode
));
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
var
response
=
await
request
.
send
();
var
response
=
await
request
.
send
();
var
responseString
=
await
response
.
stream
.
bytesToString
();
var
responseString
=
await
response
.
stream
.
bytesToString
();
if
(
kDebugMode
)
{
if
(
kDebugMode
)
{
print
(
'Response :
$responseString
'
);
print
(
'Response :
$responseString
'
);
}
}
print
(
response
.
statusCode
);
if
(
response
.
statusCode
==
200
)
{
if
(
response
.
statusCode
==
200
)
{
return
responseString
;
return
responseString
;
}
else
{
}
else
{
...
@@ -59,18 +66,18 @@ class RemoteData {
...
@@ -59,18 +66,18 @@ class RemoteData {
return
''
;
return
''
;
}
}
Future
<
String
?>
IdentifyStyleCode
(
File
imagepath
,
String
bodyimagepath
)
async
{
Future
<
String
>
saleData
(
String
stylecode
)
async
{
print
(
'Identify Stylecode
$bodyimagepath
'
);
print
(
stylecode
);
try
{
try
{
final
request
=
http
.
MultipartRequest
(
'POST'
,
Uri
.
parse
(
Identifystylecode
));
final
request
=
http
.
MultipartRequest
(
'POST'
,
Uri
.
parse
(
sale
));
request
.
files
.
add
(
await
http
.
MultipartFile
.
fromPath
(
'image'
,
imagepath
.
path
));
request
.
files
.
add
(
http
.
MultipartFile
.
fromString
(
'stylecode'
,
stylecode
));
request
.
files
.
add
(
await
http
.
MultipartFile
.
fromString
(
'body_image_path'
,
bodyimagepath
));
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
var
response
=
await
request
.
send
();
var
response
=
await
request
.
send
();
var
responseString
=
await
response
.
stream
.
bytesToString
();
var
responseString
=
await
response
.
stream
.
bytesToString
();
if
(
kDebugMode
)
{
if
(
kDebugMode
)
{
print
(
'Response :
$responseString
'
);
print
(
'Response :
$responseString
'
);
}
}
print
(
response
.
statusCode
);
if
(
response
.
statusCode
==
200
)
{
if
(
response
.
statusCode
==
200
)
{
return
responseString
;
return
responseString
;
}
else
{
}
else
{
...
@@ -84,16 +91,102 @@ class RemoteData {
...
@@ -84,16 +91,102 @@ class RemoteData {
return
''
;
return
''
;
}
}
Future
<
String
?>
registerStyleCode
(
File
imagepath
,
var
embedding
,
String
stylecode
)
async
{
Future
<
String
?>
uploadimage
(
File
imagepath
,
String
embedding
)
async
{
print
(
'Register Style Code :
$stylecode
'
);
try
{
try
{
final
request
=
http
.
MultipartRequest
(
'POST'
,
Uri
.
parse
(
registerstylecode
));
final
request
=
http
.
MultipartRequest
(
request
.
files
.
add
(
await
http
.
MultipartFile
.
fromPath
(
'image'
,
imagepath
.
path
));
'POST'
,
Uri
.
parse
(
'http://vaman.plutokm.com/detect_saree'
));
request
.
files
.
add
(
http
.
MultipartFile
.
fromString
(
'body_image_path'
,
embedding
));
request
.
files
//request.fields('style_code', stylecode);
.
add
(
await
http
.
MultipartFile
.
fromPath
(
'image'
,
imagepath
.
path
));
request
.
fields
[
'style_code'
]
=
stylecode
;
var
response
=
await
request
.
send
();
var
responseString
=
await
response
.
stream
.
bytesToString
();
if
(
kDebugMode
)
{
print
(
'Response :
$responseString
'
);
}
if
(
response
.
statusCode
==
200
)
{
return
responseString
;
}
else
{
return
responseString
;
}
}
catch
(
e
)
{
if
(
kDebugMode
)
{
print
(
e
);
}
}
return
''
;
}
Future
<
String
?>
IdentifyStyleCode
(
File
imagepath
,
String
bodyimagepath
)
async
{
if
(
kDebugMode
)
{
print
(
'Identify Stylecode
$bodyimagepath
'
);
}
try
{
final
request
=
http
.
MultipartRequest
(
'POST'
,
Uri
.
parse
(
identifystylecode
));
request
.
files
.
add
(
await
http
.
MultipartFile
.
fromPath
(
'image'
,
imagepath
.
path
));
request
.
files
.
add
(
http
.
MultipartFile
.
fromString
(
'body_image_path'
,
bodyimagepath
));
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
//request.files.add(await http.MultipartFile.fromPath('embedding', embedding));
var
response
=
await
request
.
send
();
var
response
=
await
request
.
send
();
var
responseString
=
await
response
.
stream
.
bytesToString
();
if
(
kDebugMode
)
{
print
(
'Response :
$responseString
'
);
}
if
(
response
.
statusCode
==
200
)
{
return
responseString
;
}
else
{
return
responseString
;
}
}
catch
(
e
)
{
if
(
kDebugMode
)
{
print
(
e
);
}
}
return
''
;
}
Future
<
String
?>
detectAttributes
(
File
imagepath
,
String
image
)
async
{
try
{
final
request
=
http
.
MultipartRequest
(
'POST'
,
Uri
.
parse
(
detectattributes
));
request
.
files
.
add
(
await
http
.
MultipartFile
.
fromPath
(
'image'
,
imagepath
.
path
));
request
.
files
.
add
(
http
.
MultipartFile
.
fromString
(
'body_image_path'
,
image
));
//request.fields['style_code'] = stylecode;
var
response
=
await
request
.
send
();
var
responseString
=
await
response
.
stream
.
bytesToString
();
if
(
kDebugMode
)
{
print
(
'Response :
$responseString
'
);
}
if
(
response
.
statusCode
==
200
)
{
return
responseString
;
}
else
{
return
responseString
;
}
}
catch
(
e
)
{
if
(
kDebugMode
)
{
print
(
e
);
}
}
return
''
;
}
Future
<
String
?>
registerStyleCode
(
File
imagepath
,
var
embedding
,
String
stylecode
)
async
{
if
(
kDebugMode
)
{
print
(
'Register Style Code :
$stylecode
'
);
}
try
{
final
request
=
http
.
MultipartRequest
(
'POST'
,
Uri
.
parse
(
registerstylecode
));
request
.
files
.
add
(
await
http
.
MultipartFile
.
fromPath
(
'image'
,
imagepath
.
path
));
request
.
files
.
add
(
http
.
MultipartFile
.
fromString
(
'body_image_path'
,
embedding
));
request
.
fields
[
'style_code'
]
=
stylecode
;
var
response
=
await
request
.
send
();
var
responseString
=
await
response
.
stream
.
bytesToString
();
var
responseString
=
await
response
.
stream
.
bytesToString
();
if
(
kDebugMode
)
{
if
(
kDebugMode
)
{
print
(
'Response :
$responseString
'
);
print
(
'Response :
$responseString
'
);
...
@@ -113,7 +206,8 @@ class RemoteData {
...
@@ -113,7 +206,8 @@ class RemoteData {
Future
<
String
?>
searchbybarcode
(
String
barcode
)
async
{
Future
<
String
?>
searchbybarcode
(
String
barcode
)
async
{
var
client
=
http
.
Client
();
var
client
=
http
.
Client
();
var
res
=
await
client
.
get
(
Uri
.
parse
(
'https://vaman.plutokm.com/get_vas_barcode_image/
$barcode
'
));
var
res
=
await
client
.
get
(
Uri
.
parse
(
'https://vaman.plutokm.com/get_vas_barcode_image/
$barcode
'
));
if
(
kDebugMode
)
{
if
(
kDebugMode
)
{
print
(
res
.
body
);
print
(
res
.
body
);
}
}
...
...
lib/Searchbybarcode.dart
View file @
59f975ac
...
@@ -108,18 +108,9 @@ class _Searchbybarcode extends State<Searchbybarcode> {
...
@@ -108,18 +108,9 @@ class _Searchbybarcode extends State<Searchbybarcode> {
bool
isInternetConnected
=
bool
isInternetConnected
=
await
Constants
.
checkInternetConnectivity
();
await
Constants
.
checkInternetConnectivity
();
if
(
isInternetConnected
)
{
if
(
isInternetConnected
)
{
showDialog
(
Constants
.
Showindicator
(
context
,
'Search Barcode'
);
context:
context
,
var
upload
=
await
RemoteData
().
searchbybarcode
(
barrierDismissible:
false
,
_barcode
.
text
.
trim
().
toUpperCase
());
builder:
(
context
)
{
return
const
Center
(
child:
CircularProgressIndicator
(
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
),
);
}
);
var
upload
=
await
RemoteData
().
searchbybarcode
(
_barcode
.
text
.
trim
().
toUpperCase
());
if
(
upload
!=
null
)
{
if
(
upload
!=
null
)
{
var
jsonResponse
=
jsonDecode
(
upload
);
var
jsonResponse
=
jsonDecode
(
upload
);
await
Future
.
delayed
(
const
Duration
(
seconds:
1
));
await
Future
.
delayed
(
const
Duration
(
seconds:
1
));
...
@@ -129,7 +120,7 @@ class _Searchbybarcode extends State<Searchbybarcode> {
...
@@ -129,7 +120,7 @@ class _Searchbybarcode extends State<Searchbybarcode> {
if
(
kDebugMode
)
{
if
(
kDebugMode
)
{
print
(
'Testing =========>'
);
print
(
'Testing =========>'
);
}
}
Navigator
.
of
(
context
).
pop
();
//
Navigator.of(context).pop();
}
}
}
else
{
}
else
{
setDialog
(
'Check your internet connection'
);
setDialog
(
'Check your internet connection'
);
...
@@ -148,7 +139,6 @@ class _Searchbybarcode extends State<Searchbybarcode> {
...
@@ -148,7 +139,6 @@ class _Searchbybarcode extends State<Searchbybarcode> {
end:
Alignment
.
bottomRight
,
end:
Alignment
.
bottomRight
,
colors:
[
colors:
[
Color
.
fromARGB
(
255
,
227
,
144
,
214
),
Color
.
fromARGB
(
255
,
227
,
144
,
214
),
//Color(0xFFC2185B),
Color
.
fromARGB
(
255
,
125
,
174
,
251
),
Color
.
fromARGB
(
255
,
125
,
174
,
251
),
],
],
),
),
...
@@ -157,7 +147,6 @@ class _Searchbybarcode extends State<Searchbybarcode> {
...
@@ -157,7 +147,6 @@ class _Searchbybarcode extends State<Searchbybarcode> {
child:
const
Row
(
child:
const
Row
(
children:
[
children:
[
Text
(
'
\t\t
'
),
Text
(
'
\t\t
'
),
// replace with your image
Expanded
(
Expanded
(
child:
Center
(
child:
Center
(
child:
Text
(
child:
Text
(
...
@@ -211,15 +200,19 @@ class _Searchbybarcode extends State<Searchbybarcode> {
...
@@ -211,15 +200,19 @@ class _Searchbybarcode extends State<Searchbybarcode> {
}
}
void
updateUI
(
Map
<
String
,
dynamic
>
jsonResponse
)
{
void
updateUI
(
Map
<
String
,
dynamic
>
jsonResponse
)
{
setState
(()
{
Navigator
.
of
(
context
).
pop
();
var
newImageUrl
=
jsonResponse
[
'image_url'
];
var
newImageUrl
=
jsonResponse
[
'image_url'
];
var
status
=
jsonResponse
[
'status'
];
if
(
status
==
'NotFound'
)
{
setDialog
(
jsonResponse
[
'status'
]);
}
else
{
setState
(()
{
setState
(()
{
imageUrl
=
newImageUrl
;
imageUrl
=
newImageUrl
;
var
str
=
_barcode
.
text
;
var
str
=
_barcode
.
text
;
value
=
'BARCODE :
$str
'
;
value
=
'BARCODE :
$str
'
;
_barcode
.
clear
();
_barcode
.
clear
();
});
});
}
);
}
}
}
void
setDialog
(
String
text
)
{
void
setDialog
(
String
text
)
{
...
...
lib/SplashScreen.dart
View file @
59f975ac
...
@@ -8,6 +8,7 @@ import 'package:vasthram/SignUp.dart';
...
@@ -8,6 +8,7 @@ import 'package:vasthram/SignUp.dart';
class
UserPreferences
{
class
UserPreferences
{
static
const
String
isLoggedInKey
=
'isLoggedIn'
;
static
const
String
isLoggedInKey
=
'isLoggedIn'
;
static
Future
<
SharedPreferences
>
getSharedPreferences
()
async
{
static
Future
<
SharedPreferences
>
getSharedPreferences
()
async
{
return
await
SharedPreferences
.
getInstance
();
return
await
SharedPreferences
.
getInstance
();
}
}
...
@@ -27,6 +28,7 @@ class SplashScreen extends StatefulWidget {
...
@@ -27,6 +28,7 @@ class SplashScreen extends StatefulWidget {
class
SplashScreenState
extends
State
<
SplashScreen
>
{
class
SplashScreenState
extends
State
<
SplashScreen
>
{
bool
?
isLoggedIn
=
false
;
bool
?
isLoggedIn
=
false
;
void
timeToShowSplashScreenOnScreen
()
async
{
void
timeToShowSplashScreenOnScreen
()
async
{
Timer
(
const
Duration
(
seconds:
5
),
()
async
{
Timer
(
const
Duration
(
seconds:
5
),
()
async
{
if
(!
mounted
)
return
;
if
(!
mounted
)
return
;
...
@@ -39,7 +41,8 @@ class SplashScreenState extends State<SplashScreen> {
...
@@ -39,7 +41,8 @@ class SplashScreenState extends State<SplashScreen> {
if
(
kDebugMode
)
{
if
(
kDebugMode
)
{
print
(
'if condition :
$isLoggedIn
'
);
print
(
'if condition :
$isLoggedIn
'
);
}
}
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
const
Home
()));
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
const
Home
()));
}
else
{
}
else
{
Navigator
.
pushAndRemoveUntil
(
Navigator
.
pushAndRemoveUntil
(
context
,
context
,
...
@@ -67,19 +70,6 @@ class SplashScreenState extends State<SplashScreen> {
...
@@ -67,19 +70,6 @@ class SplashScreenState extends State<SplashScreen> {
width:
MediaQuery
.
of
(
context
).
size
.
width
,
width:
MediaQuery
.
of
(
context
).
size
.
width
,
frameRate:
30
,
//default is 15 FPS
frameRate:
30
,
//default is 15 FPS
),
),
// decoration: const BoxDecoration(
// //loadingText: Text("Loading"),
// GifView.asset(
// 'assets/images/login.gif',
// height: 350,
// width: 350,
// frameRate: 30, //default is 15 FPS
// ),
// image: DecorationImage(
// image: AssetImage("assets/images/splash.gif"),
// fit: BoxFit.cover,
// ),
// ),
),
),
);
);
}
}
...
...
lib/Uploadstylecode.dart
View file @
59f975ac
...
@@ -117,16 +117,7 @@ class _Uploadstylecode extends State<Uploadstylecode> {
...
@@ -117,16 +117,7 @@ class _Uploadstylecode extends State<Uploadstylecode> {
});
});
bool
isInternetConnected
=
await
Constants
.
checkInternetConnectivity
();
bool
isInternetConnected
=
await
Constants
.
checkInternetConnectivity
();
if
(
isInternetConnected
)
{
if
(
isInternetConnected
)
{
showDialog
(
Constants
.
Showindicator
(
context
,
'Detecting Saree'
);
context:
context
,
barrierDismissible:
false
,
builder:
(
context
)
{
return
const
Center
(
child:
CircularProgressIndicator
(
color:
Color
.
fromARGB
(
255
,
69
,
66
,
121
),
),
);
});
var
upload
=
await
RemoteData
().
uploadimage
(
imagefile
!,
''
);
var
upload
=
await
RemoteData
().
uploadimage
(
imagefile
!,
''
);
print
(
_stylecode
.
text
);
print
(
_stylecode
.
text
);
if
(
upload
!=
null
)
{
if
(
upload
!=
null
)
{
...
@@ -686,12 +677,16 @@ class _Uploadstylecode extends State<Uploadstylecode> {
...
@@ -686,12 +677,16 @@ class _Uploadstylecode extends State<Uploadstylecode> {
setState
(()
{
setState
(()
{
_base64Image
=
annotated_image
;
_base64Image
=
annotated_image
;
});
});
Constants
.
Showindicator
(
context
,
'Register Stylecode'
);
var
upload
=
await
RemoteData
()
var
upload
=
await
RemoteData
()
.
registerStyleCode
(
imagefile
!,
bodyimage
,
_stylecode
.
text
);
.
registerStyleCode
(
imagefile
!,
bodyimage
,
_stylecode
.
text
);
var
json
=
jsonDecode
(
upload
!);
if
(
upload
!=
null
)
{
await
Future
.
delayed
(
const
Duration
(
seconds:
1
));
var
json
=
jsonDecode
(
upload
);
getupdate
(
json
);
await
Future
.
delayed
(
const
Duration
(
seconds:
1
));
print
(
upload
);
getupdate
(
json
);
print
(
upload
);
}
return
;
return
;
}
else
{
}
else
{
showDialog
(
showDialog
(
...
@@ -721,6 +716,10 @@ class _Uploadstylecode extends State<Uploadstylecode> {
...
@@ -721,6 +716,10 @@ class _Uploadstylecode extends State<Uploadstylecode> {
void
getupdate
(
Map
<
String
,
dynamic
>
jsonResponse
)
{
void
getupdate
(
Map
<
String
,
dynamic
>
jsonResponse
)
{
setState
(()
{
setState
(()
{
Navigator
.
of
(
context
).
pop
();
setState
(()
{
isloading
=
false
;
});
isVisible
=
false
;
isVisible
=
false
;
//{"error_message":"","reg_status":"Success"}
//{"error_message":"","reg_status":"Success"}
status
=
jsonResponse
[
'reg_status'
];
status
=
jsonResponse
[
'reg_status'
];
...
@@ -736,10 +735,10 @@ class _Uploadstylecode extends State<Uploadstylecode> {
...
@@ -736,10 +735,10 @@ class _Uploadstylecode extends State<Uploadstylecode> {
}
else
{
}
else
{
print
(
'Else Printing ===============>'
);
print
(
'Else Printing ===============>'
);
setDialog
(
jsonResponse
[
'
error_message
'
]);
setDialog
(
jsonResponse
[
'
reg_status
'
]);
//bytes!.clear();
//bytes!.clear();
//bytes1!.clear();
//bytes1!.clear();
embedding
!.
clear
();
//
embedding!.clear();
//Navigator.of(context).pop();
//Navigator.of(context).pop();
}
}
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment