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;


  User.fromJson(Map<dynamic, dynamic> json)
      : id = json['id'],
        name = json['name'];

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?
Programming Feeds
Learn something new everyday on Devsheet