Flutter _TypeError (type 'List' is not a subtype of type 'Map')Flutter get " type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast errortype List<dynamic> is not a subtype of type 'Map<String, dynamic>'type 'List<dynamic>' is not a subtype of type 'List<Widget>'Flutter - SQflite '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<Map<String, dynamic>>'type 'List<dynamic>' is not a subtype of type 'List<Map<dynamic, dynamic>>'flutter: type 'List<dynamic>' is not a subtype of type 'String'How to convert Latin to Ibm charset on Dart and Flutter?Flutter: type 'List<dynamic>' is not a subtype of type 'List<Widget>'Flutter _TypeError type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>'Flutter get " type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast error

The correct way of compute indicator function in Mathematica

Can two aircraft be allowed to stay on the same runway at the same time?

How to run a command 1 out of N times in Bash

Tikz: Draw simplified BLE-Stack

Can UV radiation be safe for the skin?

Does the telecom provider need physical access to the SIM card to clone it?

Is the following statement true: two real numbers a and b are equal iff for every ε > 0, |a − b| < ε.

Cheap oscilloscope showing 16 MHz square wave

Received email from ISP saying one of my devices has malware

Doubt about a particular point of view on how to do character creation

Four day weekend?

How to Calculate this definite integral or how to solve this series?

Is "prohibition against," a double negative?

Which is the correct version of Mussorgsky's Pictures at an Exhibition?

A vector is defined to have a magnitude and *a* direction, but the zero vector has no *single* direction. So, how is the zero vector a vector?

Can I leave a large suitcase at TPE during a 4-hour layover, and pick it up 4.5 days later when I come back to TPE on my way to Taipei downtown?

Moscow SVO airport, how to avoid scam taxis without pre-booking?

apt-file regex: find multiple packages at once using or

Where does MyAnimeList get their data from?

Could a complex system of reaction wheels be used to propel a spacecraft?

Create a list of snaking numbers under 50,000

What is this "opened" cube called?

Could a simple hospital oxygen mask protect from aerosol poison?

What is the chance of getting a Red Cabbage in year 1?



Flutter _TypeError (type 'List' is not a subtype of type 'Map')


Flutter get " type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast errortype List<dynamic> is not a subtype of type 'Map<String, dynamic>'type 'List<dynamic>' is not a subtype of type 'List<Widget>'Flutter - SQflite '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<String, dynamic>'type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'List<Map<String, dynamic>>'type 'List<dynamic>' is not a subtype of type 'List<Map<dynamic, dynamic>>'flutter: type 'List<dynamic>' is not a subtype of type 'String'How to convert Latin to Ibm charset on Dart and Flutter?Flutter: type 'List<dynamic>' is not a subtype of type 'List<Widget>'Flutter _TypeError type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>'Flutter get " type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>' in type cast error






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I am new to flutter and getting type error. I am trying to use json automated serializations.



AFTER DOING SOME TWEAKS HERE IS HOW IT LOOKS LIKE



enter image description here



Here is how I am trying to get the data from api



 Future getMyProduct() async 
final res = await http.get('url');
final data = json.decode(res.body);
BaseResponse req = new BaseResponse.fromJson(data);
return req;



My BaseResponse class looks like this



import 'package:dynamicapp/model/model.dart';
import 'package:json_annotation/json_annotation.dart';

part 'response.g.dart';

@JsonSerializable()
class BaseResponse extends Object
final int id;

final int sellingPrice;
final int totalStock;
final String productName;
final String productDesc;
final List<Image> images;

BaseResponse(this.id, this.sellingPrice, this.totalStock, this.productName,
this.productDesc, this.images);

factory BaseResponse.fromJson(Map<String, dynamic> json) => _$BaseResponseFromJson(json);

Map<String, dynamic> toJson() => _$BaseResponseToJson(this);


@JsonSerializable()
class Image extends Object
final int id;
final String image;
// final int product_id;

Image(this.id, this.image);
factory Image.fromJson(Map<String, dynamic> json) => _$ImageFromJson(json);
Map<String, dynamic> toJson() => _$ImageToJson(this);



Could anyone please help me with this. I am stuck here. Have been trying different methods but none working. Thank you.










