Browse Source

Merge pull request #424 from Leptopoda/cleanup/String.isEmpty

neon, neon_news, neon_notes: prefer isEmpty over ''
pull/428/head
Nikolas Rimikis 1 year ago committed by GitHub
parent
commit
26664b47b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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. 36
      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) { String userAgent(final PackageInfo packageInfo) {
var buildNumber = packageInfo.buildNumber; var buildNumber = packageInfo.buildNumber;
if (buildNumber == '') { if (buildNumber.isEmpty) {
buildNumber = '1'; buildNumber = '1';
} }
return 'Neon ${packageInfo.version}+$buildNumber'; 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) { if (notification?.shouldNotify ?? true) {
final appID = notification?.app ?? pushNotification.subject.app ?? 'nextcloud'; final appID = notification?.app ?? pushNotification.subject.app ?? 'nextcloud';
String? appName = localizations.appImplementationName(appID); String? appName = localizations.appImplementationName(appID);
if (appName == '') { if (appName.isEmpty) {
debugPrint('Missing app name for $appID'); debugPrint('Missing app name for $appID');
appName = null; appName = null;
} }

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

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

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

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

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

@ -14,7 +14,7 @@ class NotesCategoryPage extends StatelessWidget {
Widget build(final BuildContext context) => Scaffold( Widget build(final BuildContext context) => Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( 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( body: NotesView(
bloc: bloc, bloc: bloc,

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

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

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

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

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

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

Loading…
Cancel
Save