Custom parameter for type List<int> is causing RangeError exception
josechagas opened this issue · 1 comments
josechagas commented
Exception
Shell: RangeError (index): Invalid value: Not in inclusive range 0..4: 5
Shell: RangeError (index): Invalid value: Not in inclusive range 0..4: 5
Shell: RangeError (index): Invalid value: Not in inclusive range 0..4: 5
Custom parameter definition
class ListIntParameter extends CustomParameter<List<int>> {
ListIntParameter()
: super('listInt', RegExp(r'(\[(\d+(\,\d)*)*\]){1}', caseSensitive: false), (value) {
print('1 - aqui:'+value);
final result = value.replaceAll(RegExp(r'\[|\]'), '').split(',')
.map(
(e) => int.tryParse(e),
)
.whereNotNull()
.toList(
growable: false,
);
print(result);
return result;
});
}
Step definition
class GivenUserEntersTheInformations extends Given5WithWorld<String, String,
String, List<int>, String, MyWorld> {
@override
Future<void> executeStep(
String primaryPosition,
String secondaryPosition,
String preferredFieldSide,
List<int> skillsIds,
String favoriteFoot,
) async {
// TODO: implement executeStep
throw UnimplementedError();
}
@override
Pattern get pattern => RegExp(
r'User enters the informations {string}, {string}, {string}, {listInt}, {string}',
);
}
jonsamwell commented
What is the error and stack trace? How is this custom parameter for used.
Please provide more context.
…On Thu, Dec 23, 2021, 22:50 José Lucas Souza das Chagas < ***@***.***> wrote:
class ListIntParameter extends CustomParameter<List<int>> {
ListIntParameter()
: super('listInt', RegExp(r'(\[(\d+(\,\d)*)*\]){1}', caseSensitive: false), (value) {
print('1 - aqui:'+value);
final result = value.replaceAll(RegExp(r'\[|\]'), '').split(',')
.map(
(e) => int.tryParse(e),
)
.whereNotNull()
.toList(
growable: false,
);
print(result);
return result;
});
}
—
Reply to this email directly, view it on GitHub
<#56>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA4F7IM7PGDG3DK3FF7IACDUSMEHLANCNFSM5KUTWXMQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>