Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleting data from local datastore when connect to internet to sync #5806

Open
Technical-Team-4Dev opened this issue Jan 14, 2025 · 13 comments
Assignees
Labels
datastore Issues related to the DataStore Category pending-maintainer-response Pending response from a maintainer of this repository pending-triage This issue is in the backlog of issues to triage question A question about the Amplify Flutter libraries

Comments

@Technical-Team-4Dev
Copy link

when i add the data in the subAccount and deptoperation its added successfully while am offline and when i connect to the internet to sync the data its also sync successfully but it disappear from the local datastore after its sync to the cloud while it stay presist in the cloud and disappear from the local data store and this log appears while am adding the data

here i the logs

W/amplify:aws-datastore( 1347): GraphQLResponseException{message=Mutation failed. Failed mutation = PendingMutation{mutatedItem=SerializedModel{id='6cb3f6f8-673b-493a-82cf-377d0974e634', serializedData={userName=, subAccount=SerializedModel{id='3c3bb71f-967f-4621-8913-485587f3b66d', serializedData={id=3c3bb71f-967f-4621-8913-485587f3b66d}, modelName=SubAccount}, createdAt=null, wholeSaleAmount=0, addDateTime=2025-01-14T01:34:04.438737000Z, isDeleted=0, currency=محلي, details=مصاريف, operationType=ALIH, id=6cb3f6f8-673b-493a-82cf-377d0974e634, retailAmount=0, moneyAmount=1240, updatedAt=null}, modelName=DebtOperation}, mutationType=CREATE, mutationId=a78c8718-d217-11ef-9889-9ba63c0f9ccf, predicate=MatchAllQueryPredicate}. AppSync response contained errors = [GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSTimestamp' within parent 'SubAccount' (/createDebtOperation/subAccount/_lastChangedAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='_lastChangedAt'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'Int' within parent 'SubAccount' (/createDebtOperation/subAccount/_version)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='_version'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSDateTime' within parent 'SubAccount' (/createDebtOperation/subAccount/createdAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='createdAt'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'ID' within parent 'SubAccount' (/createDebtOperation/subAccount/id)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='id'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'String' within parent 'SubAccount' (/createDebtOperation/subAccount/subAccountName)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='subAccountName'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSDateTime' within parent 'SubAccount' (/createDebtOperation/subAccount/updatedAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='updatedAt'}]', extensions='null'}], errors=[GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSTimestamp' within parent 'SubAccount' (/createDebtOperation/subAccount/_lastChangedAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='_lastChangedAt'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'Int' within parent 'SubAccount' (/createDebtOperation/subAccount/_version)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='_version'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSDateTime' within parent 'SubAccount' (/createDebtOperation/subAccount/createdAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='createdAt'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'ID' within parent 'SubAccount' (/createDebtOperation/subAccount/id)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPath
W/amplify:aws-datastore( 1347): Segment{value='id'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'String' within parent 'SubAccount' (/createDebtOperation/subAccount/subAccountName)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='subAccountName'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSDateTime' within parent 'SubAccount' (/createDebtOperation/subAccount/updatedAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='updatedAt'}]', extensions='null'}], recoverySuggestion=See attached list of GraphQLResponse.Error objects.}
W/amplify:aws-datastore( 1347): at com.amplifyframework.datastore.synceng

and here is my shema

type Blog @model @auth(rules: [{ allow: owner }]) {
id: ID!
name: String!
posts: [Post] @hasmany(indexName: "byBlog", fields: ["id"])
}

type Post @model @auth(rules: [{ allow: owner }]) {
id: ID!
title: String!
blogID: ID! @index(name: "byBlog")
blog: Blog @belongsTo(fields: ["blogID"])
comments: [Comment] @hasmany(indexName: "byPost", fields: ["id"])
}

type Comment @model @auth(rules: [{ allow: owner }]) {
id: ID!
postID: ID! @index(name: "byPost")
post: Post @belongsTo(fields: ["postID"])
content: String!
}

type MainAccount @model @auth(rules: [{ allow: owner }]) {
id: ID!
mainAccountName: String! # Non-nullable
userName: String
details: String
icon: String
defaultCurrency: String
isDeleted: Int # Non-nullable (make sure you always provide a value)

One MainAccount has many SubAccounts

subAccounts: [SubAccount] @hasmany(indexName: "byMainAccount", fields: ["id"])
}

type SubAccount @model @auth(rules: [{ allow: owner }]) {
id: ID!
mainAccountID: ID! @index(name: "byMainAccount")

Belongs to MainAccount via the mainAccountID field

mainAccount: MainAccount @belongsTo(fields: ["mainAccountID"])

subAccountName: String! # Non-nullable
defaultCurrency: String
userName: String
image: String
phoneNumber: String
whatsAppNumber: String
address: String
note: String
messagingWay: MessagingWay
messagingType: MessagingType
isDeleted: Int # Non-nullable (make sure you always provide a value)

One SubAccount has many DebtOperations

debtOperations: [DebtOperation] @hasmany(indexName: "bySubAccount", fields: ["id"])
}

type DebtOperation @model @auth(rules: [{ allow: owner }]) {
id: ID!
subAccountID: ID! @index(name: "bySubAccount")

Belongs to SubAccount via the subAccountID field

subAccount: SubAccount @belongsTo(fields: ["subAccountID"])

userName: String
moneyAmount: Float! # Non-nullable
wholeSaleAmount: String
retailAmount: String
currency: String! # Non-nullable
details: String
operationType: OperationType
addDateTime: AWSDateTime! # Non-nullable
isDeleted: Int
}

enum MessagingWay {
sms
whats
}

enum MessagingType {
directly
assurance
never
}

enum OperationType {
ALIH
LAHU
}

@github-actions github-actions bot added pending-triage This issue is in the backlog of issues to triage pending-maintainer-response Pending response from a maintainer of this repository labels Jan 14, 2025
@Technical-Team-4Dev
Copy link
Author

the add methods for all of them

Future _saveMainAccount() async {
// Validate the form first
if (!_formKey.currentState!.validate()) {
return;
}

// Fetch the local user name (or use whatever you need for userName)
final userName = await _userController.getStringUserName();

final mainAccount = MainAccount(
  // id: widget.account?.id,
  mainAccountName: _accountNameController.text ?? "غير محدد",
  details: _accountDetailsController.text,
  icon: _selectedIconPath ?? '',
  defaultCurrency: _selectedCurrency ?? 'محلي',
  userName: userName,
  isDeleted: 0,
);

try {
  if (widget.account == null) {
    // Create new account
    await _mainAccountController.addMainAccount(mainAccount);
    Get.snackbar(
      'احسنت',
      'تم اضافة الحساب بنجاح',
      duration: const Duration(milliseconds: 1500),
    );
  } else {
    // Update existing account
    await _mainAccountController.updateMainAccount(mainAccount);
    Get.snackbar(
      'احسنت',
      'تم تعديل الحساب بنجاح',
      duration: const Duration(milliseconds: 1500),
    );
  }

  // Refresh the accounts list once done
  await _mainAccountController.fetchMainAccounts();

  // Close dialog
  Navigator.of(context).pop();
} catch (e) {
  Get.snackbar(
    'خطأ',
    'فشلت عملية الحفظ: $e',
    duration: const Duration(milliseconds: 1500),
  );
}

#################################

Future _saveSubAccount() async {
if (!_formKey.currentState!.validate()) {
return;
}

// If adding, we need a valid mainAccount passed in the constructor
final mainAccount = widget.mainAccount ?? widget.subAccount?.mainAccount;
if (mainAccount == null) {
  Get.snackbar(
    'خطأ',
    'لم يتم تعيين حساب رئيسي صالح',
    duration: const Duration(milliseconds: 1500),
  );
  return;
}

// Validate messaging type
final validMessagingTypes = [
  MessagingType.directly,
  MessagingType.assurance,
  MessagingType.never,
];
if (!validMessagingTypes.contains(_messagingType)) {
  Get.snackbar(
    'خطأ',
    'لا يوجد طريقة ارسال الرسالة',
    duration: const Duration(milliseconds: 1500),
  );
  return;
}

// Validate messaging way
final validMessagingWays = [
  MessagingWay.whats,
  MessagingWay.sms,
];
if (!validMessagingWays.contains(_messagingWay)) {
  Get.snackbar(
    'خطأ',
    'لا يوجد وسيلة ارسال صحيحة',
    duration: const Duration(milliseconds: 1500),
  );
  return;
}

final userName = await _userController.getStringUserName();

// Build the SubAccount object
final subAccount = SubAccount(
  // id: widget.subAccount?.id, // Keep same ID if editing
  mainAccount: widget.mainAccount, // BelongsTo
  subAccountName: _accountNameController.text,
  defaultCurrency: subAccountCurrency, // e.g. 'محلي'
  userName: userName,
  image: _image != null ? _image!.path : widget.subAccount?.image,
  phoneNumber: _phoneNumberController.text.isNotEmpty
      ? _phoneNumberController.text
      : null,
  whatsAppNumber: _whatsNumberController.text.isNotEmpty
      ? _whatsNumberController.text
      : null,
  address:
      _addressController.text.isNotEmpty ? _addressController.text : null,
  note: _noteController.text.isNotEmpty ? _noteController.text : null,
  messagingWay: _messagingWay,
  messagingType: _messagingType,
  isDeleted: 0, // Always provide a non-null value for isDeleted
);

try {
  if (widget.subAccount == null) {
    // Create new
    await _subAccountController.addSubAccount(subAccount);
    Get.snackbar(
      'احسنت',
      'تم اضافة الحساب الفرعي بنجاح',
      duration: const Duration(milliseconds: 1500),
    );
  } else {
    // Update existing
    await _subAccountController.updateSubAccount(subAccount);
    Get.snackbar(
      'احسنت',
      'تم تعديل الحساب الفرعي بنجاح',
      duration: const Duration(milliseconds: 1500),
    );
  }
  Navigator.of(context).pop();
} catch (e) {
  Get.snackbar(
    'خطأ',
    'فشلت عملية الحفظ: $e',
    duration: const Duration(milliseconds: 1500),
  );
}

}

########################################

Future _handleSave() async {
if (!_formKey.currentState!.validate()) return;

try {
  // Handle messaging if required
  await _handleMessagingBeforeSave();

  // Safely parse amount
  double moneyAmount = double.tryParse(_amountController.text) ?? 0.0;

  // Prepare the DebtOperation object
  final debtOperation = DebtOperation(
    // id: widget.debtOperation?.id,
    subAccount: widget.subAccounts,
    moneyAmount: moneyAmount,
    currency: debtOperationCurrency ?? 'محلي', // Default currency
    details: _statementController.text.isNotEmpty
        ? _statementController.text
        : 'لا يوجد تفاصيل',
    wholeSaleAmount: _quantityTotalController.text.isNotEmpty
        ? _quantityTotalController.text
        : '0',
    retailAmount: _quantityUnitController.text.isNotEmpty
        ? _quantityUnitController.text
        : '0',
    operationType:
        _selectedType ?? OperationType.ALIH, // Default operation type
    userName: await _userController.getStringUserName() ?? '',
    addDateTime: _selectedDateTime != ''
        ? TemporalDateTime(_selectedDateTime)
        : TemporalDateTime.now(),
    isDeleted: 0,
  );

  // Perform add or update operation
  if (widget.debtOperation == null) {
    await _debtOperationController.addDebtOperation(debtOperation);
    print('11111111111111111111111111111111111');
    print(debtOperation);
    Get.snackbar(
      'أحسنت',
      'تمت عملية الاضافة بنجاح',
      colorText: black,
      duration: Duration(milliseconds: 1500),
    );
  } else {
    await _debtOperationController.updateDebtOperation(debtOperation);
    Get.snackbar(
      'أحسنت',
      'تمت عملية التعديل بنجاح',
      colorText: black,
      duration: Duration(milliseconds: 1500),
    );
  }

  // Trigger the callback if provided

  // Reset or close the dialog based on the keep-open checkbox
  if (!_keepOpen) {
    Navigator.of(context).pop();
  } else {
    _resetFormFields();
  }
} catch (e) {
  Get.snackbar(
    'خطأ',
    'فشل في عملية الحفظ: $e',
    colorText: redColor,
    duration: Duration(milliseconds: 1500),
  );
}

}

@tylerjroach
Copy link
Member

Did you configure Amplify with Gen1 + Conflict Detection enabled. Your models appear to be missing createdAt, updatedAt, and version variables which are all required for DataStore to work successfully? If conflict detection was enabled on your project, try regenerating your models. Maybe they were generated before it was enabled?

@tylerjroach tylerjroach added datastore Issues related to the DataStore Category question A question about the Amplify Flutter libraries labels Jan 14, 2025
@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Jan 14, 2025
@tylerjroach tylerjroach removed the pending-triage This issue is in the backlog of issues to triage label Jan 14, 2025
@Technical-Team-4Dev
Copy link
Author

Technical-Team-4Dev commented Jan 15, 2025

#tylerjroach thanks alot for the quick response
forgive me to tell you that
i have enabled the Conflict Detection and the issue persist
i forgot to tell you part of the scenario tell the issue happen
1- i add mainAccount in the time of the addition i check the logs i found the mainAccount instance has createdAt =null , updatedAt = null
2- i add subAccount related to the mainAccount then i check the logs i found the instance of the mainAccount has values for createdAt , And updatedAt that ware null
but here i still find the subAccount createdAt = null, updatedAt = null
and this what lead to lose data from the local datastore

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Jan 15, 2025
@tylerjroach
Copy link
Member

Did you enable it after my last message or was it already enabled?

Please post your updated models so that we can make sure that they were generated correctly.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Jan 15, 2025
@Technical-Team-4Dev
Copy link
Author

it was already enabled before i opened the issue

here is my model i will post them in the following comment

@Technical-Team-4Dev
Copy link
Author

mainAccount model

/*

  • Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  • Licensed under the Apache License, Version 2.0 (the "License").
  • You may not use this file except in compliance with the License.
  • A copy of the License is located at
  • http://aws.amazon.com/apache2.0
  • or in the "license" file accompanying this file. This file is distributed
  • on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  • express or implied. See the License for the specific language governing
  • permissions and limitations under the License.
    */

// NOTE: This file is generated and may not follow lint rules defined in your app
// Generated files can be excluded from analysis in analysis_options.yaml
// For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis

// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously

import 'ModelProvider.dart';
import 'package:amplify_core/amplify_core.dart' as amplify_core;
import 'package:collection/collection.dart';

/** This is an auto generated class representing the MainAccount type in your schema. */
class MainAccount extends amplify_core.Model {
static const classType = const _MainAccountModelType();
final String id;
final String? _mainAccountName;
final String? _userName;
final String? _details;
final String? _icon;
final String? _defaultCurrency;
final int? _isDeleted;
final List? _subAccounts;
final amplify_core.TemporalDateTime? _createdAt;
final amplify_core.TemporalDateTime? _updatedAt;

@OverRide
getInstanceType() => classType;

@deprecated('[getId] is being deprecated in favor of custom primary key feature. Use getter [modelIdentifier] to get model identifier.')
@OverRide
String getId() => id;

MainAccountModelIdentifier get modelIdentifier {
return MainAccountModelIdentifier(
id: id
);
}

String? get mainAccountName {
return _mainAccountName;
}

String? get userName {
return _userName;
}

String? get details {
return _details;
}

String? get icon {
return _icon;
}

String? get defaultCurrency {
return _defaultCurrency;
}

int get isDeleted {
try {
return _isDeleted!;
} catch(e) {
throw amplify_core.AmplifyCodeGenModelException(
amplify_core.AmplifyExceptionMessages.codeGenRequiredFieldForceCastExceptionMessage,
recoverySuggestion:
amplify_core.AmplifyExceptionMessages.codeGenRequiredFieldForceCastRecoverySuggestion,
underlyingException: e.toString()
);
}
}

List? get subAccounts {
return _subAccounts;
}

amplify_core.TemporalDateTime? get createdAt {
return _createdAt;
}

amplify_core.TemporalDateTime? get updatedAt {
return _updatedAt;
}

const MainAccount._internal({required this.id, mainAccountName, userName, details, icon, defaultCurrency, required isDeleted, subAccounts, createdAt, updatedAt}): _mainAccountName = mainAccountName, _userName = userName, _details = details, _icon = icon, _defaultCurrency = defaultCurrency, _isDeleted = isDeleted, _subAccounts = subAccounts, _createdAt = createdAt, _updatedAt = updatedAt;

factory MainAccount({String? id, String? mainAccountName, String? userName, String? details, String? icon, String? defaultCurrency, required int isDeleted, List? subAccounts}) {
return MainAccount._internal(
id: id == null ? amplify_core.UUID.getUUID() : id,
mainAccountName: mainAccountName,
userName: userName,
details: details,
icon: icon,
defaultCurrency: defaultCurrency,
isDeleted: isDeleted,
subAccounts: subAccounts != null ? List.unmodifiable(subAccounts) : subAccounts);
}

bool equals(Object other) {
return this == other;
}

@OverRide
bool operator ==(Object other) {
if (identical(other, this)) return true;
return other is MainAccount &&
id == other.id &&
_mainAccountName == other._mainAccountName &&
_userName == other._userName &&
_details == other._details &&
_icon == other._icon &&
_defaultCurrency == other._defaultCurrency &&
_isDeleted == other._isDeleted &&
DeepCollectionEquality().equals(_subAccounts, other._subAccounts);
}

@OverRide
int get hashCode => toString().hashCode;

@OverRide
String toString() {
var buffer = new StringBuffer();

buffer.write("MainAccount {");
buffer.write("id=" + "$id" + ", ");
buffer.write("mainAccountName=" + "$_mainAccountName" + ", ");
buffer.write("userName=" + "$_userName" + ", ");
buffer.write("details=" + "$_details" + ", ");
buffer.write("icon=" + "$_icon" + ", ");
buffer.write("defaultCurrency=" + "$_defaultCurrency" + ", ");
buffer.write("isDeleted=" + (_isDeleted != null ? _isDeleted!.toString() : "null") + ", ");
buffer.write("createdAt=" + (_createdAt != null ? _createdAt!.format() : "null") + ", ");
buffer.write("updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null"));
buffer.write("}");

return buffer.toString();

}

MainAccount copyWith({String? mainAccountName, String? userName, String? details, String? icon, String? defaultCurrency, int? isDeleted, List? subAccounts}) {
return MainAccount._internal(
id: id,
mainAccountName: mainAccountName ?? this.mainAccountName,
userName: userName ?? this.userName,
details: details ?? this.details,
icon: icon ?? this.icon,
defaultCurrency: defaultCurrency ?? this.defaultCurrency,
isDeleted: isDeleted ?? this.isDeleted,
subAccounts: subAccounts ?? this.subAccounts);
}

MainAccount copyWithModelFieldValues({
ModelFieldValue<String?>? mainAccountName,
ModelFieldValue<String?>? userName,
ModelFieldValue<String?>? details,
ModelFieldValue<String?>? icon,
ModelFieldValue<String?>? defaultCurrency,
ModelFieldValue? isDeleted,
ModelFieldValue<List?>? subAccounts
}) {
return MainAccount._internal(
id: id,
mainAccountName: mainAccountName == null ? this.mainAccountName : mainAccountName.value,
userName: userName == null ? this.userName : userName.value,
details: details == null ? this.details : details.value,
icon: icon == null ? this.icon : icon.value,
defaultCurrency: defaultCurrency == null ? this.defaultCurrency : defaultCurrency.value,
isDeleted: isDeleted == null ? this.isDeleted : isDeleted.value,
subAccounts: subAccounts == null ? this.subAccounts : subAccounts.value
);
}

MainAccount.fromJson(Map<String, dynamic> json)
: id = json['id'],
_mainAccountName = json['mainAccountName'],
_userName = json['userName'],
_details = json['details'],
_icon = json['icon'],
_defaultCurrency = json['defaultCurrency'],
_isDeleted = (json['isDeleted'] as num?)?.toInt(),
_subAccounts = json['subAccounts'] is Map
? (json['subAccounts']['items'] is List
? (json['subAccounts']['items'] as List)
.where((e) => e != null)
.map((e) => SubAccount.fromJson(new Map<String, dynamic>.from(e)))
.toList()
: null)
: (json['subAccounts'] is List
? (json['subAccounts'] as List)
.where((e) => e?['serializedData'] != null)
.map((e) => SubAccount.fromJson(new Map<String, dynamic>.from(e?['serializedData'])))
.toList()
: null),
_createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null,
_updatedAt = json['updatedAt'] != null ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) : null;

Map<String, dynamic> toJson() => {
'id': id, 'mainAccountName': _mainAccountName, 'userName': _userName, 'details': _details, 'icon': _icon, 'defaultCurrency': _defaultCurrency, 'isDeleted': _isDeleted, 'subAccounts': _subAccounts?.map((SubAccount? e) => e?.toJson()).toList(), 'createdAt': _createdAt?.format(), 'updatedAt': _updatedAt?.format()
};

Map<String, Object?> toMap() => {
'id': id,
'mainAccountName': _mainAccountName,
'userName': _userName,
'details': _details,
'icon': _icon,
'defaultCurrency': _defaultCurrency,
'isDeleted': _isDeleted,
'subAccounts': _subAccounts,
'createdAt': _createdAt,
'updatedAt': _updatedAt
};

static final amplify_core.QueryModelIdentifier MODEL_IDENTIFIER = amplify_core.QueryModelIdentifier();
static final ID = amplify_core.QueryField(fieldName: "id");
static final MAINACCOUNTNAME = amplify_core.QueryField(fieldName: "mainAccountName");
static final USERNAME = amplify_core.QueryField(fieldName: "userName");
static final DETAILS = amplify_core.QueryField(fieldName: "details");
static final ICON = amplify_core.QueryField(fieldName: "icon");
static final DEFAULTCURRENCY = amplify_core.QueryField(fieldName: "defaultCurrency");
static final ISDELETED = amplify_core.QueryField(fieldName: "isDeleted");
static final SUBACCOUNTS = amplify_core.QueryField(
fieldName: "subAccounts",
fieldType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.model, ofModelName: 'SubAccount'));
static var schema = amplify_core.Model.defineSchema(define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) {
modelSchemaDefinition.name = "MainAccount";
modelSchemaDefinition.pluralName = "MainAccounts";

modelSchemaDefinition.authRules = [
  amplify_core.AuthRule(
    authStrategy: amplify_core.AuthStrategy.OWNER,
    ownerField: "owner",
    identityClaim: "cognito:username",
    provider: amplify_core.AuthRuleProvider.USERPOOLS,
    operations: const [
      amplify_core.ModelOperation.CREATE,
      amplify_core.ModelOperation.UPDATE,
      amplify_core.ModelOperation.DELETE,
      amplify_core.ModelOperation.READ
    ])
];

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id());

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: MainAccount.MAINACCOUNTNAME,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: MainAccount.USERNAME,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: MainAccount.DETAILS,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: MainAccount.ICON,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: MainAccount.DEFAULTCURRENCY,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: MainAccount.ISDELETED,
  isRequired: true,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.int)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.hasMany(
  key: MainAccount.SUBACCOUNTS,
  isRequired: false,
  ofModelName: 'SubAccount',
  associatedKey: SubAccount.MAINACCOUNT
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.nonQueryField(
  fieldName: 'createdAt',
  isRequired: false,
  isReadOnly: true,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.dateTime)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.nonQueryField(
  fieldName: 'updatedAt',
  isRequired: false,
  isReadOnly: true,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.dateTime)
));

});
}

