flutterx_live_data 2.0.1 copy "flutterx_live_data: ^2.0.1" to clipboard
flutterx_live_data: ^2.0.1 copied to clipboard

Observable data holders inspired by Android LiveData, with lazy activation, mediators, history, storage, observable collections and widget builders.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutterx_live_data/flutterx_live_data.dart';

void main() => runApp(const ExampleApp());

/// A counter held by a [MutableLiveData], with a parity label derived from it by a transformation.
class ExampleApp extends StatefulWidget {
  /// Creates the example app.
  const ExampleApp({super.key});

  @override
  State<ExampleApp> createState() => _ExampleAppState();
}

class _ExampleAppState extends State<ExampleApp> {
  final _counter = MutableLiveData<int>(value: 0);
  late final _parity = _counter.transform((value) => value.isEven ? 'even' : 'odd');

  @override
  Widget build(BuildContext context) => MaterialApp(
    home: Scaffold(
      body: Center(
        child: LiveDataBuilder<int>(
          data: _counter,
          builder: (context, value) => LiveDataBuilder<String>(
            data: _parity,
            builder: (context, parity) => Text('$value is $parity'),
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => _counter.value++,
        child: const Icon(Icons.add),
      ),
    ),
  );
}
14
likes
150
points
422
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Observable data holders inspired by Android LiveData, with lazy activation, mediators, history, storage, observable collections and widget builders.

Repository (GitLab)
View/report issues

License

BSD-3-Clause (license)

Dependencies

collection, flutter

More

Packages that depend on flutterx_live_data