Search code snippets, questions, articles...

Define Int type value in class Flutter

In computer programming, an integer is a data type that represents mathematical integers. In the Dart programming language, the int type represents a 64-bit signed integer. This means that it can represent values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
class User {
  int? id;
  String? name;

  Picture({
    this.type,
    this.name
  });

  User.fromJson(Map<dynamic, dynamic> json)
      : id = json['id'],
        name = json['name'];
}
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.

In the above User Class model, we have defined two properties - id and name. The id property has the type int and the name property has the type String.

Was this helpful?
0 Comments