import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:hello_web3/hello/hello.dart';
import 'package:hello_web3/l10n/l10n.dart';

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

  Widget build(BuildContext context) {
    final l10n = context.l10n;
    return Scaffold(
      appBar: AppBar(title: Text(l10n.appTitle)),
      body: BlocConsumer<HelloBloc, HelloState>(
        listenWhen: (prev, curr) => prev.status != curr.status && curr.hasError,
        listener: (context, state) {
            SnackBar(content: Text(l10n.errorMessage)),
        builder: (context, state) {
          if (state.hasData) {
            return const HelloDataContent();
          } else if (state.hasError) {
            return const HelloErrorContent();
          return const Center(
            child: CircularProgressIndicator(),
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