๐ŸŽขCollection data

Management of collection data such as List, Set, Map.

Use tip: At first, you'll have to install Pulse-X package. Here's the installation tip.

Usage

Pulse-X has provided you with three different collection view models. You can use each of them as you need.

  1. PulseXListViewModel

  2. PulseXSetViewModel

  3. PulseXMapViewModel

Example 1 - PulseXListViewModel

Let's create a random user list generator using Pulse.

First you have to addfaker package which generate users in your pubspec.yaml file dependencies: section.

Create a UserModel class to create user model.

class UserModel {
  String name;
  String age;
  String job;
  String city;
  UserModel({
    required this.name,
    required this.age,
    required this.job,
    required this.city,
  });
}

Then, create a service that returns a new user. Here, I'll use abstraction to obey Open/Close Principle.

After that, you are ready to create a ViewModel which extends Pulse's PulseListViewModel. We'll pass IUserService in constructor to do dependency inversion.

Lastly, we'll have to create a view that shows a list of users.

๐ŸพCongratulations!! You've completed list data management with Pulse.

๐Ÿšง Set and map management examples are coming soon .....

Last updated