Skip to content

Commit e672239

Browse files
committed
Fix possible null access in formatNumber
1 parent 30cb68d commit e672239

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/src/intl.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ class L10nDelegate extends LocalizationsDelegate<L10n> {
413413
DateTime secondsToDateTime(int secondsSinceEpoch) =>
414414
DateTime.fromMillisecondsSinceEpoch(secondsSinceEpoch * 1000);
415415

416-
String formatNumber(dynamic value) => _numberFormatCompact.format(value);
416+
String formatNumber(num value) => _numberFormatCompact.format(value);
417417

418418
String formatTimestamp(BuildContext context, int? timestamp) {
419419
if (timestamp == null) return '';

lib/src/widgets/thread/widget.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class _ThreadWidgetActionsState extends State<_ThreadWidgetActions> {
313313
),
314314
),
315315
TextSpan(
316-
text: " ${formatNumber(post.postLikeCount)}",
316+
text: " ${formatNumber(postLikeCount)}",
317317
style: textStyle,
318318
),
319319
];

lib/src/widgets/user/member_view_header.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class MemberViewHeader extends StatelessWidget {
8181
),
8282
const SizedBox(width: 5),
8383
Text(
84-
formatNumber(user.userMessageCount),
84+
formatNumber(user.userMessageCount ?? 0),
8585
style: style,
8686
),
8787
],
@@ -95,7 +95,7 @@ class MemberViewHeader extends StatelessWidget {
9595
),
9696
const SizedBox(width: 5),
9797
Text(
98-
formatNumber(user.userLikeCount),
98+
formatNumber(user.userLikeCount ?? 0),
9999
style: style,
100100
),
101101
],

0 commit comments

Comments
 (0)