rxdart_ext
0.4.0, released 5 weeks ago by hoc081098.dev
Extension methods and classes built on top of RxDart like Single and StateStream.
What it does
Extends RxDart with specialized reactive types such as Single for one-shot operations, and StateStream with synchronous latest-value access and distinct until changed behavior. It provides operators for streams and helpers for state management.
AI-written summary of version 0.4.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are using RxDart and need a Single type for one-shot asynchronous computations.
- You want broadcast state streams with synchronous access to the latest value and automatic distinct checking.
- You want advanced stream operators like flatMapSingle, distinctBy, and asNullable.
Skip it when
- You do not use RxDart or reactive programming in your application.
- You prefer standard Flutter setState or simple ValueNotifiers for state management.
Strengths
- Adds useful stream operators and classes missing from core RxDart.
- Provides Single type suited for API calls and single-emission asynchronous tasks.
- StateStream and StateSubject fit well with the BLoC pattern and StreamBuilder.
Weaknesses
- Requires learning additional custom Rx types and concepts alongside RxDart.
- Dart 3 class modifiers strictly restrict subclassing or implementing certain core classes outside their libraries.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
import 'package:rxdart_ext/rxdart_ext.dart';
Single<User> fetchUser(String id) {
return Single.fromCallable(() => http.get(Uri.parse('$baseUrl/users/$id')))
.flatMapSingle<String>((res) => res.statusCode == HttpStatus.ok
? Single.value(res.body)
: Single.error(Exception('Cannot fetch user with id=$id')))
.map((body) => User.fromJson(jsonDecode(body) as Map<String, dynamic>));
}Alternatives
Packages that do the same job and could replace rxdart_ext.
- mobx
Transparent functional reactive state management using observables, actions, and reactions.
92Compare - flutter_mobx
Flutter integration for MobX, providing reactive Observer widgets.
92Compare - rx_widgets
Stream-based Flutter widgets that facilitate a reactive programming style with RxDart and RxCommand.
45Compare - context_watch
Observe value changes within the build method using extensions.
63Compare
Works with
Packages commonly used together with rxdart_ext: ones it builds on, ones built on it, and its own family.
- stack_tracerxdart_ext depends on itProvides parsing, inspection, and readable formatting of Dart stack traces.
- rxdartrxdart_ext depends on itImplementation of the ReactiveX API for asynchronous programming leveraging native Dart Streams.
- dart_eitherrxdart_ext depends on itEither monad for Dart and Flutter supporting type-safe error handling and railway-oriented programming.
- sqlbriteBuilt on rxdart_extReactive stream wrapper around sqflite for Flutter.
- rx_storageBuilt on rxdart_extReactive key-value storage powered by RxDart
- flutter_bloc_patternBuilt on rxdart_extProvides BLoCs to descendant widgets with internal disposal and RxDart stream builders.
- flutter_google_places_hoc081098Built on rxdart_extGoogle Places autocomplete widgets for Flutter