show_error_handler 0.0.4 copy "show_error_handler: ^0.0.4" to clipboard
show_error_handler: ^0.0.4 copied to clipboard

A Flutter package that provides a convenient and customizable way to display errors to the user.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  final wcBaseError = WcBaseError(
    message: 'This is a message',
    title: 'This is a title',
  );
  int _counter = 0;

  void _showWcAlert() {
    showWcAlert(context, wcBaseError);
  }

  void _showWcModal() {
    showWcModal(context, wcBaseError, onPressed: () {
      setState(() {
        _counter--;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Theme.of(context).colorScheme.inversePrimary,
          title: Text(widget.title),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text(
                'You have pushed the button this many times:',
              ),
              Text(
                '$_counter',
                style: Theme.of(context).textTheme.headlineMedium,
              ),
            ],
          ),
        ),
        floatingActionButton: Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: <Widget>[
            FloatingActionButton(
              onPressed: _showWcAlert,
              tooltip: 'Increment',
              child: const Icon(Icons.add),
            ),
            const SizedBox(width: 10),
            FloatingActionButton(
              onPressed: _showWcModal,
              tooltip: 'Second Button',
              child: const Icon(Icons.remove),
            ),
          ],
        ));
  }
}
2
likes
150
points
1
downloads

Publisher

verified publisherweincode.dev

Weekly Downloads

A Flutter package that provides a convenient and customizable way to display errors to the user.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

dart_code_linter, flutter

More

Packages that depend on show_error_handler