Skip to content
pubscout

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.

WASM-ready
$ flutter pub add rxdart_ext
Source repository

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.

  • flutter_mobx

    Flutter integration for MobX, providing reactive Observer widgets.

  • rx_widgets

    Stream-based Flutter widgets that facilitate a reactive programming style with RxDart and RxCommand.

  • context_watch

    Observe value changes within the build method using extensions.

Works with

Packages commonly used together with rxdart_ext: ones it builds on, ones built on it, and its own family.