This is a pet adoption app built with Flutter that allows users to browse and adopt pets. It includes pagination listing, search functionality, and a history of adoption feature.
Pagination listing: The app fetches and displays a list of pets in a paginated manner, allowing users to browse through multiple pages of available pets.
Search: Users can search for pets based on different criteria such as name age, gender, etc. The app provides a search bar where users can enter their search query and receive filtered results.
History of adoption: The app keeps track of pets that users have adopted in the past. It provides a history section where users can view the details of previously adopted pets.
This layer is the lowest layer and is responsible for retrieving raw data from external sources such as a databases, APIs, and more.
This layer combines one or more data providers and applies “business rules” to the data. Each component in this layer is called a repository and each repository generally manages a single domain. Packages in the repository layer should generally only interact with the data layer.
This layer contains all of the application-specific features and use cases. Each feature generally consists of some UI and business logic. Features should generally be independent of other features so that they can easily be added/removed without impacting the rest of the codebase. Within each feature, the state of the feature along with any business logic is managed by blocs. Blocs interact with zero or more repositories. Blocs react to events and emit states which trigger changes in the UI. Widgets within each feature should generally only depend on the corresponding bloc and render UI based on the current state. The UI can notify the bloc of user input via events.
Now that we’ve gone over the layers at a high level, let’s start building our application starting with the data layer!
Database queries are:
Find Records of Limit n.
final List<PetDataModel?> dataModel = await isar.petDataModels.where().limit(20).findAll();
Pagination using ISAR Data Base.
var offsetCount = index * perPage;
Searching items(AKA Pets)
List<PetDataModel?> dataModel = await isar.petDataModels .filter() .nameContains(searchText ?? “”) .findAll();
Setting up model attributes
To get started with this project, follow these steps:
Clone the repository:
Change into the project directory:
Run the app:
This project relies on the following famous dependencies:
- flutter_bloc: State management library that provides a predictable way to manage app state.
- isar: Super Fast Cross-Platform Database for Flutter
- provider: State management library that provides a predictable way to manage app state.
- get_it: This is a simple Service Locator for Dart and Flutter projects with some additional goodies highly inspired by Splat. It can be used instead of InheritedWidget or Provider to access objects e.g. from your UI.
Make sure to check the
pubspec.yaml file for the specific versions of these dependencies used in the project.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
[Add your license information here]