Flutter Word Game features/game/presentation/widget/attempt_row_widget.dart

반응형
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:wordgame/features/game/presentation/bloc/game_bloc.dart';
import 'package:wordgame/features/game/presentation/bloc/game_state.dart';
import 'package:wordgame/features/game/presentation/widgets/letter_box_widget.dart';

class AttemptRowWidget extends StatelessWidget {
  final int attemptIndex;
  const AttemptRowWidget({super.key,required this.attemptIndex});

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<GameBloc, GameState>(
      builder: (context, state) {
        final word = state.word ?? '';
        final previousAttempts = state.attempts ?? [];
        final currentAttempt = state.currentAttempt ?? '';
        final isCurrentAttempt = attemptIndex == previousAttempts.length;
        return Row(
          children: List.generate(4, (letterIndex){
                return Expanded(child: LetterBoxWidget(text: 'T'));
          })
        );
      }
    );
  }
}
반응형