class _MainAccountModelType extends amplify_core.ModelType {
const _MainAccountModelType();

@OverRide
MainAccount fromJson(Map<String, dynamic> jsonData) {
return MainAccount.fromJson(jsonData);
}

@OverRide
String modelName() {
return 'MainAccount';
}
}

/**

  • This is an auto generated class representing the model identifier
  • of [MainAccount] in your schema.
    */
    class MainAccountModelIdentifier implements amplify_core.ModelIdentifier {
    final String id;

/** Create an instance of MainAccountModelIdentifier using [id] the primary key. */
const MainAccountModelIdentifier({
required this.id});

@OverRide
Map<String, dynamic> serializeAsMap() => (<String, dynamic>{
'id': id
});

@OverRide
List<Map<String, dynamic>> serializeAsList() => serializeAsMap()
.entries
.map((entry) => (<String, dynamic>{ entry.key: entry.value }))
.toList();

@OverRide
String serializeAsString() => serializeAsMap().values.join('#');

@OverRide
String toString() => 'MainAccountModelIdentifier(id: $id)';

@OverRide
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}

return other is MainAccountModelIdentifier &&
  id == other.id;

}

@OverRide
int get hashCode =>
id.hashCode;
}

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Jan 15, 2025
@Technical-Team-4Dev
Copy link
Author

