Im having an error in my Dart app with XML parsing, here is the code segment for the parsing:
getValue(value, string) {
var substring = string.substr(string.indexOf(value));
return substring.substr(value.length + 2, substring.indexOf('"', value.length + 2) - (value.length + 2));
}
The error I get is :
Unhandled exception:
Uncaught Error: The null object does not have a method 'indexOf'.
NoSuchMethodError: method not found: 'indexOf'
Receiver: null
Arguments: ["cb"]
Stack Trace:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#1 getValue (file:///C:/Users/karim_000/dart/test/bin/test.dart:5:49)
#2 connectChat (file:///C:/Users/karim_000/dart/test/bin/test.dart:31:35)
#3 loginUser.<anonymous closure> (file:///C:/Users/karim_000/dart/test/bin/test.dart:19:18)
#4 _RootZone.runUnary (dart:async/zone.dart:1151)
#5 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:496)
#6 _Future._propagateToListeners (dart:async/future_impl.dart:579)
#7 _Future._completeWithValue (dart:async/future_impl.dart:339)
#8 _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:401)
#9 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#10 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#11 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
#12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)
#0 _rootHandleUncaughtError.<anonymous closure> (dart:async/zone.dart:883)
#1 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#2 _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#3 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:84)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:131)
here is the whole code:
import 'dart:io';
import 'dart:core';
getValue(value, string) {
var substring = string.substr(string.indexOf(value));
return substring.substr(value.length + 2, substring.indexOf('"', value.length + 2) - (value.length + 2));
}
loginUser(id, username, pass) {
var data;
var logindata;
Socket.connect('173.255.132.116', 10014).then((socket) {
print("connected to logen server");
socket.write('<y r="8" v="0" u="' + id + '" />\0');
socket.write('<v p="' + pass + '" n="' + username + '" />\0');
print("Sending Authentication information");
socket.close();
print("Disconnected from login server");
connectChat(logindata, '211258656', '882763542', 'VenomshqB0t', 'ratscake');
});
return logindata;
}
connectChat(login, chatid, userid, username, password) {
var data = true;
var y = '<y r="' + chatid + '" m="1" v="0" u="' + userid + '" />\0';
var j2 = '<j2 cb="' + getValue("cb", login) + '" q="1" y="' + getValue("i", y) + '" k="' + getValue("k1", login) + '" k3="' + getValue("k3", login) + '" p="0" c="' + chatid + '" r="0" f="0" u="' + userid + '" d0="' + getValue("d0", login) + '" d3="' + getValue("d3", login) + '" dt="' + getValue("dt", login) + '" N="' + username + '" n="BotDART" a="http://ift.tt/1uSPjl0" h="" v="0" />\0';
print("Trying to connect");
var socket = Socket.connect('173.255.132.116', 10010).then((socket) {
print("Authenticating user");
socket.write(y);
socket.write(j2);
});
}
void main() {
loginUser('882763542', 'venomshqb0t', 'ratscake');
}
Any help or advise? Thank you!
No comments:
Post a Comment