ICRUD<T, P> class Null safety

Interface to implement to query a rest API or database for Create, Read, Update, and Delete of Items-Item.

The first generic type is the item type.

the second generic type is for the query parameter type

class MyItemsRepository implements ICRUD<Item, Param> {
  ICRUD<void> init()async{
    //initialize any plugging here

  Future<List<Item>> read(Param? param) async {
    final items = await http.get('uri/${param.user.id}');
    //After parsing
    return items;

    // if(param.queryType=='GetCompletedItems'){
    //    final items = await http.get('uri/${param.user.id}/completed');
    //    return items;
    // }else if(param.queryType == 'GetActiveItems'){
    //   final items = await http.get('uri/${param.user.id}/active');
    //    return items;
    // }
  Future<Item> create(Item item, Param? param) async {
    final result = await http.post('uri/${param.user.id}/items');
    return item.copyWith(id: result['id']);

  Future<dynamic> update(List<Item> items, Param? param) async {
    //Update items
    return numberOfUpdatedRows;
  Future<dynamic> delete(List<Item> items, Param? param) async {
    //Delete items

  void dispose() {
    //Cleaning resources

// You can add here custom methods to perform other requests to the backend





hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


create(T item, P? param) Future<T>
Create an Item [...]
delete(List<T> items, P? param) Future
Delete a list of items [...]
dispose() → void
It is called when the injected model is disposed [...]
init() Future<void>
Initialize any plugging and return the initialized instance.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
read(P? param) Future<List<T>>
Read from rest API or a database and get a list of items [...]
toString() String
A string representation of this object. [...]
update(List<T> items, P? param) Future
Update a list of items [...]


operator ==(Object other) bool
The equality operator. [...]