subAccount model
/*

  • Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  • Licensed under the Apache License, Version 2.0 (the "License").
  • You may not use this file except in compliance with the License.
  • A copy of the License is located at
  • http://aws.amazon.com/apache2.0
  • or in the "license" file accompanying this file. This file is distributed
  • on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  • express or implied. See the License for the specific language governing
  • permissions and limitations under the License.
    */

// NOTE: This file is generated and may not follow lint rules defined in your app
// Generated files can be excluded from analysis in analysis_options.yaml
// For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis

// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously

import 'ModelProvider.dart';
import 'package:amplify_core/amplify_core.dart' as amplify_core;
import 'package:collection/collection.dart';

/** This is an auto generated class representing the SubAccount type in your schema. */
class SubAccount extends amplify_core.Model {
static const classType = const _SubAccountModelType();
final String id;
final MainAccount? _mainAccount;
final String? _subAccountName;
final String? _defaultCurrency;
final String? _userName;
final String? _image;
final String? _phoneNumber;
final String? _whatsAppNumber;
final String? _address;
final String? _note;
final MessagingWay? _messagingWay;
final MessagingType? _messagingType;
final int? _isDeleted;
final List? _debtOperations;
final amplify_core.TemporalDateTime? _createdAt;
final amplify_core.TemporalDateTime? _updatedAt;

@OverRide
getInstanceType() => classType;

@deprecated('[getId] is being deprecated in favor of custom primary key feature. Use getter [modelIdentifier] to get model identifier.')
@OverRide
String getId() => id;

SubAccountModelIdentifier get modelIdentifier {
return SubAccountModelIdentifier(
id: id
);
}

MainAccount? get mainAccount {
return _mainAccount;
}

String? get subAccountName {
return _subAccountName;
}

String? get defaultCurrency {
return _defaultCurrency;
}

String? get userName {
return _userName;
}

String? get image {
return _image;
}

String? get phoneNumber {
return _phoneNumber;
}

String? get whatsAppNumber {
return _whatsAppNumber;
}

String? get address {
return _address;
}

String? get note {
return _note;
}

MessagingWay? get messagingWay {
return _messagingWay;
}

MessagingType? get messagingType {
return _messagingType;
}

int get isDeleted {
try {
return _isDeleted!;
} catch(e) {
throw amplify_core.AmplifyCodeGenModelException(
amplify_core.AmplifyExceptionMessages.codeGenRequiredFieldForceCastExceptionMessage,
recoverySuggestion:
amplify_core.AmplifyExceptionMessages.codeGenRequiredFieldForceCastRecoverySuggestion,
underlyingException: e.toString()
);
}
}

List? get debtOperations {
return _debtOperations;
}

amplify_core.TemporalDateTime? get createdAt {
return _createdAt;
}

amplify_core.TemporalDateTime? get updatedAt {
return _updatedAt;
}

const SubAccount._internal({required this.id, mainAccount, subAccountName, defaultCurrency, userName, image, phoneNumber, whatsAppNumber, address, note, messagingWay, messagingType, required isDeleted, debtOperations, createdAt, updatedAt}): _mainAccount = mainAccount, _subAccountName = subAccountName, _defaultCurrency = defaultCurrency, _userName = userName, _image = image, _phoneNumber = phoneNumber, _whatsAppNumber = whatsAppNumber, _address = address, _note = note, _messagingWay = messagingWay, _messagingType = messagingType, _isDeleted = isDeleted, _debtOperations = debtOperations, _createdAt = createdAt, _updatedAt = updatedAt;

factory SubAccount({String? id, MainAccount? mainAccount, String? subAccountName, String? defaultCurrency, String? userName, String? image, String? phoneNumber, String? whatsAppNumber, String? address, String? note, MessagingWay? messagingWay, MessagingType? messagingType, required int isDeleted, List? debtOperations}) {
return SubAccount._internal(
id: id == null ? amplify_core.UUID.getUUID() : id,
mainAccount: mainAccount,
subAccountName: subAccountName,
defaultCurrency: defaultCurrency,
userName: userName,
image: image,
phoneNumber: phoneNumber,
whatsAppNumber: whatsAppNumber,
address: address,
note: note,
messagingWay: messagingWay,
messagingType: messagingType,
isDeleted: isDeleted,
debtOperations: debtOperations != null ? List.unmodifiable(debtOperations) : debtOperations);
}

bool equals(Object other) {
return this == other;
}

@OverRide
bool operator ==(Object other) {
if (identical(other, this)) return true;
return other is SubAccount &&
id == other.id &&
_mainAccount == other._mainAccount &&
_subAccountName == other._subAccountName &&
_defaultCurrency == other._defaultCurrency &&
_userName == other._userName &&
_image == other._image &&
_phoneNumber == other._phoneNumber &&
_whatsAppNumber == other._whatsAppNumber &&
_address == other._address &&
_note == other._note &&
_messagingWay == other._messagingWay &&
_messagingType == other._messagingType &&
_isDeleted == other._isDeleted &&
DeepCollectionEquality().equals(_debtOperations, other._debtOperations);
}

@OverRide
int get hashCode => toString().hashCode;

@OverRide
String toString() {
var buffer = new StringBuffer();

buffer.write("SubAccount {");
buffer.write("id=" + "$id" + ", ");
buffer.write("mainAccount=" + (_mainAccount != null ? _mainAccount!.toString() : "null") + ", ");
buffer.write("subAccountName=" + "$_subAccountName" + ", ");
buffer.write("defaultCurrency=" + "$_defaultCurrency" + ", ");
buffer.write("userName=" + "$_userName" + ", ");
buffer.write("image=" + "$_image" + ", ");
buffer.write("phoneNumber=" + "$_phoneNumber" + ", ");
buffer.write("whatsAppNumber=" + "$_whatsAppNumber" + ", ");
buffer.write("address=" + "$_address" + ", ");
buffer.write("note=" + "$_note" + ", ");
buffer.write("messagingWay=" + (_messagingWay != null ? amplify_core.enumToString(_messagingWay)! : "null") + ", ");
buffer.write("messagingType=" + (_messagingType != null ? amplify_core.enumToString(_messagingType)! : "null") + ", ");
buffer.write("isDeleted=" + (_isDeleted != null ? _isDeleted!.toString() : "null") + ", ");
buffer.write("createdAt=" + (_createdAt != null ? _createdAt!.format() : "null") + ", ");
buffer.write("updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null"));
buffer.write("}");

return buffer.toString();

}