share|improve this question





















  • 1





    change json.decode to jsonDecode . Look this: flutter.dev/docs/development/data-and-backend/json

    – Rubens Melo
    Mar 27 at 22:55











  • It gives same error. I followed exactly like documentations. Still same error

    – Shakil Ahmed
    Mar 27 at 23:04






  • 1





    try change final data to final Map data to explicit the return type of jsonDecode

    – Rubens Melo
    Mar 27 at 23:09












  • It gives the same error final Map data = jsonDecode(res.body); var p = BaseResponse.fromJson(data); How can I convert the BaseResponse.fromJson(data) into a list instead of a map?

    – Shakil Ahmed
    Mar 27 at 23:16











  • OK I got the problem. It returns an array of items and in the BaseResponse call I have Object. So if I write BaseResponse.fromJson(jsonresponse[0]); it works with 0 index. But how can I make a list of array?

    – Shakil Ahmed
    Mar 27 at 23:26

















1















I am new to flutter and getting type error. I am trying to use json automated serializations.



AFTER DOING SOME TWEAKS HERE IS HOW IT LOOKS LIKE



enter image description here



Here is how I am trying to get the data from api



 Future getMyProduct() async 
final res = await http.get('url');
final data = json.decode(res.body);
BaseResponse req = new BaseResponse.fromJson(data);
return req;



My BaseResponse class looks like this



import 'package:dynamicapp/model/model.dart';
import 'package:json_annotation/json_annotation.dart';

part 'response.g.dart';

@JsonSerializable()
class BaseResponse extends Object
final int id;

final int sellingPrice;
final int totalStock;
final String productName;
final String productDesc;
final List<Image> images;

BaseResponse(this.id, this.sellingPrice, this.totalStock, this.productName,
this.productDesc, this.images);

factory BaseResponse.fromJson(Map<String, dynamic> json) => _$BaseResponseFromJson(json);

Map<String, dynamic> toJson() => _$BaseResponseToJson(this);


@JsonSerializable()
class Image extends Object
final int id;
final String image;
// final int product_id;

Image(this.id, this.image);
factory Image.fromJson(Map<String, dynamic> json) => _$ImageFromJson(json);
Map<String, dynamic> toJson() => _$ImageToJson(this);



Could anyone please help me with this. I am stuck here. Have been trying different methods but none working. Thank you.










share|improve this question





















  • 1





    change json.decode to jsonDecode . Look this: flutter.dev/docs/development/data-and-backend/json

    – Rubens Melo
    Mar 27 at 22:55











  • It gives same error. I followed exactly like documentations. Still same error

    – Shakil Ahmed
    Mar 27 at 23:04






  • 1





    try change final data to final Map data to explicit the return type of jsonDecode

    – Rubens Melo
    Mar 27 at 23:09












  • It gives the same error final Map data = jsonDecode(res.body); var p = BaseResponse.fromJson(data); How can I convert the BaseResponse.fromJson(data) into a list instead of a map?

    – Shakil Ahmed
    Mar 27 at 23:16











  • OK I got the problem. It returns an array of items and in the BaseResponse call I have Object. So if I write BaseResponse.fromJson(jsonresponse[0]); it works with 0 index. But how can I make a list of array?

    – Shakil Ahmed
    Mar 27 at 23:26













1












1








1








I am new to flutter and getting type error. I am trying to use json automated serializations.



AFTER DOING SOME TWEAKS HERE IS HOW IT LOOKS LIKE



enter image description here



Here is how I am trying to get the data from api



 Future getMyProduct() async 
final res = await http.get('url');
final data = json.decode(res.body);
BaseResponse req = new BaseResponse.fromJson(data);
return req;



My BaseResponse class looks like this



import 'package:dynamicapp/model/model.dart';
import 'package:json_annotation/json_annotation.dart';

part 'response.g.dart';

@JsonSerializable()
class BaseResponse extends Object
final int id;

final int sellingPrice;
final int totalStock;
final String productName;
final String productDesc;
final List<Image> images;

BaseResponse(this.id, this.sellingPrice, this.totalStock, this.productName,
this.productDesc, this.images);

factory BaseResponse.fromJson(Map<String, dynamic> json) => _$BaseResponseFromJson(json);

Map<String, dynamic> toJson() => _$BaseResponseToJson(this);


@JsonSerializable()
class Image extends Object
final int id;
final String image;
// final int product_id;

Image(this.id, this.image);
factory Image.fromJson(Map<String, dynamic> json) => _$ImageFromJson(json);
Map<String, dynamic> toJson() => _$ImageToJson(this);



Could anyone please help me with this. I am stuck here. Have been trying different methods but none working. Thank you.










share|improve this question
















I am new to flutter and getting type error. I am trying to use json automated serializations.



