Flutter advance data model

This is a sample flutter data model format. You can use it as a snippet.

// Import essential packages
import 'package:flutter/material.dart';


class TutorData {
  String? pageID;
  String? pageName;

  TutorData({
    @required this.pageID,
    @required this.pageName,
  });

  // Get single data value
  dynamic get(String propertyName) {
    var _mapRep = toJson();
    if (_mapRep.containsKey(propertyName)) {
      return _mapRep[propertyName];
    }
    return null;
  }
  
  // Set data from json
  factory TutorData.fromJson(Map<String, dynamic> json) {
    return TutorData(
      pageID: json["pageID"],
      pageName: json["pageName"],
    );
  }

  // Get data as json
  Map<String, dynamic> toJson() {
    return {
      'pageID': pageID,
      'pageName': pageName,
    };
  }
}