SubAccount copyWith({MainAccount? mainAccount, String? subAccountName, String? defaultCurrency, String? userName, String? image, String? phoneNumber, String? whatsAppNumber, String? address, String? note, MessagingWay? messagingWay, MessagingType? messagingType, int? isDeleted, List? debtOperations}) {
return SubAccount._internal(
id: id,
mainAccount: mainAccount ?? this.mainAccount,
subAccountName: subAccountName ?? this.subAccountName,
defaultCurrency: defaultCurrency ?? this.defaultCurrency,
userName: userName ?? this.userName,
image: image ?? this.image,
phoneNumber: phoneNumber ?? this.phoneNumber,
whatsAppNumber: whatsAppNumber ?? this.whatsAppNumber,
address: address ?? this.address,
note: note ?? this.note,
messagingWay: messagingWay ?? this.messagingWay,
messagingType: messagingType ?? this.messagingType,
isDeleted: isDeleted ?? this.isDeleted,
debtOperations: debtOperations ?? this.debtOperations);
}

SubAccount copyWithModelFieldValues({
ModelFieldValue<MainAccount?>? mainAccount,
ModelFieldValue<String?>? subAccountName,
ModelFieldValue<String?>? defaultCurrency,
ModelFieldValue<String?>? userName,
ModelFieldValue<String?>? image,
ModelFieldValue<String?>? phoneNumber,
ModelFieldValue<String?>? whatsAppNumber,
ModelFieldValue<String?>? address,
ModelFieldValue<String?>? note,
ModelFieldValue<MessagingWay?>? messagingWay,
ModelFieldValue<MessagingType?>? messagingType,
ModelFieldValue? isDeleted,
ModelFieldValue<List?>? debtOperations
}) {
return SubAccount._internal(
id: id,
mainAccount: mainAccount == null ? this.mainAccount : mainAccount.value,
subAccountName: subAccountName == null ? this.subAccountName : subAccountName.value,
defaultCurrency: defaultCurrency == null ? this.defaultCurrency : defaultCurrency.value,
userName: userName == null ? this.userName : userName.value,
image: image == null ? this.image : image.value,
phoneNumber: phoneNumber == null ? this.phoneNumber : phoneNumber.value,
whatsAppNumber: whatsAppNumber == null ? this.whatsAppNumber : whatsAppNumber.value,
address: address == null ? this.address : address.value,
note: note == null ? this.note : note.value,
messagingWay: messagingWay == null ? this.messagingWay : messagingWay.value,
messagingType: messagingType == null ? this.messagingType : messagingType.value,
isDeleted: isDeleted == null ? this.isDeleted : isDeleted.value,
debtOperations: debtOperations == null ? this.debtOperations : debtOperations.value
);
}

