Skip to content

Commit

Permalink
#77 QR유효성검증 try catch 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
opjoobe committed Aug 4, 2022
1 parent 7eadc65 commit d9ccc95
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions lib/screens/sharing/sharing_qr_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,29 +184,32 @@ class _QRforTOOKState extends State<QRforTOOK> {
setState(() {
result = scanData;
if (result != null) {
String? chatRoomId = stringToBase64.decode(
result!.code!); // 'QRTOOKExchange${widget.myId.toString()}'
if (chatRoomId.substring(0, 14) == 'QRTOOKExchange') {
String? senderIdinStr = chatRoomId.substring(14);
senderId = int.tryParse(senderIdinStr);
if (senderId != null) {
if (senderId! > 0) {
socket.emit('join', chatRoomId);
socket.emit('took', {
'chatroomID': chatRoomId,
'senderID': senderId,
'receiverID': widget.myId
});
setState(() {
isValid = true;
});
try {
String? chatRoomId = stringToBase64.decode(
result!.code!); // 'QRTOOKExchange${widget.myId.toString()}'
if (chatRoomId.substring(0, 14) == 'QRTOOKExchange') {
String? senderIdinStr = chatRoomId.substring(14);
senderId = int.tryParse(senderIdinStr);
if (senderId != null) {
if (senderId! > 0) {
socket.emit('join', chatRoomId);
socket.emit('took', {
'chatroomID': chatRoomId,
'senderID': senderId,
'receiverID': widget.myId
});
setState(() {
isValid = true;
});
}
}
}
}
if (!isValid) {
setState(() {
errorMsg = '유효하지 않은 바코드입니다.';
});
if (!isValid) {
showSnackbar(errorMsg);
}
} catch (e) {
debugPrint('유효하지 않은 바코드입니다.');
showSnackbar(errorMsg);
}
} // 칭구
});
Expand Down

0 comments on commit d9ccc95

Please sign in to comment.