Type 'String' is not a subtype of type 'int' of 'index'












1















My App can authenticate successfully when debugging against the Android emulator, but if I try to authenticate using debugging against the physical device (with same OS version), an error message appears after more than one minute waiting:




Exception has occurred.



_TypeError (type 'String' is not a subtype of type 'int' of 'index')




The error message points to the following code:



        if (responseJson[AuthUtils.authTokenKey] != null) {
AuthUtils.insertDetails(
userNameController.text, passwordController.text, responseJson);
...
} else {
...
};


And in the DEBUG CONSOLE I get the following:




I/flutter ( 9531): Auth: SocketException: OS Error: Connection timed
out, errno = 110, address = example.com, port = 38975
V/InputMethodManager( 9531): Starting input:
tba=android.view.inputmethod.EditorInfo@4aece4e nm :
example.com.todoapp ic=null




Here is the screenshot:
enter image description here



What am I doing wrong here ?










share|improve this question























  • responseJson seems to be inferred as type List and expects an integer in the index accessor responseJson[intIndexhere], but AuthUtils.authTokenKey is a String which is not supported here. That would only be supported if responseJson would be a Map

    – Günter Zöchbauer
    Nov 21 '18 at 16:30
















1















My App can authenticate successfully when debugging against the Android emulator, but if I try to authenticate using debugging against the physical device (with same OS version), an error message appears after more than one minute waiting:




Exception has occurred.



_TypeError (type 'String' is not a subtype of type 'int' of 'index')




The error message points to the following code:



        if (responseJson[AuthUtils.authTokenKey] != null) {
AuthUtils.insertDetails(
userNameController.text, passwordController.text, responseJson);
...
} else {
...
};


And in the DEBUG CONSOLE I get the following:




I/flutter ( 9531): Auth: SocketException: OS Error: Connection timed
out, errno = 110, address = example.com, port = 38975
V/InputMethodManager( 9531): Starting input:
tba=android.view.inputmethod.EditorInfo@4aece4e nm :
example.com.todoapp ic=null




Here is the screenshot:
enter image description here



What am I doing wrong here ?










share|improve this question























  • responseJson seems to be inferred as type List and expects an integer in the index accessor responseJson[intIndexhere], but AuthUtils.authTokenKey is a String which is not supported here. That would only be supported if responseJson would be a Map

    – Günter Zöchbauer
    Nov 21 '18 at 16:30














1












1








1








My App can authenticate successfully when debugging against the Android emulator, but if I try to authenticate using debugging against the physical device (with same OS version), an error message appears after more than one minute waiting:




Exception has occurred.



_TypeError (type 'String' is not a subtype of type 'int' of 'index')




The error message points to the following code:



        if (responseJson[AuthUtils.authTokenKey] != null) {
AuthUtils.insertDetails(
userNameController.text, passwordController.text, responseJson);
...
} else {
...
};


And in the DEBUG CONSOLE I get the following:




I/flutter ( 9531): Auth: SocketException: OS Error: Connection timed
out, errno = 110, address = example.com, port = 38975
V/InputMethodManager( 9531): Starting input:
tba=android.view.inputmethod.EditorInfo@4aece4e nm :
example.com.todoapp ic=null




Here is the screenshot:
enter image description here



What am I doing wrong here ?










share|improve this question














My App can authenticate successfully when debugging against the Android emulator, but if I try to authenticate using debugging against the physical device (with same OS version), an error message appears after more than one minute waiting:




Exception has occurred.



_TypeError (type 'String' is not a subtype of type 'int' of 'index')




The error message points to the following code:



        if (responseJson[AuthUtils.authTokenKey] != null) {
AuthUtils.insertDetails(
userNameController.text, passwordController.text, responseJson);
...
} else {
...
};


And in the DEBUG CONSOLE I get the following:




I/flutter ( 9531): Auth: SocketException: OS Error: Connection timed
out, errno = 110, address = example.com, port = 38975
V/InputMethodManager( 9531): Starting input:
tba=android.view.inputmethod.EditorInfo@4aece4e nm :
example.com.todoapp ic=null




Here is the screenshot:
enter image description here



What am I doing wrong here ?







android dart flutter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 16:26









Sami-LSami-L

2,01493862




2,01493862













  • responseJson seems to be inferred as type List and expects an integer in the index accessor responseJson[intIndexhere], but AuthUtils.authTokenKey is a String which is not supported here. That would only be supported if responseJson would be a Map

    – Günter Zöchbauer
    Nov 21 '18 at 16:30



















  • responseJson seems to be inferred as type List and expects an integer in the index accessor responseJson[intIndexhere], but AuthUtils.authTokenKey is a String which is not supported here. That would only be supported if responseJson would be a Map

    – Günter Zöchbauer
    Nov 21 '18 at 16:30

















responseJson seems to be inferred as type List and expects an integer in the index accessor responseJson[intIndexhere], but AuthUtils.authTokenKey is a String which is not supported here. That would only be supported if responseJson would be a Map

