google / google/built_value.dart

How to combine the usage of GetX and build_value?

Open
#1,129 4 comments 0 reactions 1 assignee Claimed by @davidmorgan View on GitHub
question
Dominant language
Dart
Stars
886
Forks
195
Avg merge
1d 11h
Merged PRs (30d)
4

Description

Our app has a lot of provider (https://pub.dev/packages/provider) code which uses built_value (https://pub.dev/packages/built_value) to be able to work with immutable data objects.

Now we want to migrate the whole provider functionality to the state management of GetX (https://pub.dev/packages/get) but I am not clear about how to make these two things work together? GetX-controllers work with Rx-Values which are directly used in the logic part and whenever the value changes ONLY the listener gets notified which subscribed to exactly this value. But how does this work when it is combined with built_value? There the "actual" value is more or less hidden by an internal state which holds the data and can only access it indirect via getters.

So e.g. the actual data for a user only can be accessed in the user getter inside the UserProviderState like in the following example:

```
abstract class UserProviderState implements Built {
User? get user;
...
}
```
An example for a GetX controller (without using built_value) is:

```
class LoginController extends GetxController {
RxString username = ''.obs, password = ''.obs;
RxBool obscurePassword = true.obs;
...
}
```

It is all a bit more nested when using built_value and some advice how to use it correctly with GetX would be really appreciated. Thanks

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.