AFTER DOING SOME TWEAKS HERE IS HOW IT LOOKS LIKE



enter image description here



Here is how I am trying to get the data from api



 Future getMyProduct() async 
final res = await http.get('url');
final data = json.decode(res.body);
BaseResponse req = new BaseResponse.fromJson(data);
return req;



My BaseResponse class looks like this



import 'package:dynamicapp/model/model.dart';
import 'package:json_annotation/json_annotation.dart';

part 'response.g.dart';

@JsonSerializable()
class BaseResponse extends Object
final int id;

final int sellingPrice;
final int totalStock;
final String productName;
final String productDesc;
final List<Image> images;

BaseResponse(this.id, this.sellingPrice, this.totalStock, this.productName,
this.productDesc, this.images);

factory BaseResponse.fromJson(Map<String, dynamic> json) => _$BaseResponseFromJson(json);

Map<String, dynamic> toJson() => _$BaseResponseToJson(this);


@JsonSerializable()
class Image extends Object
final int id;
final String image;
// final int product_id;

Image(this.id, this.image);
factory Image.fromJson(Map<String, dynamic> json) => _$ImageFromJson(json);
Map<String, dynamic> toJson() => _$ImageToJson(this);



Could anyone please help me with this. I am stuck here. Have been trying different methods but none working. Thank you.







dart flutter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 10 at 11:28









DolDurma

3,92817 gold badges83 silver badges156 bronze badges




3,92817 gold badges83 silver badges156 bronze badges










asked Mar 27 at 22:50









Shakil AhmedShakil Ahmed

8217 silver badges33 bronze badges




8217 silver badges33 bronze badges










  • 1





    change json.decode to jsonDecode . Look this: flutter.dev/docs/development/data-and-backend/json

    – Rubens Melo
    Mar 27 at 22:55











  • It gives same error. I followed exactly like documentations. Still same error

    – Shakil Ahmed
    Mar 27 at 23:04






  • 1





    try change final data to final Map data to explicit the return type of jsonDecode

    – Rubens Melo
    Mar 27 at 23:09












  • It gives the same error final Map data = jsonDecode(res.body); var p = BaseResponse.fromJson(data); How can I convert the BaseResponse.fromJson(data) into a list instead of a map?

    – Shakil Ahmed
    Mar 27 at 23:16











  • OK I got the problem. It returns an array of items and in the BaseResponse call I have Object. So if I write BaseResponse.fromJson(jsonresponse[0]); it works with 0 index. But how can I make a list of array?

    – Shakil Ahmed
    Mar 27 at 23:26












  • 1





    change json.decode to jsonDecode . Look this: flutter.dev/docs/development/data-and-backend/json

    – Rubens Melo
    Mar 27 at 22:55











  • It gives same error. I followed exactly like documentations. Still same error

    – Shakil Ahmed
    Mar 27 at 23:04






  • 1





    try change final data to final Map data to explicit the return type of jsonDecode

    – Rubens Melo
    Mar 27 at 23:09












  • It gives the same error final Map data = jsonDecode(res.body); var p = BaseResponse.fromJson(data); How can I convert the BaseResponse.fromJson(data) into a list instead of a map?

    – Shakil Ahmed
    Mar 27 at 23:16











  • OK I got the problem. It returns an array of items and in the BaseResponse call I have Object. So if I write BaseResponse.fromJson(jsonresponse[0]); it works with 0 index. But how can I make a list of array?

    – Shakil Ahmed
    Mar 27 at 23:26







1




1





change json.decode to jsonDecode . Look this: flutter.dev/docs/development/data-and-backend/json

– Rubens Melo
Mar 27 at 22:55





change json.decode to jsonDecode . Look this: flutter.dev/docs/development/data-and-backend/json

– Rubens Melo
Mar 27 at 22:55













It gives same error. I followed exactly like documentations. Still same error

– Shakil Ahmed
Mar 27 at 23:04





It gives same error. I followed exactly like documentations. Still same error

– Shakil Ahmed
Mar 27 at 23:04




1




1





try change final data to final Map data to explicit the return type of jsonDecode

– Rubens Melo
Mar 27 at 23:09






try change final data to final Map data to explicit the return type of jsonDecode

– Rubens Melo
Mar 27 at 23:09














It gives the same error final Map data = jsonDecode(res.body); var p = BaseResponse.fromJson(data); How can I convert the BaseResponse.fromJson(data) into a list instead of a map?

– Shakil Ahmed
Mar 27 at 23:16