– Günter Zöchbauer
Nov 21 '18 at 16:30





responseJson seems to be inferred as type List and expects an integer in the index accessor responseJson[intIndexhere], but AuthUtils.authTokenKey is a String which is not supported here. That would only be supported if responseJson would be a Map

– Günter Zöchbauer
Nov 21 '18 at 16:30












1 Answer
1






active

oldest

votes


















2














I believe that in the line:



responseJson[AuthUtils.authTokenKey]


You're referencing an item in the list responseJson by the index AuthUtils.authTokenKey



And since AuthUtils.authTokenKey is a String, you cannot use it as in index of an array.



So you need first to get the index of AuthUtils.authTokenKey then use it to reference the item:



responseJson[responseJson.indexOf(AuthUtils.authTokenKey)]





share|improve this answer
























  • @Sami-L can you post the new error?

    – Mina Samy
    Nov 21 '18 at 16:44











  • Tried your solution, but instead getting the error message in the screenshot, I got the following: Could not load source 'dart:core/runtime/libstring_patch.dart': <source not available>.

    – Sami-L
    Nov 21 '18 at 16:48











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416469%2ftype-string-is-not-a-subtype-of-type-int-of-index%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














I believe that in the line:



responseJson[AuthUtils.authTokenKey]


You're referencing an item in the list responseJson by the index AuthUtils.authTokenKey



And since AuthUtils.authTokenKey is a String, you cannot use it as in index of an array.



So you need first to get the index of AuthUtils.authTokenKey then use it to reference the item:



responseJson[responseJson.indexOf(AuthUtils.authTokenKey)]





share|improve this answer
























  • @Sami-L can you post the new error?

    – Mina Samy
    Nov 21 '18 at 16:44











  • Tried your solution, but instead getting the error message in the screenshot, I got the following: Could not load source 'dart:core/runtime/libstring_patch.dart': <source not available>.

    – Sami-L
    Nov 21 '18 at 16:48
















2














I believe that in the line:



responseJson[AuthUtils.authTokenKey]


You're referencing an item in the list responseJson by the index AuthUtils.authTokenKey



And since AuthUtils.authTokenKey is a String, you cannot use it as in index of an array.



So you need first to get the index of AuthUtils.authTokenKey then use it to reference the item:



responseJson[responseJson.indexOf(AuthUtils.authTokenKey)]





share|improve this answer
























  • @Sami-L can you post the new error?

    – Mina Samy
    Nov 21 '18 at 16:44











  • Tried your solution, but instead getting the error message in the screenshot, I got the following: Could not load source 'dart:core/runtime/libstring_patch.dart': <source not available>.

    – Sami-L
    Nov 21 '18 at 16:48














2












2








2







I believe that in the line:



responseJson[AuthUtils.authTokenKey]


You're referencing an item in the list responseJson by the index AuthUtils.authTokenKey



And since AuthUtils.authTokenKey is a String, you cannot use it as in index of an array.



So you need first to get the index of AuthUtils.authTokenKey then use it to reference the item:



responseJson[responseJson.indexOf(AuthUtils.authTokenKey)]





share|improve this answer













I believe that in the line:



responseJson[AuthUtils.authTokenKey]


You're referencing an item in the list responseJson by the index AuthUtils.authTokenKey



And since AuthUtils.authTokenKey is a String, you cannot use it as in index of an array.



So you need first to get the index of AuthUtils.authTokenKey then use it to reference the item:



responseJson[responseJson.indexOf(AuthUtils.authTokenKey)]






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '18 at 16:31









Mina SamyMina Samy

7,3201276134




7,3201276134













  • @Sami-L can you post the new error?

    – Mina Samy
    Nov 21 '18 at 16:44











  • Tried your solution, but instead getting the error message in the screenshot, I got the following: Could not load source 'dart:core/runtime/libstring_patch.dart': <source not available>.

    – Sami-L
    Nov 21 '18 at 16:48



















  • @Sami-L can you post the new error?

    – Mina Samy
    Nov 21 '18 at 16:44











  • Tried your solution, but instead getting the error message in the screenshot, I got the following: Could not load source 'dart:core/runtime/libstring_patch.dart': <source not available>.

    – Sami-L
    Nov 21 '18 at 16:48

















@Sami-L can you post the new error?

– Mina Samy
Nov 21 '18 at 16:44





@Sami-L can you post the new error?

– Mina Samy
Nov 21 '18 at 16:44













Tried your solution, but instead getting the error message in the screenshot, I got the following: Could not load source 'dart:core/runtime/libstring_patch.dart': <source not available>.

– Sami-L
Nov 21 '18 at 16:48





Tried your solution, but instead getting the error message in the screenshot, I got the following: Could not load source 'dart:core/runtime/libstring_patch.dart': <source not available>.

– Sami-L
Nov 21 '18 at 16:48




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416469%2ftype-string-is-not-a-subtype-of-type-int-of-index%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules