1
resposta

Código como referencia(Não é pergunta)

Pra quem precisar do código atualizado como referencia.

import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Byte Bank',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: FormularioDeTransferencia(),
      ),
    );
  }
}

class FormularioDeTransferencia extends StatelessWidget {
  FormularioDeTransferencia({super.key});

  final TextEditingController _controlarNumeroConta = TextEditingController();
  final TextEditingController _controlarValor = TextEditingController();


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Transferindo'),
      ),
      body: Column(
        children: <Widget>[
           Padding(
            padding: const EdgeInsets.all(8.0),
            child: TextField(
              controller: _controlarNumeroConta,
              style: const TextStyle(
                fontSize: 24.0,
              ),
              decoration: const InputDecoration(
                  labelText: 'Numero da conta', hintText: '0000'),
              keyboardType: TextInputType.number,
            ),
          ),
           Padding(
            padding: const EdgeInsets.all(8.0),
            child: TextField(
              controller: _controlarValor,
              style: const TextStyle(
                fontSize: 24.0,
              ),
              decoration: const InputDecoration(
                  icon: Icon(Icons.monetization_on),
                  labelText: 'Valor',
                  hintText: '0.00'),
              keyboardType: TextInputType.number,
            ),
          ),
          ElevatedButton(
            onPressed: () {
              debugPrint('teste');
              final  int? numeroConta = int.tryParse(_controlarNumeroConta.text);
              final  double? valor = double.tryParse(_controlarNumeroConta.text);
              if (numeroConta != null && valor != null) {
                final tranferencia = Transferencia(valor, numeroConta);
                debugPrint('$Transferencia');
              }

            },
            child: const Text('Confirmar'),
          ),
        ],
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Transferencias'),
      ),
      body: Column(
        children: <Widget>[
          ItemTransferencia(Transferencia(100.0, 1000)),
          ItemTransferencia(Transferencia(200.0, 1000)),
          ItemTransferencia(Transferencia(400.0, 1000)),
        ],
      ),
      floatingActionButton: FloatingActionButton(
        child: const Icon(Icons.add),
        onPressed: () {},
      ),
    );
  }
}

class ItemTransferencia extends StatelessWidget {
  final Transferencia _transferencia;

  const ItemTransferencia(this._transferencia, {super.key});

  @override
  Widget build(BuildContext context) {
    return Card(
        child: ListTile(
          leading: const Icon(Icons.monetization_on),
          title: Text(_transferencia.valor.toString()),
          subtitle: Text(_transferencia.numeroConta.toString()),
        ));
  }
}

class Transferencia {
  final double valor;
  final int numeroConta;

  Transferencia(this.valor, this.numeroConta);

  @override
  String toString() {
    return 'Transferencia{valor: $valor, numeroConta: $numeroConta}';
  }
}
1 resposta

valeu