Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 810 Bytes

File metadata and controls

40 lines (31 loc) · 810 Bytes

useException

Flutter side-effect hook that returns an exception dispatcher.

Installation

dependencies:
  flutter_use: 

Usage

class SampleException extends Exception {}

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

    if (dispatcherException.value is SampleException) {
      debugPrint('Exception');
    }

    return Column(
      children: [
        ElevatedButton(
          onPressed: () {
            dispatcherException.dispatch(SampleException());
          },
          child: const Text('Dispatch Exception'),
        ),
      ]
    );
  }
}