개발/Flutter

Rx null 사용 하는 법, RxList, RxSet

dev_caleb 2022. 12. 29. 12:08
728x90

Rx는 null 을 사용하지 말라는 권고가 있다. 

그런데 null 을 사용해야하면 어떻게 하느냐

 

Rxn을 사용해보자!

 

final Rxn<MoimModel> _moimModel = Rxn();
MoimModel? get moimModel => _moimModel.value;

 

이렇게 하면 된다. 

리스트 사용하는 방법, Set을 사용하는 방법

 

final RxList<SocialPlaceModel> _placeList = RxList();
List<SocialPlaceModel> get placeList => _placeList;

 

final RxSet<CollectionModel> _collectionModelOnShelf = RxSet();
Set<CollectionModel> get collectionModelOnShelf => _collectionModelOnShelf;

 

728x90