comprehensive_utils 0.7.3 copy "comprehensive_utils: ^0.7.3" to clipboard
comprehensive_utils: ^0.7.3 copied to clipboard

A collection of classes and functions containing simple and complex performance-oriented tools

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({required this.title, super.key});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final DistinctSubject<String> _userNameSubject = DistinctSubject<String>();

  @override
  void dispose() {
    _userNameSubject.close();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          spacing: 4,
          children: [
            const Text('userName:'),
            AsyncBuilder<String>(
              stream: _userNameSubject.stream,
              initial: '',
              builder: (context, value, child) => Text(
                value!,
                style: Theme.of(context).textTheme.headlineMedium,
              ),
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          // the value will be added to Stream if it differs from the previous one
          _userNameSubject.add('Random user');
        },
        tooltip: 'Set userName',
        child: const Icon(Icons.add),
      ),
    );
  }
}
8
likes
160
points
1.58k
downloads

Publisher

unverified uploader

Weekly Downloads

A collection of classes and functions containing simple and complex performance-oriented tools

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

async, collection, fast_immutable_collections, flutter, meta, nil, rxdart

More

Packages that depend on comprehensive_utils