SubAccount.fromJson(Map<String, dynamic> json)
: id = json['id'],
_mainAccount = json['mainAccount'] != null
? json['mainAccount']['serializedData'] != null
? MainAccount.fromJson(new Map<String, dynamic>.from(json['mainAccount']['serializedData']))
: MainAccount.fromJson(new Map<String, dynamic>.from(json['mainAccount']))
: null,
_subAccountName = json['subAccountName'],
_defaultCurrency = json['defaultCurrency'],
_userName = json['userName'],
_image = json['image'],
_phoneNumber = json['phoneNumber'],
_whatsAppNumber = json['whatsAppNumber'],
_address = json['address'],
_note = json['note'],
_messagingWay = amplify_core.enumFromString(json['messagingWay'], MessagingWay.values),
_messagingType = amplify_core.enumFromString(json['messagingType'], MessagingType.values),
_isDeleted = (json['isDeleted'] as num?)?.toInt(),
_debtOperations = json['debtOperations'] is Map
? (json['debtOperations']['items'] is List
? (json['debtOperations']['items'] as List)
.where((e) => e != null)
.map((e) => DebtOperation.fromJson(new Map<String, dynamic>.from(e)))
.toList()
: null)
: (json['debtOperations'] is List
? (json['debtOperations'] as List)
.where((e) => e?['serializedData'] != null)
.map((e) => DebtOperation.fromJson(new Map<String, dynamic>.from(e?['serializedData'])))
.toList()
: null),
_createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null,
_updatedAt = json['updatedAt'] != null ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) : null;

Map<String, dynamic> toJson() => {
'id': id, 'mainAccount': _mainAccount?.toJson(), 'subAccountName': _subAccountName, 'defaultCurrency': _defaultCurrency, 'userName': _userName, 'image': _image, 'phoneNumber': _phoneNumber, 'whatsAppNumber': _whatsAppNumber, 'address': _address, 'note': _note, 'messagingWay': amplify_core.enumToString(_messagingWay), 'messagingType': amplify_core.enumToString(_messagingType), 'isDeleted': _isDeleted, 'debtOperations': _debtOperations?.map((DebtOperation? e) => e?.toJson()).toList(), 'createdAt': _createdAt?.format(), 'updatedAt': _updatedAt?.format()
};

Map<String, Object?> toMap() => {
'id': id,
'mainAccount': _mainAccount,
'subAccountName': _subAccountName,
'defaultCurrency': _defaultCurrency,
'userName': _userName,
'image': _image,
'phoneNumber': _phoneNumber,
'whatsAppNumber': _whatsAppNumber,
'address': _address,
'note': _note,
'messagingWay': _messagingWay,
'messagingType': _messagingType,
'isDeleted': _isDeleted,
'debtOperations': _debtOperations,
'createdAt': _createdAt,
'updatedAt': _updatedAt
};

static final amplify_core.QueryModelIdentifier MODEL_IDENTIFIER = amplify_core.QueryModelIdentifier();
static final ID = amplify_core.QueryField(fieldName: "id");
static final MAINACCOUNT = amplify_core.QueryField(
fieldName: "mainAccount",
fieldType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.model, ofModelName: 'MainAccount'));
static final SUBACCOUNTNAME = amplify_core.QueryField(fieldName: "subAccountName");
static final DEFAULTCURRENCY = amplify_core.QueryField(fieldName: "defaultCurrency");
static final USERNAME = amplify_core.QueryField(fieldName: "userName");
static final IMAGE = amplify_core.QueryField(fieldName: "image");
static final PHONENUMBER = amplify_core.QueryField(fieldName: "phoneNumber");
static final WHATSAPPNUMBER = amplify_core.QueryField(fieldName: "whatsAppNumber");
static final ADDRESS = amplify_core.QueryField(fieldName: "address");
static final NOTE = amplify_core.QueryField(fieldName: "note");
static final MESSAGINGWAY = amplify_core.QueryField(fieldName: "messagingWay");
static final MESSAGINGTYPE = amplify_core.QueryField(fieldName: "messagingType");
static final ISDELETED = amplify_core.QueryField(fieldName: "isDeleted");
static final DEBTOPERATIONS = amplify_core.QueryField(
fieldName: "debtOperations",
fieldType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.model, ofModelName: 'DebtOperation'));
static var schema = amplify_core.Model.defineSchema(define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) {
modelSchemaDefinition.name = "SubAccount";
modelSchemaDefinition.pluralName = "SubAccounts";

modelSchemaDefinition.authRules = [
  amplify_core.AuthRule(
    authStrategy: amplify_core.AuthStrategy.OWNER,
    ownerField: "owner",
    identityClaim: "cognito:username",
    provider: amplify_core.AuthRuleProvider.USERPOOLS,
    operations: const [
      amplify_core.ModelOperation.CREATE,
      amplify_core.ModelOperation.UPDATE,
      amplify_core.ModelOperation.DELETE,
      amplify_core.ModelOperation.READ
    ])
];

modelSchemaDefinition.indexes = [
  amplify_core.ModelIndex(fields: const ["mainAccountID"], name: "byMainAccount")
];

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id());

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo(
  key: SubAccount.MAINACCOUNT,
  isRequired: false,
  targetNames: ['mainAccountID'],
  ofModelName: 'MainAccount'
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: SubAccount.SUBACCOUNTNAME,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: SubAccount.DEFAULTCURRENCY,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: SubAccount.USERNAME,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: SubAccount.IMAGE,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: SubAccount.PHONENUMBER,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: SubAccount.WHATSAPPNUMBER,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: SubAccount.ADDRESS,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: SubAccount.NOTE,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: SubAccount.MESSAGINGWAY,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.enumeration)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: SubAccount.MESSAGINGTYPE,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.enumeration)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: SubAccount.ISDELETED,
  isRequired: true,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.int)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.hasMany(
  key: SubAccount.DEBTOPERATIONS,
  isRequired: false,
  ofModelName: 'DebtOperation',
  associatedKey: DebtOperation.SUBACCOUNT
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.nonQueryField(
  fieldName: 'createdAt',
  isRequired: false,
  isReadOnly: true,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.dateTime)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.nonQueryField(
  fieldName: 'updatedAt',
  isRequired: false,
  isReadOnly: true,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.dateTime)
));

});
}

