im having some issues with my integration tests in flutter on how i can check if an error pops up when wrong value is input idk how to check for it any help would be much appeciated.
`
child: TextFormField(
key: Key('UserEntry_btc'),
textAlign: TextAlign.center,
// inputFormatters: [
// FilteringTextInputFormatter.digitsOnly
// ],
decoration: InputDecoration(
errorText:
showError ? guessTextFieldErrorMessage : null,
hintText: "Enter USD amount",
),
keyboardType: TextInputType.number,
controller: UserInput,
),
)),
)),
Padding(padding: EdgeInsets.all(4)),
SizedBox(
width: 280,
height: 45,
child: ElevatedButton(
key: Key("ConvertButton_btc"),
style: ElevatedButton.styleFrom(
primary: Color(0xFF4C748B),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(17),
),
elevation: 0.0,
),
//Code in OnPressed
onPressed: () {
USD = UserInput.text;
setState(() {
visible = false;
try {
if (UserInput.text.isEmpty ||
UserInput.text.contains(RegExp(r'[a-z,A-Z]+$'))) {
showError = true;
visible = false;
guessTextFieldErrorMessage =
'Invalid input, must be an number';
} else {
visible = true;
USD =
BtcTools.BtcToUsd(double.parse(UserInput.text))
.toStringAsFixed(2);
showError = false;
}
} catch (e) {
//If the user is guessing an invalid character return this message
guessTextFieldErrorMessage =
'Invalid input, must be an number';
showError = true;
visible = false;
}
});
USD = BtcTools.UsdToBtc(double.parse(UserInput.text))
.toString();
// USD = BtcTools.UsdToBtc(double.parse(UserInput.text))
// .toStringAsFixed(7);
},
`
here is how im running some tests i do not know what im needing to call in the test if their is a way.
`test("should give conversion for USD to BTC", () async {
//expect(await driver.getText(apptitle), 'Currency Converter App');
await driver.tap(btc_selection_button);
//expect(await driver.getText(btc_entry), 'Enter USD amount');
await driver.tap(btc_entry);
await driver.enterText('-3');
await driver.waitFor(find.text('-3'));
await driver.tap(btc_convert_button);
expect(
await driver.getText(btc_error), 'Invalid input, must be an number');
//expect(await driver.getText(btc_result), '0.9941365 BTC');
await driver.tap(btc_back_button);
});`
ive tried to double key it but i dont seem to understand how or where to.