Browse Source

neon, neon_news, neon_notes: prefer isEmpty over ''

pull/424/head
Nikolas Rimikis 1 year ago
parent
commit
ce9723bb35
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 2
      packages/neon/neon/lib/src/models/account.dart
  2. 2
      packages/neon/neon/lib/src/utils/push_utils.dart
  3. 4
      packages/neon/neon/lib/src/utils/validators.dart
  4. 10
      packages/neon/neon_news/lib/widgets/feed_icon.dart
  5. 2
      packages/neon/neon_notes/lib/pages/category.dart
  6. 4
      packages/neon/neon_notes/lib/widgets/categories_view.dart
  7. 6
      packages/neon/neon_notes/lib/widgets/category_select.dart
  8. 2
      packages/neon/neon_notes/lib/widgets/notes_view.dart

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

@ -34,7 +34,7 @@ Future<Account> getAccount(
String userAgent(final PackageInfo packageInfo) {
var buildNumber = packageInfo.buildNumber;
if (buildNumber == '') {
if (buildNumber.isEmpty) {
buildNumber = '1';
}
return 'Neon ${packageInfo.version}+$buildNumber';

2
packages/neon/neon/lib/src/utils/push_utils.dart

@ -121,7 +121,7 @@ class PushUtils {
if (notification?.shouldNotify ?? true) {
final appID = notification?.app ?? pushNotification.subject.app ?? 'nextcloud';
String? appName = localizations.appImplementationName(appID);
if (appName == '') {
if (appName.isEmpty) {
debugPrint('Missing app name for $appID');
appName = null;
}

4
packages/neon/neon/lib/src/utils/validators.dart

@ -5,7 +5,7 @@ String? validateHttpUrl(
final String? input, {
final bool httpsOnly = false,
}) {
if (input == null || input == '') {
if (input == null || input.isEmpty) {
return AppLocalizations.of(context).errorInvalidURL;
}
try {
@ -22,7 +22,7 @@ String? validateHttpUrl(
}
String? validateNotEmpty(final BuildContext context, final String? input) {
if (input == null || input == '') {
if (input == null || input.isEmpty) {
return AppLocalizations.of(context).errorEmptyField;
}

10
packages/neon/neon_news/lib/widgets/feed_icon.dart

@ -13,13 +13,16 @@ class NewsFeedIcon extends StatelessWidget {
final BorderRadius? borderRadius;
@override
Widget build(final BuildContext context) => NeonImageWrapper(
Widget build(final BuildContext context) {
final faviconLink = feed.faviconLink;
return NeonImageWrapper(
color: Colors.white,
size: Size.square(size),
borderRadius: borderRadius,
child: feed.faviconLink != null && feed.faviconLink != ''
child: faviconLink != null && faviconLink.isNotEmpty
? NeonCachedUrlImage(
url: feed.faviconLink!,
url: faviconLink,
size: Size.square(size),
iconColor: Theme.of(context).colorScheme.primary,
)
@ -30,3 +33,4 @@ class NewsFeedIcon extends StatelessWidget {
),
);
}
}

2
packages/neon/neon_notes/lib/pages/category.dart

@ -14,7 +14,7 @@ class NotesCategoryPage extends StatelessWidget {
Widget build(final BuildContext context) => Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
title: Text(category.name != '' ? category.name : AppLocalizations.of(context).categoryUncategorized),
title: Text(category.name.isNotEmpty ? category.name : AppLocalizations.of(context).categoryUncategorized),
),
body: NotesView(
bloc: bloc,

4
packages/neon/neon_notes/lib/widgets/categories_view.dart

@ -41,9 +41,9 @@ class NotesCategoriesView extends StatelessWidget {
final NoteCategory category,
) =>
ListTile(
title: Text(category.name != '' ? category.name : AppLocalizations.of(context).categoryUncategorized),
title: Text(category.name.isNotEmpty ? category.name : AppLocalizations.of(context).categoryUncategorized),
subtitle: Text(AppLocalizations.of(context).categoryNotesCount(category.count)),
leading: category.name != ''
leading: category.name.isNotEmpty
? Icon(
MdiIcons.tag,
size: 40,

6
packages/neon/neon_notes/lib/widgets/category_select.dart

@ -35,7 +35,7 @@ class NotesCategorySelect extends StatelessWidget {
..._categories,
];
if (value.text == '') {
if (value.text.isEmpty) {
return categories;
}
return categories.where((final category) => category.toLowerCase().contains(value.text.toLowerCase()));
@ -74,10 +74,10 @@ class NotesCategorySelect extends StatelessWidget {
return ListTile(
leading: Icon(
MdiIcons.tag,
color: option != '' ? NotesCategoryColor.compute(option) : null,
color: option.isNotEmpty ? NotesCategoryColor.compute(option) : null,
),
title: Text(
option != '' ? option : AppLocalizations.of(context).categoryUncategorized,
option.isNotEmpty ? option : AppLocalizations.of(context).categoryUncategorized,
),
onTap: () {
onSelected(option);

2
packages/neon/neon_notes/lib/widgets/notes_view.dart

@ -54,7 +54,7 @@ class NotesView extends StatelessWidget {
RelativeTime(
date: DateTime.fromMillisecondsSinceEpoch(note.modified * 1000),
),
if (note.category != '') ...[
if (note.category.isNotEmpty) ...[
const SizedBox(
width: 8,
),

Loading…
Cancel
Save