class _SubAccountModelType extends amplify_core.ModelType {
const _SubAccountModelType();

@OverRide
SubAccount fromJson(Map<String, dynamic> jsonData) {
return SubAccount.fromJson(jsonData);
}

@OverRide
String modelName() {
return 'SubAccount';
}
}

/**

  • This is an auto generated class representing the model identifier
  • of [SubAccount] in your schema.
    */
    class SubAccountModelIdentifier implements amplify_core.ModelIdentifier {
    final String id;

/** Create an instance of SubAccountModelIdentifier using [id] the primary key. */
const SubAccountModelIdentifier({
required this.id});

@OverRide
Map<String, dynamic> serializeAsMap() => (<String, dynamic>{
'id': id
});

@OverRide
List<Map<String, dynamic>> serializeAsList() => serializeAsMap()
.entries
.map((entry) => (<String, dynamic>{ entry.key: entry.value }))
.toList();

@OverRide
String serializeAsString() => serializeAsMap().values.join('#');

@OverRide
String toString() => 'SubAccountModelIdentifier(id: $id)';

@OverRide
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}

return other is SubAccountModelIdentifier &&
  id == other.id;

}

@OverRide
int get hashCode =>
id.hashCode;
}

@Technical-Team-4Dev
Copy link
Author

deptoperation model
/*

  • Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  • Licensed under the Apache License, Version 2.0 (the "License").
  • You may not use this file except in compliance with the License.
  • A copy of the License is located at
  • http://aws.amazon.com/apache2.0
  • or in the "license" file accompanying this file. This file is distributed
  • on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  • express or implied. See the License for the specific language governing
  • permissions and limitations under the License.
    */

// NOTE: This file is generated and may not follow lint rules defined in your app
// Generated files can be excluded from analysis in analysis_options.yaml
// For more info, see: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis

// ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously

import 'ModelProvider.dart';
import 'package:amplify_core/amplify_core.dart' as amplify_core;

