tbdc_flutter_plugin 1.1.2 copy "tbdc_flutter_plugin: ^1.1.2" to clipboard
tbdc_flutter_plugin: ^1.1.2 copied to clipboard

Plugin of TBDC Company with helper classes and UI Components for Flutter

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 #

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

And run:

flutter  pub  get

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',
	);

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 ...
    };
  }
}

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}');
5
likes
0
points
211
downloads

Publisher

unverified uploader

Weekly Downloads

Plugin of TBDC Company with helper classes and UI Components for Flutter

Homepage

License

unknown (license)

Dependencies

collection, flutter, flutter_localizations, flutter_svg, intl, l10m

More

Packages that depend on tbdc_flutter_plugin