Browse Source

neon: make use of collection in find extensions

pull/394/head
Nikolas Rimikis 1 year ago
parent
commit
7b12389316
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 1
      packages/neon/neon/lib/neon.dart
  2. 11
      packages/neon/neon/lib/src/models/account.dart
  3. 10
      packages/neon/neon/lib/src/utils/app_implementation.dart

1
packages/neon/neon/lib/neon.dart

@ -6,6 +6,7 @@ import 'dart:io';
import 'dart:ui'; import 'dart:ui';
import 'package:bitmap/bitmap.dart'; import 'package:bitmap/bitmap.dart';
import 'package:collection/collection.dart';
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:filesize/filesize.dart'; import 'package:filesize/filesize.dart';

11
packages/neon/neon/lib/src/models/account.dart

@ -1,5 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:collection/collection.dart';
import 'package:crypto/crypto.dart'; import 'package:crypto/crypto.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:json_annotation/json_annotation.dart'; import 'package:json_annotation/json_annotation.dart';
@ -104,13 +105,5 @@ extension NextcloudClientHelpers on NextcloudClient {
} }
extension AccountFind on Iterable<Account> { extension AccountFind on Iterable<Account> {
Account? find(final String accountID) { Account? find(final String accountID) => firstWhereOrNull((final account) => account.id == accountID);
for (final account in this) {
if (account.id == accountID) {
return account;
}
}
return null;
}
} }

10
packages/neon/neon/lib/src/utils/app_implementation.dart

@ -74,13 +74,5 @@ abstract class AppImplementation<T extends Bloc, R extends NextcloudAppSpecificO
} }
extension AppImplementationFind on Iterable<AppImplementation> { extension AppImplementationFind on Iterable<AppImplementation> {
AppImplementation? find(final String appID) { AppImplementation? find(final String appID) => firstWhereOrNull((final app) => app.id == appID);
for (final app in this) {
if (app.id == appID) {
return app;
}
}
return null;
}
} }

Loading…
Cancel
Save