It gives the same error final Map data = jsonDecode(res.body); var p = BaseResponse.fromJson(data); How can I convert the BaseResponse.fromJson(data) into a list instead of a map?

– Shakil Ahmed
Mar 27 at 23:16













OK I got the problem. It returns an array of items and in the BaseResponse call I have Object. So if I write BaseResponse.fromJson(jsonresponse[0]); it works with 0 index. But how can I make a list of array?

– Shakil Ahmed
Mar 27 at 23:26





OK I got the problem. It returns an array of items and in the BaseResponse call I have Object. So if I write BaseResponse.fromJson(jsonresponse[0]); it works with 0 index. But how can I make a list of array?

– Shakil Ahmed
Mar 27 at 23:26












1 Answer
1






active

oldest

votes


















0















It looks like data is a List<dynamic>, then data.map(someFunc).toList() will take each element of data pass it to someFunc and form it back into a list of the return type of someFunc (which you will presumably want to be BaseResponse). Which tells you that someFunc needs to be a function that takes dynamic and returns BaseResponse.



You'd want to write something like this:



 final data = json.decode(res.body);
List<BaseResponse> responses =
data.map((j) => BaseResponse.fromJson(j)).toList();





share|improve this answer

























  • could you help me on this issue? https://stackoverflow.com/q/56524623/1830228 thanks

    – DolDurma
    Jun 10 at 11:23










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%2f55387659%2fflutter-typeerror-type-listdynamic-is-not-a-subtype-of-type-mapstring-d%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









0















It looks like data is a List<dynamic>, then data.map(someFunc).toList() will take each element of data pass it to someFunc and form it back into a list of the return type of someFunc (which you will presumably want to be BaseResponse). Which tells you that someFunc needs to be a function that takes dynamic and returns BaseResponse.



You'd want to write something like this:



 final data = json.decode(res.body);
List<BaseResponse> responses =
data.map((j) => BaseResponse.fromJson(j)).toList();





share|improve this answer

























  • could you help me on this issue? https://stackoverflow.com/q/56524623/1830228 thanks

    – DolDurma
    Jun 10 at 11:23















0















It looks like data is a List<dynamic>, then data.map(someFunc).toList() will take each element of data pass it to someFunc and form it back into a list of the return type of someFunc (which you will presumably want to be BaseResponse). Which tells you that someFunc needs to be a function that takes dynamic and returns BaseResponse.



You'd want to write something like this:



 final data = json.decode(res.body);
List<BaseResponse> responses =
data.map((j) => BaseResponse.fromJson(j)).toList();





share|improve this answer

























  • could you help me on this issue? https://stackoverflow.com/q/56524623/1830228 thanks

    – DolDurma
    Jun 10 at 11:23













0














0










0









It looks like data is a List<dynamic>, then data.map(someFunc).toList() will take each element of data pass it to someFunc and form it back into a list of the return type of someFunc (which you will presumably want to be BaseResponse). Which tells you that someFunc needs to be a function that takes dynamic and returns BaseResponse.



You'd want to write something like this:



 final data = json.decode(res.body);
List<BaseResponse> responses =
data.map((j) => BaseResponse.fromJson(j)).toList();





share|improve this answer













It looks like data is a List<dynamic>, then data.map(someFunc).toList() will take each element of data pass it to someFunc and form it back into a list of the return type of someFunc (which you will presumably want to be BaseResponse). Which tells you that someFunc needs to be a function that takes dynamic and returns BaseResponse.



You'd want to write something like this:



 final data = json.decode(res.body);
List<BaseResponse> responses =
data.map((j) => BaseResponse.fromJson(j)).toList();






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 27 at 23:52









Richard HeapRichard Heap

12.7k2 gold badges17 silver badges32 bronze badges




12.7k2 gold badges17 silver badges32 bronze badges















  • could you help me on this issue? https://stackoverflow.com/q/56524623/1830228 thanks

    – DolDurma
    Jun 10 at 11:23

















  • could you help me on this issue? https://stackoverflow.com/q/56524623/1830228 thanks

    – DolDurma
    Jun 10 at 11:23
















could you help me on this issue? https://stackoverflow.com/q/56524623/1830228 thanks

– DolDurma
Jun 10 at 11:23





could you help me on this issue? https://stackoverflow.com/q/56524623/1830228 thanks

– DolDurma
Jun 10 at 11:23








Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















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%2f55387659%2fflutter-typeerror-type-listdynamic-is-not-a-subtype-of-type-mapstring-d%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

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현