Files
nabeh/mobile/lib/features/dashboard/data/models/plan_model.dart
2026-05-24 23:27:32 +03:00

45 lines
1.3 KiB
Dart

import 'package:equatable/equatable.dart';
class PlanModel extends Equatable {
// English: Unique plan identifier.
// Arabic: المعرف الفريد للباقة.
final int id;
// English: Name of the plan (e.g. Free Trial, Pro, Enterprise).
// Arabic: اسم الباقة (مثل التجريبية، الاحترافية، الشركات).
final String name;
// English: Monthly price of the plan.
// Arabic: السعر الشهري للباقة.
final double price;
const PlanModel({
required this.id,
required this.name,
required this.price,
});
// English: Factory constructor to parse PlanModel from JSON data map.
// Arabic: منشئ المصنع لتحليل نموذج الباقة من خريطة بيانات جيسون.
factory PlanModel.fromJson(Map<String, dynamic> json) {
return PlanModel(
id: json['id'] as int? ?? 0,
name: json['name'] as String? ?? 'Nabeh Plan',
price: (json['price'] as num?)?.toDouble() ?? 0.0,
);
}
// English: Convert model to JSON map.
// Arabic: تحويل النموذج إلى خريطة جيسون.
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'price': price,
};
}
@override
List<Object?> get props => [id, name, price];
}