lib/main.dart:30:17: Error: Too many positional arguments: 4 allowed, but 5 found.
Try removing the extra positional arguments.
Editor(_controladorCampoValor, 'Valor', '0.00', Icons,monetization_on),
^
lib/main.dart:81:3: Context: Found this candidate, but the arguments don't match.
Editor(this._controlador, this._rotulo, this._dica, this._icone);
^^^^^^
lib/main.dart:29:75: Error: The value 'null' can't be assigned to the parameter type
'IconData' because 'IconData' is not nullable.
- 'IconData' is from 'package:flutter/src/widgets/icon_data.dart'
('../../snap/flutter/common/flutter/packages/flutter/lib/src/widgets/icon_data.dart').
Editor(_controladorCampoNumeroConta, 'Número da Conta', '0000', null),
^
import 'package:flutter/material.dart';
void main() => runApp(BytebankApp());
class BytebankApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: FormularioTransferencia(),
),
);
}
}
class FormularioTransferencia extends StatelessWidget {
final TextEditingController _controladorCampoNumeroConta =
TextEditingController();
final TextEditingController _controladorCampoValor = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Criando Transferência'),
),
body: Column(
children: <Widget>[
Editor(_controladorCampoNumeroConta, 'Número da Conta', '0000', null),
Editor(_controladorCampoValor, 'Valor', '0.00', Icons,monetization_on),
ElevatedButton(
onPressed: () {
debugPrint('clicou no confirmar');
final int? numeroConta = int.tryParse(_controladorCampoNumeroConta.text);
final double? valor = double.tryParse(_controladorCampoValor.text);
if(numeroConta != null && valor != null){
final transferenciaCriada = Transferencia( valor, numeroConta);
debugPrint('$transferenciaCriada');
}
},
child: const Text(
"Confirmar",
style: TextStyle(fontSize: 24),
),
)
],
),
);
}
}
class ListaTransferencia extends StatelessWidget{
@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
title: Text('Transferências'),
),
body: Column(
children: <Widget>[
ItemTransferencia(Transferencia(100.0, 1000)),
ItemTransferencia(Transferencia(200.0, 2000)),
ItemTransferencia(Transferencia(300.0, 3000)),
],
),
floatingActionButton: FloatingActionButton(
onPressed: () { },
child: Icon(Icons.add),
),
);
}
}
class Editor extends StatelessWidget {
final TextEditingController _controlador;
final String _rotulo;
final String _dica;
final IconData _icone;
Editor(this._controlador, this._rotulo, this._dica, this._icone);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: TextField(
controller: _controlador,
style: TextStyle(
fontSize: 24.0,
),
decoration: InputDecoration(
icon: Icon(_icone),
labelText: _rotulo,
hintText: _dica,
),
keyboardType: TextInputType.number,
),
);
}
}
class ItemTransferencia extends StatelessWidget {
final Transferencia _transferencia;
ItemTransferencia(this._transferencia);
@override
Widget build(BuildContext context) {
// TODO: implement build
return Card(
child: ListTile(
leading: 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}';
}
}