/** This is an auto generated class representing the DebtOperation type in your schema. */
class DebtOperation extends amplify_core.Model {
static const classType = const _DebtOperationModelType();
final String id;
final SubAccount? _subAccount;
final String? _userName;
final double? _moneyAmount;
final String? _wholeSaleAmount;
final String? _retailAmount;
final String? _currency;
final String? _details;
final OperationType? _operationType;
final amplify_core.TemporalDateTime? _addDateTime;
final int? _isDeleted;
final amplify_core.TemporalDateTime? _createdAt;
final amplify_core.TemporalDateTime? _updatedAt;

@OverRide
getInstanceType() => classType;

@deprecated('[getId] is being deprecated in favor of custom primary key feature. Use getter [modelIdentifier] to get model identifier.')
@OverRide
String getId() => id;

DebtOperationModelIdentifier get modelIdentifier {
return DebtOperationModelIdentifier(
id: id
);
}

SubAccount? get subAccount {
return _subAccount;
}

String? get userName {
return _userName;
}

double get moneyAmount {
try {
return _moneyAmount!;
} catch(e) {
throw amplify_core.AmplifyCodeGenModelException(
amplify_core.AmplifyExceptionMessages.codeGenRequiredFieldForceCastExceptionMessage,
recoverySuggestion:
amplify_core.AmplifyExceptionMessages.codeGenRequiredFieldForceCastRecoverySuggestion,
underlyingException: e.toString()
);
}
}

String? get wholeSaleAmount {
return _wholeSaleAmount;
}

String? get retailAmount {
return _retailAmount;
}

String? get currency {
return _currency;
}

String? get details {
return _details;
}

OperationType? get operationType {
return _operationType;
}

amplify_core.TemporalDateTime? get addDateTime {
return _addDateTime;
}

int? get isDeleted {
return _isDeleted;
}

amplify_core.TemporalDateTime? get createdAt {
return _createdAt;
}

amplify_core.TemporalDateTime? get updatedAt {
return _updatedAt;
}

const DebtOperation._internal({required this.id, subAccount, userName, required moneyAmount, wholeSaleAmount, retailAmount, currency, details, operationType, addDateTime, isDeleted, createdAt, updatedAt}): _subAccount = subAccount, _userName = userName, _moneyAmount = moneyAmount, _wholeSaleAmount = wholeSaleAmount, _retailAmount = retailAmount, _currency = currency, _details = details, _operationType = operationType, _addDateTime = addDateTime, _isDeleted = isDeleted, _createdAt = createdAt, _updatedAt = updatedAt;

factory DebtOperation({String? id, SubAccount? subAccount, String? userName, required double moneyAmount, String? wholeSaleAmount, String? retailAmount, String? currency, String? details, OperationType? operationType, amplify_core.TemporalDateTime? addDateTime, int? isDeleted}) {
return DebtOperation._internal(
id: id == null ? amplify_core.UUID.getUUID() : id,
subAccount: subAccount,
userName: userName,
moneyAmount: moneyAmount,
wholeSaleAmount: wholeSaleAmount,
retailAmount: retailAmount,
currency: currency,
details: details,
operationType: operationType,
addDateTime: addDateTime,
isDeleted: isDeleted);
}

bool equals(Object other) {
return this == other;
}

@OverRide
bool operator ==(Object other) {
if (identical(other, this)) return true;
return other is DebtOperation &&
id == other.id &&
_subAccount == other._subAccount &&
_userName == other._userName &&
_moneyAmount == other._moneyAmount &&
_wholeSaleAmount == other._wholeSaleAmount &&
_retailAmount == other._retailAmount &&
_currency == other._currency &&
_details == other._details &&
_operationType == other._operationType &&
_addDateTime == other._addDateTime &&
_isDeleted == other._isDeleted;
}

@OverRide
int get hashCode => toString().hashCode;

@OverRide
String toString() {
var buffer = new StringBuffer();

buffer.write("DebtOperation {");
buffer.write("id=" + "$id" + ", ");
buffer.write("subAccount=" + (_subAccount != null ? _subAccount!.toString() : "null") + ", ");
buffer.write("userName=" + "$_userName" + ", ");
buffer.write("moneyAmount=" + (_moneyAmount != null ? _moneyAmount!.toString() : "null") + ", ");
buffer.write("wholeSaleAmount=" + "$_wholeSaleAmount" + ", ");
buffer.write("retailAmount=" + "$_retailAmount" + ", ");
buffer.write("currency=" + "$_currency" + ", ");
buffer.write("details=" + "$_details" + ", ");
buffer.write("operationType=" + (_operationType != null ? amplify_core.enumToString(_operationType)! : "null") + ", ");
buffer.write("addDateTime=" + (_addDateTime != null ? _addDateTime!.format() : "null") + ", ");
buffer.write("isDeleted=" + (_isDeleted != null ? _isDeleted!.toString() : "null") + ", ");
buffer.write("createdAt=" + (_createdAt != null ? _createdAt!.format() : "null") + ", ");
buffer.write("updatedAt=" + (_updatedAt != null ? _updatedAt!.format() : "null"));
buffer.write("}");

return buffer.toString();

}

DebtOperation copyWith({SubAccount? subAccount, String? userName, double? moneyAmount, String? wholeSaleAmount, String? retailAmount, String? currency, String? details, OperationType? operationType, amplify_core.TemporalDateTime? addDateTime, int? isDeleted}) {
return DebtOperation._internal(
id: id,
subAccount: subAccount ?? this.subAccount,
userName: userName ?? this.userName,
moneyAmount: moneyAmount ?? this.moneyAmount,
wholeSaleAmount: wholeSaleAmount ?? this.wholeSaleAmount,
retailAmount: retailAmount ?? this.retailAmount,
currency: currency ?? this.currency,
details: details ?? this.details,
operationType: operationType ?? this.operationType,
addDateTime: addDateTime ?? this.addDateTime,
isDeleted: isDeleted ?? this.isDeleted);
}

DebtOperation copyWithModelFieldValues({
ModelFieldValue<SubAccount?>? subAccount,
ModelFieldValue<String?>? userName,
ModelFieldValue? moneyAmount,
ModelFieldValue<String?>? wholeSaleAmount,
ModelFieldValue<String?>? retailAmount,
ModelFieldValue<String?>? currency,
ModelFieldValue<String?>? details,
ModelFieldValue<OperationType?>? operationType,
ModelFieldValue<amplify_core.TemporalDateTime?>? addDateTime,
ModelFieldValue<int?>? isDeleted
}) {
return DebtOperation._internal(
id: id,
subAccount: subAccount == null ? this.subAccount : subAccount.value,
userName: userName == null ? this.userName : userName.value,
moneyAmount: moneyAmount == null ? this.moneyAmount : moneyAmount.value,
wholeSaleAmount: wholeSaleAmount == null ? this.wholeSaleAmount : wholeSaleAmount.value,
retailAmount: retailAmount == null ? this.retailAmount : retailAmount.value,
currency: currency == null ? this.currency : currency.value,
details: details == null ? this.details : details.value,
operationType: operationType == null ? this.operationType : operationType.value,
addDateTime: addDateTime == null ? this.addDateTime : addDateTime.value,
isDeleted: isDeleted == null ? this.isDeleted : isDeleted.value
);
}

DebtOperation.fromJson(Map<String, dynamic> json)
: id = json['id'],
_subAccount = json['subAccount'] != null
? json['subAccount']['serializedData'] != null
? SubAccount.fromJson(new Map<String, dynamic>.from(json['subAccount']['serializedData']))
: SubAccount.fromJson(new Map<String, dynamic>.from(json['subAccount']))
: null,
_userName = json['userName'],
_moneyAmount = (json['moneyAmount'] as num?)?.toDouble(),
_wholeSaleAmount = json['wholeSaleAmount'],
_retailAmount = json['retailAmount'],
_currency = json['currency'],
_details = json['details'],
_operationType = amplify_core.enumFromString(json['operationType'], OperationType.values),
_addDateTime = json['addDateTime'] != null ? amplify_core.TemporalDateTime.fromString(json['addDateTime']) : null,
_isDeleted = (json['isDeleted'] as num?)?.toInt(),
_createdAt = json['createdAt'] != null ? amplify_core.TemporalDateTime.fromString(json['createdAt']) : null,
_updatedAt = json['updatedAt'] != null ? amplify_core.TemporalDateTime.fromString(json['updatedAt']) : null;

Map<String, dynamic> toJson() => {
'id': id, 'subAccount': _subAccount?.toJson(), 'userName': _userName, 'moneyAmount': _moneyAmount, 'wholeSaleAmount': _wholeSaleAmount, 'retailAmount': _retailAmount, 'currency': _currency, 'details': _details, 'operationType': amplify_core.enumToString(_operationType), 'addDateTime': _addDateTime?.format(), 'isDeleted': _isDeleted, 'createdAt': _createdAt?.format(), 'updatedAt': _updatedAt?.format()
};

Map<String, Object?> toMap() => {
'id': id,
'subAccount': _subAccount,
'userName': _userName,
'moneyAmount': _moneyAmount,
'wholeSaleAmount': _wholeSaleAmount,
'retailAmount': _retailAmount,
'currency': _currency,
'details': _details,
'operationType': _operationType,
'addDateTime': _addDateTime,
'isDeleted': _isDeleted,
'createdAt': _createdAt,
'updatedAt': _updatedAt
};

static final amplify_core.QueryModelIdentifier MODEL_IDENTIFIER = amplify_core.QueryModelIdentifier();
static final ID = amplify_core.QueryField(fieldName: "id");
static final SUBACCOUNT = amplify_core.QueryField(
fieldName: "subAccount",
fieldType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.model, ofModelName: 'SubAccount'));
static final USERNAME = amplify_core.QueryField(fieldName: "userName");
static final MONEYAMOUNT = amplify_core.QueryField(fieldName: "moneyAmount");
static final WHOLESALEAMOUNT = amplify_core.QueryField(fieldName: "wholeSaleAmount");
static final RETAILAMOUNT = amplify_core.QueryField(fieldName: "retailAmount");
static final CURRENCY = amplify_core.QueryField(fieldName: "currency");
static final DETAILS = amplify_core.QueryField(fieldName: "details");
static final OPERATIONTYPE = amplify_core.QueryField(fieldName: "operationType");
static final ADDDATETIME = amplify_core.QueryField(fieldName: "addDateTime");
static final ISDELETED = amplify_core.QueryField(fieldName: "isDeleted");
static var schema = amplify_core.Model.defineSchema(define: (amplify_core.ModelSchemaDefinition modelSchemaDefinition) {
modelSchemaDefinition.name = "DebtOperation";
modelSchemaDefinition.pluralName = "DebtOperations";

modelSchemaDefinition.authRules = [
  amplify_core.AuthRule(
    authStrategy: amplify_core.AuthStrategy.OWNER,
    ownerField: "owner",
    identityClaim: "cognito:username",
    provider: amplify_core.AuthRuleProvider.USERPOOLS,
    operations: const [
      amplify_core.ModelOperation.CREATE,
      amplify_core.ModelOperation.UPDATE,
      amplify_core.ModelOperation.DELETE,
      amplify_core.ModelOperation.READ
    ])
];

modelSchemaDefinition.indexes = [
  amplify_core.ModelIndex(fields: const ["subAccountID"], name: "bySubAccount")
];

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.id());

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.belongsTo(
  key: DebtOperation.SUBACCOUNT,
  isRequired: false,
  targetNames: ['subAccountID'],
  ofModelName: 'SubAccount'
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: DebtOperation.USERNAME,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: DebtOperation.MONEYAMOUNT,
  isRequired: true,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.double)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: DebtOperation.WHOLESALEAMOUNT,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: DebtOperation.RETAILAMOUNT,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: DebtOperation.CURRENCY,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: DebtOperation.DETAILS,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.string)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: DebtOperation.OPERATIONTYPE,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.enumeration)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: DebtOperation.ADDDATETIME,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.dateTime)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.field(
  key: DebtOperation.ISDELETED,
  isRequired: false,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.int)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.nonQueryField(
  fieldName: 'createdAt',
  isRequired: false,
  isReadOnly: true,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.dateTime)
));

