Skip to content

Commit 8cc52fc

Browse files
committed
content [nfc]: Have resolveUrl return a Uri object, not a String
This pushes the `toString` out to callers, so they can pass the string form to whatever other code is asking for it. ...Actually, though, in all the cases where that other code has been asking for the string form, it could easily be changed to accept the Uri form. So we'll do that, coming up.
1 parent 7c77e93 commit 8cc52fc

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/widgets/content.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class MessageImage extends StatelessWidget {
224224
return GestureDetector(
225225
onTap: () {
226226
Navigator.of(context).push(getLightboxRoute(
227-
context: context, message: message, src: resolvedSrc));
227+
context: context, message: message, src: resolvedSrc.toString()));
228228
},
229229
child: Align(
230230
alignment: Alignment.centerLeft,
@@ -241,9 +241,9 @@ class MessageImage extends StatelessWidget {
241241
color: const Color.fromRGBO(0, 0, 0, 0.03),
242242
child: LightboxHero(
243243
message: message,
244-
src: resolvedSrc,
244+
src: resolvedSrc.toString(),
245245
child: RealmContentNetworkImage(
246-
resolvedSrc,
246+
resolvedSrc.toString(),
247247
filterQuality: FilterQuality.medium))))));
248248
}
249249
}
@@ -648,7 +648,7 @@ class MessageImageEmoji extends StatelessWidget {
648648
// too low.
649649
top: -1.5,
650650
child: RealmContentNetworkImage(
651-
resolvedSrc,
651+
resolvedSrc.toString(),
652652
filterQuality: FilterQuality.medium,
653653
width: size,
654654
height: size,
@@ -823,10 +823,9 @@ class RealmContentNetworkImage extends StatelessWidget {
823823
/// Resolve `url` to `account`'s realm, if relative
824824
// This may dissolve when we start passing around URLs as [Uri] objects instead
825825
// of strings.
826-
String resolveUrl(String url, Account account) {
826+
Uri resolveUrl(String url, Account account) {
827827
final realmUrl = account.realmUrl;
828-
final resolved = realmUrl.resolve(url); // TODO handle if fails to parse
829-
return resolved.toString();
828+
return realmUrl.resolve(url); // TODO handle if fails to parse
830829
}
831830

832831
InlineSpan _errorUnimplemented(UnimplementedNode node) {

lib/widgets/message_list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ class MessageWithSender extends StatelessWidget {
482482
final avatar = (avatarUrl == null)
483483
? const SizedBox.shrink()
484484
: RealmContentNetworkImage(
485-
avatarUrl,
485+
avatarUrl.toString(),
486486
filterQuality: FilterQuality.medium,
487487
);
488488

0 commit comments

Comments
 (0)