tbdc_flutter_plugin

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

tbdc flutter plugin

Overview #
The TBDC Flutter Plugin is a versatile collection of utilities for Flutter applications, featuring various helper classes to enhance development. This document focuses on the Helpers section and showcasing several utility classes.
Table of Contents #

Installation
Helpers

CompareListsOfObjects

Usage
Example





Installation #
To integrate the TBDC Flutter Plugin, including the Helpers module, into your Flutter project, add the following dependency to your pubspec.yaml file:
dependencies:
tbdc_flutter_plugin: ^1.0.0
copied to clipboard
And run:
flutter pub get
copied to clipboard

Helpers #

CompareListsOfObject #
The CompareListsOfObject class provides functionality to compare lists of objects based on a specified field ID. It returns a CompareListsOfObjectsResult object containing lists of added, removed, and updated items.
CompareListsOfObjectResult<MyObject> result = CompareListsOfObject
.compare(
oldList: oldList,
newList: newList,
fieldId: 'uniqueField',
);
copied to clipboard

Usage
Ensure that the objects in your lists implement the ObjectComparable interface. This interface mandates the implementation of the map getter, returning a map representing the object.
class MyObject implements ObjectComparable {
// ... other properties and methods ...

@override
Map<String, dynamic> get map {
return {
'field1': field1,
'field2': field2,
// ... other fields ...
};
}
}
copied to clipboard

Example
// Import the TBDC Flutter Plugin
import 'package:tbdc_flutter_plugin/tbdc_flutter_plugin.dart';

// Define your custom class implementing ObjectComparable
class MyObject implements ObjectComparable {
// ... implementation of ComparableList interface ...

// ... other properties and methods ...
}

// Create lists of your objects
List<MyObject> oldList = [...];
List<MyObject> newList = [...];

// Compare lists
CompareListsOfObjectsResult<MyObject> result = CompareListsOfObject.compare(
oldList: oldList,
newList: newList,
fieldId: 'uniqueField',
);

// Access the result
print('Added items: ${result.added}');
print('Removed items: ${result.removed}');
print('Updated items: ${result.updated}');
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.