riverpod_repo 3.0.0 copy "riverpod_repo: ^3.0.0" to clipboard
riverpod_repo: ^3.0.0 copied to clipboard

A Lib to build Riverpod providers based on the reposirory interfaces.

example/example.dart

import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:riverpod_repo/annotations.dart';

part 'example.g.dart';
part 'example.repo.dart';

@Riverpod(keepAlive: true)
RepoData repoData(Ref ref) => RepoDataImpl();

@riverpodRepo

/// Repository class to get Data
abstract class RepoData {
  /// Get the books
  Future<List<String>> getBooks({String search = '', String categoryId = ''});

  /// Get the top  genres
  Future<List<int>> getTopGenres();

  /// Get the top books by genre
  Future<List<bool>> getTopBooksByGenre(String genreId, {String search = ''});

  Future<List<String>> getCategories({String search = ''});
}

/// Repository Implementation class to get Data
class RepoDataImpl implements RepoData {
  /// Implimentation of the getBooks method
  @override
  Future<List<String>> getBooks({String search = '', String categoryId = ''}) {
    throw UnimplementedError();
  }

  /// Implimentation of the getCategories method
  @override
  Future<List<String>> getCategories({String search = ''}) {
    throw UnimplementedError();
  }

  /// Implimentation of the getTopBooksByGenre method
  @override
  Future<List<bool>> getTopBooksByGenre(String genreId, {String search = ''}) {
    throw UnimplementedError();
  }

  /// Implimentation of the getTopGenres method
  @override
  Future<List<int>> getTopGenres() {
    throw UnimplementedError();
  }
}
7
likes
160
pub points
64%
popularity

Publisher

verified publisherdilexus.dev

A Lib to build Riverpod providers based on the reposirory interfaces.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, build, flutter, recase, riverpod, riverpod_annotation, source_gen

More

Packages that depend on riverpod_repo