dart advantage of a factory constructor identifier

前端 未结 3 2160
小蘑菇
小蘑菇 2020-11-29 04:48

I\'ve been investigating JSON parsing for my Flutter app and have a question about factory constructors that I can\'t resolve. I\'m trying to understand the advantage of usi

3条回答
  •  隐瞒了意图╮
    2020-11-29 04:54

    After I've been noticing and wondering the same, and given I don't think the other answers actually answer the question ("I've been investigating JSON parsing [...] I'm trying to understand the advantage of using a factory constructor verses a plain constructor"), here my try:

    there's no advantage or difference that I could see or understand, when parsing json, in using a factory constructor instead of a plain constructor. I tried both, and both works fine, with all the types of parameters. I decided eventually to adopt the factory constructor, because of the convenience of how the code is written, and readability, but it's a matter of choice and both will work fine in all the cases.

提交回复
热议问题