While looking at Reso Coder's TDD Clean Architecture tutorial, I came across some factory code that seems to do the same thing as a normal method. What's the benefit of using the factory keyword, and is there a difference between:
factory NumberTriviaModel.fromJson(Map<String, dynamic> json) {
return NumberTriviaModel(
text: json['text'],
number: (json['number'] as num).toInt(),
);
}
and
NumberTriviaModel NumberTriviaFromJson(Map<String, dynamic> json) {
return NumberTriviaModel(
text: json['text'],
number: (json['number'] as num).toInt(),
);
}
?