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

  Widget build(BuildContext context) {
    final status = bloc) => bloc.state.status);
    switch (status) {
      case MyStatus.initial:
      case MyStatus.loading:
        return const Center(child: CircularProgressIndicator());
      case MyStatus.success:
        return const MyView();
      case MyStatus.error:
        return Center(
          child: Column(
            children: [
              const Text('Something went wrong.'),
              const SizedBox(height: 16),
                onPressed: () {
                child: const Text('Try again'),
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter