Skip to content

Commit

Permalink
More cast cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmorgan committed Sep 30, 2024
1 parent 8d370e1 commit 875e641
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ class FileSelectorIOS extends FileSelectorPlatform {
String? initialDirectory,
String? confirmButtonText,
}) async {
final List<String> path = (await _hostApi.openFile(FileSelectorConfig(
utis: _allowedUtiListFromTypeGroups(acceptedTypeGroups))))
.cast<String>();
final List<String> path = await _hostApi.openFile(FileSelectorConfig(
utis: _allowedUtiListFromTypeGroups(acceptedTypeGroups)));
return path.isEmpty ? null : XFile(path.first);
}

Expand All @@ -33,10 +32,9 @@ class FileSelectorIOS extends FileSelectorPlatform {
String? initialDirectory,
String? confirmButtonText,
}) async {
final List<String> pathList = (await _hostApi.openFile(FileSelectorConfig(
utis: _allowedUtiListFromTypeGroups(acceptedTypeGroups),
allowMultiSelection: true)))
.cast<String>();
final List<String> pathList = await _hostApi.openFile(FileSelectorConfig(
utis: _allowedUtiListFromTypeGroups(acceptedTypeGroups),
allowMultiSelection: true));
return pathList.map((String path) => XFile(path)).toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,11 @@ base class SharedPreferencesAsyncFoundation
SharedPreferencesOptions options,
) async {
final PreferencesFilters filter = parameters.filter;
final Map<String?, Object?>? data =
await _convertKnownExceptions<Map<String?, Object?>>(
() async => _api.getAll(
filter.allowList?.toList(),
_convertOptionsToPigeonOptions(options),
));

return data!.cast<String, Object>();
return (await _convertKnownExceptions<Map<String, Object>>(
() async => _api.getAll(
filter.allowList?.toList(),
_convertOptionsToPigeonOptions(options),
)))!;
}

Future<T?> _convertKnownExceptions<T>(Future<T?> Function() method) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ class SharedPreferencesFoundation extends SharedPreferencesStorePlatform {
Future<Map<String, Object>> getAllWithParameters(
GetAllParameters parameters) async {
final PreferencesFilter filter = parameters.filter;
final Map<String?, Object?> data =
await _api.getAll(filter.prefix, filter.allowList?.toList());
return data.cast<String, Object>();
return _api.getAll(filter.prefix, filter.allowList?.toList());
}

@override
Expand Down

0 comments on commit 875e641

Please sign in to comment.