modelSchemaDefinition.addField(amplify_core.ModelFieldDefinition.nonQueryField(
  fieldName: 'updatedAt',
  isRequired: false,
  isReadOnly: true,
  ofType: amplify_core.ModelFieldType(amplify_core.ModelFieldTypeEnum.dateTime)
));

});
}

class _DebtOperationModelType extends amplify_core.ModelType {
const _DebtOperationModelType();

@OverRide
DebtOperation fromJson(Map<String, dynamic> jsonData) {
return DebtOperation.fromJson(jsonData);
}

@OverRide
String modelName() {
return 'DebtOperation';
}
}

/**

  • This is an auto generated class representing the model identifier
  • of [DebtOperation] in your schema.
    */
    class DebtOperationModelIdentifier implements amplify_core.ModelIdentifier {
    final String id;

/** Create an instance of DebtOperationModelIdentifier using [id] the primary key. */
const DebtOperationModelIdentifier({
required this.id});

@OverRide
Map<String, dynamic> serializeAsMap() => (<String, dynamic>{
'id': id
});

@OverRide
List<Map<String, dynamic>> serializeAsList() => serializeAsMap()
.entries
.map((entry) => (<String, dynamic>{ entry.key: entry.value }))
.toList();

@OverRide
String serializeAsString() => serializeAsMap().values.join('#');

@OverRide
String toString() => 'DebtOperationModelIdentifier(id: $id)';

@OverRide
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}

return other is DebtOperationModelIdentifier &&
  id == other.id;

}

@OverRide
int get hashCode =>
id.hashCode;
}

@Technical-Team-4Dev
Copy link
Author

and here is updated schema
type MainAccount @model @auth(rules: [{ allow: owner }]){
id: ID!
mainAccountName: String # Non-nullable
userName: String
details: String
icon: String
defaultCurrency: String
isDeleted: Int! # Non-nullable

One MainAccount has many SubAccounts

subAccounts: [SubAccount] @hasmany(indexName: "byMainAccount", fields: ["id"])
}

type SubAccount @model @auth(rules: [{ allow: owner }]){
id: ID!
mainAccountID: ID! @index(name: "byMainAccount")

Belongs to MainAccount via the mainAccountID field

mainAccount: MainAccount @belongsTo(fields: ["mainAccountID"])
subAccountName: String # Non-nullable
defaultCurrency: String
userName: String
image: String
phoneNumber: String
whatsAppNumber: String
address: String
note: String
messagingWay: MessagingWay
messagingType: MessagingType
isDeleted: Int! # Non-nullable

One SubAccount has many DebtOperations

debtOperations: [DebtOperation] @hasmany(indexName: "bySubAccount", fields: ["id"])
}

type DebtOperation @model @auth(rules: [{ allow: owner }]){
id: ID!
subAccountID: ID! @index(name: "bySubAccount")

Belongs to SubAccount via the subAccountID field

subAccount: SubAccount @belongsTo(fields: ["subAccountID"])
userName: String
moneyAmount: Float! # Non-nullable
wholeSaleAmount: String
retailAmount: String
currency: String # Non-nullable
details: String
operationType: OperationType
addDateTime: AWSDateTime # Non-nullable
isDeleted: Int
}

enum MessagingWay {
sms
whats
}

enum MessagingType {
directly
assurance
never
}

enum OperationType {
ALIH
LAHU
}

@tylerjroach
Copy link
Member

I didn't realize you were using Flutter. I'm going to go ahead and transfer this to the Flutter team to take a look at. I understand there could be an underlying issue within Swift DataStore, since Flutter DataStore is built on top of it. However, we will start investigating at the Flutter level.

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Jan 15, 2025
@tylerjroach tylerjroach transferred this issue from aws-amplify/amplify-swift Jan 15, 2025
@github-actions github-actions bot added pending-triage This issue is in the backlog of issues to triage pending-maintainer-response Pending response from a maintainer of this repository labels Jan 15, 2025
@Technical-Team-4Dev
Copy link
Author

i realy do appreciate your help
and i am sorry that i did not tell you that i use flutter

@ekjotmultani
Copy link
Member

Hi @Technical-Team-4Dev , no problem, we will take a look and get back to you with an update when we have one

@github-actions github-actions bot removed the pending-maintainer-response Pending response from a maintainer of this repository label Jan 21, 2025
@Technical-Team-4Dev
Copy link
Author

the new about my issue that
when i first launch the app after installation every thing goes great and not issue occurs
but
when i exit the app then i start it again i found not thing no data at all and when i try to add data the data is not saved while it says
the record saved successfully but not data appeared at all

can you check if i have any issue in the configuration of amplify or any thing else

void main() async {
WidgetsFlutterBinding.ensureInitialized();

await configureAmplify();

final dbHelper = DatabaseHelper();
final database = await dbHelper.database;

setupControllers(database);

runApp(MyApp());
}
################################

Future configureAmplify() async {
try {
if (!Amplify.isConfigured) {
await Amplify.addPlugins([
AmplifyAuthCognito(),
AmplifyAPI(),
AmplifyDataStore(modelProvider: ModelProvider.instance),
]);
await Amplify.configure(amplifyconfig);
debugPrint('Amplify successfully configured.');
}
} catch (e) {
debugPrint('Error configuring Amplify: $e');
}
}
################################
void setupControllers(Database database) {
Get.put(UserController(database));
Get.put(UserSerialsController(database));
Get.put(DebtOperationController());
Get.put(SubAccountController());
Get.put(ArchiveDebtOperationController(database));
Get.put(CurrencyController(database));
Get.put(MainAccountController());
Get.put(ArchiveSubAccountController(database)); // Use Get.put() here
Get.put(ThemeController());
Get.put(TotalOperationsController());
Get.put(PreviousEntriesController());
Get.put(FieldSettingsController());
Get.put(AdminSerialController());
}
###############################
class MyApp extends StatelessWidget {
const MyApp({super.key});

@OverRide
Widget build(BuildContext context) {
return FutureBuilder(
future: runInitialChecks(context),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
}

    return Authenticator(
      stringResolver: ArabicAuthStrings.resolver,
      child: GetMaterialApp(
        builder: Authenticator.builder(),
        debugShowCheckedModeBanner: false,
        theme: lightTheme,
        darkTheme: darkTheme,
        themeMode: Get.find<ThemeController>().isDarkMode.value
            ? ThemeMode.dark
            : ThemeMode.light,
        home: MainScreen(),
        locale: const Locale('ar'),
        supportedLocales: const [Locale('ar'), Locale('en')],
        localizationsDelegates: const [
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
          GlobalCupertinoLocalizations.delegate,
        ],
      ),
    );
  },
);

}

Future runInitialChecks(BuildContext context) async {
final userController = Get.find();
final userSerialsController = Get.find();

await userController.recordInstallationTime(context);

if (!await userController.isActivated() &&
    await userController.isTrialExpired()) {
  Get.off(() => AppActivationPage());
}

await userController.checkTrialExpiration(context);

if (await userController.isActivated()) {
  await userSerialsController.checkSerialExpiration(context);
}

}
}

@github-actions github-actions bot added the pending-maintainer-response Pending response from a maintainer of this repository label Jan 23, 2025
@tyllark tyllark self-assigned this Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datastore Issues related to the DataStore Category pending-maintainer-response Pending response from a maintainer of this repository pending-triage This issue is in the backlog of issues to triage question A question about the Amplify Flutter libraries
Projects
None yet
Development

No branches or pull requests

4 participants