Why does getAt have a nullable return type if it throws an exception on out of range errors?
- Dominant language
- Dart
- Stars
- 4.4k
- Forks
- 449
- PR merge metrics
- No merged PRs in 30d
Description
**Question**
The getAt() function's return type is E?. However, when I call getAt with an index outside of range, I get a thrown exception with an out of range error. When would getAt actually return null if E was not a nullable type? Should getAt's return type be just "E" instead of "E?" ?
**Version**
- Platform: Android
- Flutter version: 3.3.9
- Hive version: 2.2.3
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the getAt entry point and checking its documented behavior for out-of-range indexes and nullable element types. Confirm whether the current return type and exception behavior are intentional, then document the expected contract or add the relevant regression coverage; the issue is resolved when the API behavior and return type are consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100