Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 787 Bytes

useError.md

File metadata and controls

40 lines (31 loc) · 787 Bytes

useError

Flutter side-effect hook that returns an error dispatcher.

Installation

dependencies:
  flutter_use: ^0.0.2

Usage

class SampleError extends Error {}

class Sample extends HookWidget {
  @override
  Widget build(BuildContext context) {
    final dispatcherError = useError();

    if (dispatcherError.value is SampleError) {
      debugPrint('Error');
    }

    return Column(
      children: [
        ElevatedButton(
          onPressed: () {
            dispatcherError.dispatch(SampleError());
          },
          child: const Text('Dispatch Error'),
        ),
      ]
    );
  }
}