From ee7d0ddd25226ec043836578e47038418813cb86 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 26 Dec 2024 23:01:00 +0800 Subject: [PATCH] :art: Fix most of linting notes --- lib/providers/sn_attachment.dart | 12 +++--- .../account/publishers/publisher_edit.dart | 39 +++++++------------ .../account/publishers/publisher_new.dart | 2 +- lib/screens/auth/login.dart | 27 ++++++------- lib/screens/chat/channel_detail.dart | 4 +- lib/screens/chat/room.dart | 1 - lib/screens/friend.dart | 4 +- lib/screens/home.dart | 10 ++--- lib/screens/post/publisher_page.dart | 1 - lib/screens/realm/realm_detail.dart | 8 ++-- lib/types/attachment.dart | 1 + lib/types/attachment.freezed.dart | 37 ++++++++++++++---- lib/types/attachment.g.dart | 2 + lib/widgets/account/account_select.dart | 2 +- lib/widgets/attachment/attachment_item.dart | 20 +++++----- lib/widgets/chat/chat_message.dart | 4 +- lib/widgets/link_preview.dart | 1 - lib/widgets/post/post_item.dart | 10 ++--- lib/widgets/post/post_media_pending_list.dart | 5 +-- pubspec.lock | 6 +-- pubspec.yaml | 1 + 21 files changed, 100 insertions(+), 97 deletions(-) diff --git a/lib/providers/sn_attachment.dart b/lib/providers/sn_attachment.dart index 1ec2878..f4181bb 100644 --- a/lib/providers/sn_attachment.dart +++ b/lib/providers/sn_attachment.dart @@ -217,15 +217,17 @@ class SnAttachmentProvider { } Future updateOne( - int id, - String alt, { - required Map metadata, - bool isMature = false, + int id, { + String? alt, + String? thumbnail, + Map? metadata, + bool? isIndexable, }) async { final resp = await _sn.client.put('/cgi/uc/attachments/$id', data: { 'alt': alt, + 'thumbnail': thumbnail, 'metadata': metadata, - 'is_mature': isMature, + 'is_indexable': isIndexable, }); return SnAttachment.fromJson(resp.data); } diff --git a/lib/screens/account/publishers/publisher_edit.dart b/lib/screens/account/publishers/publisher_edit.dart index 475ef92..488e808 100644 --- a/lib/screens/account/publishers/publisher_edit.dart +++ b/lib/screens/account/publishers/publisher_edit.dart @@ -22,15 +22,14 @@ import 'package:surface/widgets/universal_image.dart'; class AccountPublisherEditScreen extends StatefulWidget { final String name; + const AccountPublisherEditScreen({super.key, required this.name}); @override - State createState() => - _AccountPublisherEditScreenState(); + State createState() => _AccountPublisherEditScreenState(); } -class _AccountPublisherEditScreenState - extends State { +class _AccountPublisherEditScreenState extends State { bool _isBusy = false; SnPublisher? _publisher; @@ -54,7 +53,7 @@ class _AccountPublisherEditScreenState _publisher = SnPublisher.fromJson(resp.data); _syncWidget(); } catch (err) { - context.showErrorDialog(err); + if (mounted) context.showErrorDialog(err); } finally { setState(() => _isBusy = false); } @@ -75,9 +74,9 @@ class _AccountPublisherEditScreenState 'name': _nameController.text, 'description': _descriptionController.text, }); - Navigator.pop(context, true); + if (mounted) Navigator.pop(context, true); } catch (err) { - context.showErrorDialog(err); + if(mounted) context.showErrorDialog(err); } finally { setState(() => _isBusy = false); } @@ -108,11 +107,9 @@ class _AccountPublisherEditScreenState if (image == null) return; if (!mounted) return; - final ImageProvider imageProvider = - kIsWeb ? NetworkImage(image.path) : FileImage(File(image.path)); - final aspectRatios = place == 'banner' - ? [CropAspectRatio(width: 16, height: 7)] - : [CropAspectRatio(width: 1, height: 1)]; + final ImageProvider imageProvider = kIsWeb ? NetworkImage(image.path) : FileImage(File(image.path)); + final aspectRatios = + place == 'banner' ? [CropAspectRatio(width: 16, height: 7)] : [CropAspectRatio(width: 1, height: 1)]; final result = (!kIsWeb && (Platform.isIOS || Platform.isMacOS)) ? await showCupertinoImageCropper( // ignore: use_build_context_synchronously @@ -134,10 +131,7 @@ class _AccountPublisherEditScreenState setState(() => _isBusy = true); - final rawBytes = - (await result.uiImage.toByteData(format: ImageByteFormat.png))! - .buffer - .asUint8List(); + final rawBytes = (await result.uiImage.toByteData(format: ImageByteFormat.png))!.buffer.asUint8List(); try { final attachment = await attach.directUploadOne( @@ -199,9 +193,7 @@ class _AccountPublisherEditScreenState child: AspectRatio( aspectRatio: 16 / 9, child: Container( - color: Theme.of(context) - .colorScheme - .surfaceContainerHigh, + color: Theme.of(context).colorScheme.surfaceContainerHigh, child: _banner != null ? AutoResizeUniversalImage( sn.getAttachmentUrl(_banner!), @@ -240,8 +232,7 @@ class _AccountPublisherEditScreenState labelText: 'fieldUsername'.tr(), helperText: 'fieldUsernameCannotEditHint'.tr(), ), - onTapOutside: (_) => - FocusManager.instance.primaryFocus?.unfocus(), + onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), ), const Gap(4), TextField( @@ -249,8 +240,7 @@ class _AccountPublisherEditScreenState decoration: InputDecoration( labelText: 'fieldNickname'.tr(), ), - onTapOutside: (_) => - FocusManager.instance.primaryFocus?.unfocus(), + onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), ), const Gap(4), TextField( @@ -260,8 +250,7 @@ class _AccountPublisherEditScreenState decoration: InputDecoration( labelText: 'fieldDescription'.tr(), ), - onTapOutside: (_) => - FocusManager.instance.primaryFocus?.unfocus(), + onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(), ), const Gap(12), Row( diff --git a/lib/screens/account/publishers/publisher_new.dart b/lib/screens/account/publishers/publisher_new.dart index b10664c..80239f5 100644 --- a/lib/screens/account/publishers/publisher_new.dart +++ b/lib/screens/account/publishers/publisher_new.dart @@ -201,7 +201,7 @@ class _PublisherNewPersonalState extends State<_PublisherNewPersonal> { } class _PublisherNewOrganization extends StatefulWidget { - const _PublisherNewOrganization({super.key}); + const _PublisherNewOrganization(); @override State<_PublisherNewOrganization> createState() => diff --git a/lib/screens/auth/login.dart b/lib/screens/auth/login.dart index 84eaee0..46f90a2 100644 --- a/lib/screens/auth/login.dart +++ b/lib/screens/auth/login.dart @@ -105,6 +105,7 @@ class _LoginCheckScreen extends StatefulWidget { final SnAuthFactor? factor; final Function(SnAuthTicket?) onTicket; final Function onNext; + const _LoginCheckScreen({ super.key, required this.ticket, @@ -204,9 +205,7 @@ class _LoginCheckScreenState extends State<_LoginCheckScreen> { controller: _passwordController, obscureText: true, autofillHints: [ - (_factorLabelMap[widget.factor!.type]?.$3 ?? true) - ? AutofillHints.password - : AutofillHints.oneTimeCode + (_factorLabelMap[widget.factor!.type]?.$3 ?? true) ? AutofillHints.password : AutofillHints.oneTimeCode ], decoration: InputDecoration( isDense: true, @@ -243,6 +242,7 @@ class _LoginPickerScreen extends StatefulWidget { final Function(SnAuthTicket?) onTicket; final Function(SnAuthFactor) onPickFactor; final Function onNext; + const _LoginPickerScreen({ super.key, required this.ticket, @@ -260,8 +260,7 @@ class _LoginPickerScreenState extends State<_LoginPickerScreen> { bool _isBusy = false; int? _factorPicked; - Color get _unFocusColor => - Theme.of(context).colorScheme.onSurface.withAlpha((255 * 0.75).round()); + Color get _unFocusColor => Theme.of(context).colorScheme.onSurface.withAlpha((255 * 0.75).round()); void _performGetFactorCode() async { if (_factorPicked == null) return; @@ -373,6 +372,7 @@ class _LoginLookupScreen extends StatefulWidget { final Function(SnAuthTicket?) onTicket; final Function(List?) onFactor; final Function onNext; + const _LoginLookupScreen({ super.key, required this.ticket, @@ -401,14 +401,13 @@ class _LoginLookupScreenState extends State<_LoginLookupScreen> { try { final sn = context.read(); - final lookupResp = - await sn.client.get('/cgi/id/users/lookup?probe=$username'); + final lookupResp = await sn.client.get('/cgi/id/users/lookup?probe=$username'); await sn.client.post('/cgi/id/users/me/password-reset', data: { 'user_id': lookupResp.data['id'], }); - context.showModalDialog('done'.tr(), 'signinResetPasswordSent'.tr()); + if (mounted) context.showModalDialog('done'.tr(), 'signinResetPasswordSent'.tr()); } catch (err) { - context.showErrorDialog(err); + if (mounted) context.showErrorDialog(err); } finally { setState(() => _isBusy = false); } @@ -431,8 +430,7 @@ class _LoginLookupScreenState extends State<_LoginLookupScreen> { widget.onTicket(result.ticket); // Pull factors - final factorResp = - await sn.client.get('/cgi/id/auth/factors', queryParameters: { + final factorResp = await sn.client.get('/cgi/id/auth/factors', queryParameters: { 'ticketId': result.ticket!.id.toString(), }); widget.onFactor( @@ -443,7 +441,7 @@ class _LoginLookupScreenState extends State<_LoginLookupScreen> { widget.onNext(); } catch (err) { - context.showErrorDialog(err); + if(mounted) context.showErrorDialog(err); return; } finally { setState(() => _isBusy = false); @@ -526,10 +524,7 @@ class _LoginLookupScreenState extends State<_LoginLookupScreen> { 'termAcceptNextWithAgree'.tr(), textAlign: TextAlign.end, style: Theme.of(context).textTheme.bodySmall!.copyWith( - color: Theme.of(context) - .colorScheme - .onSurface - .withAlpha((255 * 0.75).round()), + color: Theme.of(context).colorScheme.onSurface.withAlpha((255 * 0.75).round()), ), ), Material( diff --git a/lib/screens/chat/channel_detail.dart b/lib/screens/chat/channel_detail.dart index 1279085..0f13927 100644 --- a/lib/screens/chat/channel_detail.dart +++ b/lib/screens/chat/channel_detail.dart @@ -443,7 +443,7 @@ class _ChannelProfileDetailDialogState class _ChannelMemberListWidget extends StatefulWidget { final SnChannel channel; - const _ChannelMemberListWidget({super.key, required this.channel}); + const _ChannelMemberListWidget({required this.channel}); @override State<_ChannelMemberListWidget> createState() => @@ -580,7 +580,7 @@ class _ChannelMemberListWidgetState extends State<_ChannelMemberListWidget> { class _NewChannelMemberWidget extends StatefulWidget { final SnChannel channel; - const _NewChannelMemberWidget({super.key, required this.channel}); + const _NewChannelMemberWidget({required this.channel}); @override State<_NewChannelMemberWidget> createState() => diff --git a/lib/screens/chat/room.dart b/lib/screens/chat/room.dart index d24c77c..f3f3198 100644 --- a/lib/screens/chat/room.dart +++ b/lib/screens/chat/room.dart @@ -97,7 +97,6 @@ class _ChatRoomScreenState extends State { } } catch (err) { if (!mounted) return; - print((err as DioException).response?.data); context.showErrorDialog(err); } finally { setState(() => _isCalling = false); diff --git a/lib/screens/friend.dart b/lib/screens/friend.dart index 4c44eb7..c33f741 100644 --- a/lib/screens/friend.dart +++ b/lib/screens/friend.dart @@ -289,7 +289,7 @@ class _FriendScreenState extends State { } class _NewFriendWidget extends StatefulWidget { - const _NewFriendWidget({super.key}); + const _NewFriendWidget(); @override State<_NewFriendWidget> createState() => _NewFriendWidgetState(); @@ -365,7 +365,7 @@ class _NewFriendWidgetState extends State<_NewFriendWidget> { class _FriendshipListWidget extends StatefulWidget { final List relations; - const _FriendshipListWidget({super.key, required this.relations}); + const _FriendshipListWidget({required this.relations}); @override State<_FriendshipListWidget> createState() => _FriendshipListWidgetState(); diff --git a/lib/screens/home.dart b/lib/screens/home.dart index c1d8e5d..323fb44 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -109,7 +109,7 @@ class _HomeScreenState extends State { class _HomeDashUpdateWidget extends StatelessWidget { final EdgeInsets? padding; - const _HomeDashUpdateWidget({super.key, this.padding}); + const _HomeDashUpdateWidget({this.padding}); @override Widget build(BuildContext context) { @@ -153,7 +153,7 @@ class _HomeDashUpdateWidget extends StatelessWidget { } class _HomeDashSpecialDayWidget extends StatelessWidget { - const _HomeDashSpecialDayWidget({super.key}); + const _HomeDashSpecialDayWidget(); @override Widget build(BuildContext context) { @@ -215,7 +215,7 @@ class _HomeDashSpecialDayWidget extends StatelessWidget { } class _HomeDashCheckInWidget extends StatefulWidget { - const _HomeDashCheckInWidget({super.key}); + const _HomeDashCheckInWidget(); @override State<_HomeDashCheckInWidget> createState() => _HomeDashCheckInWidgetState(); @@ -433,7 +433,7 @@ class _HomeDashCheckInWidgetState extends State<_HomeDashCheckInWidget> { } class _HomeDashNotificationWidget extends StatefulWidget { - const _HomeDashNotificationWidget({super.key}); + const _HomeDashNotificationWidget(); @override State<_HomeDashNotificationWidget> createState() => _HomeDashNotificationWidgetState(); @@ -504,7 +504,7 @@ class _HomeDashNotificationWidgetState extends State<_HomeDashNotificationWidget } class _HomeDashRecommendationPostWidget extends StatefulWidget { - const _HomeDashRecommendationPostWidget({super.key}); + const _HomeDashRecommendationPostWidget(); @override State<_HomeDashRecommendationPostWidget> createState() => _HomeDashRecommendationPostWidgetState(); diff --git a/lib/screens/post/publisher_page.dart b/lib/screens/post/publisher_page.dart index 477f607..1b73fa7 100644 --- a/lib/screens/post/publisher_page.dart +++ b/lib/screens/post/publisher_page.dart @@ -580,7 +580,6 @@ class _PublisherPostList extends StatelessWidget { final void Function() onDeleted; const _PublisherPostList({ - super.key, required this.isBusy, required this.postCount, required this.posts, diff --git a/lib/screens/realm/realm_detail.dart b/lib/screens/realm/realm_detail.dart index c8bc85d..0438e25 100644 --- a/lib/screens/realm/realm_detail.dart +++ b/lib/screens/realm/realm_detail.dart @@ -119,7 +119,7 @@ class _RealmDetailHomeWidget extends StatelessWidget { final SnRealm? realm; final List? publishers; - const _RealmDetailHomeWidget({super.key, required this.realm, this.publishers}); + const _RealmDetailHomeWidget({required this.realm, this.publishers}); @override Widget build(BuildContext context) { @@ -175,7 +175,7 @@ class _RealmDetailHomeWidget extends StatelessWidget { class _RealmMemberListWidget extends StatefulWidget { final SnRealm? realm; - const _RealmMemberListWidget({super.key, this.realm}); + const _RealmMemberListWidget({this.realm}); @override State<_RealmMemberListWidget> createState() => _RealmMemberListWidgetState(); @@ -304,7 +304,7 @@ class _RealmMemberListWidgetState extends State<_RealmMemberListWidget> { class _NewRealmMemberWidget extends StatefulWidget { final SnRealm realm; - const _NewRealmMemberWidget({super.key, required this.realm}); + const _NewRealmMemberWidget({required this.realm}); @override State<_NewRealmMemberWidget> createState() => _NewRealmMemberWidgetState(); @@ -384,7 +384,7 @@ class _RealmSettingsWidget extends StatefulWidget { final SnRealm? realm; final Function() onUpdate; - const _RealmSettingsWidget({super.key, required this.realm, required this.onUpdate}); + const _RealmSettingsWidget({required this.realm, required this.onUpdate}); @override State<_RealmSettingsWidget> createState() => _RealmSettingsWidgetState(); diff --git a/lib/types/attachment.dart b/lib/types/attachment.dart index 2bd38af..ab02f9b 100644 --- a/lib/types/attachment.dart +++ b/lib/types/attachment.dart @@ -43,6 +43,7 @@ class SnAttachment with _$SnAttachment { required int accountId, @Default({}) Map usermeta, @Default({}) Map metadata, + String? thumbnail, }) = _SnAttachment; factory SnAttachment.fromJson(Map json) => _$SnAttachmentFromJson(json); diff --git a/lib/types/attachment.freezed.dart b/lib/types/attachment.freezed.dart index ab4ba29..82c7e12 100644 --- a/lib/types/attachment.freezed.dart +++ b/lib/types/attachment.freezed.dart @@ -47,6 +47,7 @@ mixin _$SnAttachment { int get accountId => throw _privateConstructorUsedError; Map get usermeta => throw _privateConstructorUsedError; Map get metadata => throw _privateConstructorUsedError; + String? get thumbnail => throw _privateConstructorUsedError; /// Serializes this SnAttachment to a JSON map. Map toJson() => throw _privateConstructorUsedError; @@ -91,7 +92,8 @@ abstract class $SnAttachmentCopyWith<$Res> { int poolId, int accountId, Map usermeta, - Map metadata}); + Map metadata, + String? thumbnail}); $SnAttachmentPoolCopyWith<$Res>? get pool; } @@ -138,6 +140,7 @@ class _$SnAttachmentCopyWithImpl<$Res, $Val extends SnAttachment> Object? accountId = null, Object? usermeta = null, Object? metadata = null, + Object? thumbnail = freezed, }) { return _then(_value.copyWith( id: null == id @@ -248,6 +251,10 @@ class _$SnAttachmentCopyWithImpl<$Res, $Val extends SnAttachment> ? _value.metadata : metadata // ignore: cast_nullable_to_non_nullable as Map, + thumbnail: freezed == thumbnail + ? _value.thumbnail + : thumbnail // ignore: cast_nullable_to_non_nullable + as String?, ) as $Val); } @@ -301,7 +308,8 @@ abstract class _$$SnAttachmentImplCopyWith<$Res> int poolId, int accountId, Map usermeta, - Map metadata}); + Map metadata, + String? thumbnail}); @override $SnAttachmentPoolCopyWith<$Res>? get pool; @@ -347,6 +355,7 @@ class __$$SnAttachmentImplCopyWithImpl<$Res> Object? accountId = null, Object? usermeta = null, Object? metadata = null, + Object? thumbnail = freezed, }) { return _then(_$SnAttachmentImpl( id: null == id @@ -457,6 +466,10 @@ class __$$SnAttachmentImplCopyWithImpl<$Res> ? _value._metadata : metadata // ignore: cast_nullable_to_non_nullable as Map, + thumbnail: freezed == thumbnail + ? _value.thumbnail + : thumbnail // ignore: cast_nullable_to_non_nullable + as String?, )); } } @@ -491,7 +504,8 @@ class _$SnAttachmentImpl extends _SnAttachment { required this.poolId, required this.accountId, final Map usermeta = const {}, - final Map metadata = const {}}) + final Map metadata = const {}, + this.thumbnail}) : _usermeta = usermeta, _metadata = metadata, super._(); @@ -569,9 +583,12 @@ class _$SnAttachmentImpl extends _SnAttachment { return EqualUnmodifiableMapView(_metadata); } + @override + final String? thumbnail; + @override String toString() { - return 'SnAttachment(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, rid: $rid, uuid: $uuid, size: $size, name: $name, alt: $alt, mimetype: $mimetype, hash: $hash, destination: $destination, refCount: $refCount, contentRating: $contentRating, qualityRating: $qualityRating, fileChunks: $fileChunks, cleanedAt: $cleanedAt, isAnalyzed: $isAnalyzed, isUploaded: $isUploaded, isSelfRef: $isSelfRef, ref: $ref, refId: $refId, pool: $pool, poolId: $poolId, accountId: $accountId, usermeta: $usermeta, metadata: $metadata)'; + return 'SnAttachment(id: $id, createdAt: $createdAt, updatedAt: $updatedAt, deletedAt: $deletedAt, rid: $rid, uuid: $uuid, size: $size, name: $name, alt: $alt, mimetype: $mimetype, hash: $hash, destination: $destination, refCount: $refCount, contentRating: $contentRating, qualityRating: $qualityRating, fileChunks: $fileChunks, cleanedAt: $cleanedAt, isAnalyzed: $isAnalyzed, isUploaded: $isUploaded, isSelfRef: $isSelfRef, ref: $ref, refId: $refId, pool: $pool, poolId: $poolId, accountId: $accountId, usermeta: $usermeta, metadata: $metadata, thumbnail: $thumbnail)'; } @override @@ -617,7 +634,9 @@ class _$SnAttachmentImpl extends _SnAttachment { (identical(other.accountId, accountId) || other.accountId == accountId) && const DeepCollectionEquality().equals(other._usermeta, _usermeta) && - const DeepCollectionEquality().equals(other._metadata, _metadata)); + const DeepCollectionEquality().equals(other._metadata, _metadata) && + (identical(other.thumbnail, thumbnail) || + other.thumbnail == thumbnail)); } @JsonKey(includeFromJson: false, includeToJson: false) @@ -650,7 +669,8 @@ class _$SnAttachmentImpl extends _SnAttachment { poolId, accountId, const DeepCollectionEquality().hash(_usermeta), - const DeepCollectionEquality().hash(_metadata) + const DeepCollectionEquality().hash(_metadata), + thumbnail ]); /// Create a copy of SnAttachment @@ -697,7 +717,8 @@ abstract class _SnAttachment extends SnAttachment { required final int poolId, required final int accountId, final Map usermeta, - final Map metadata}) = _$SnAttachmentImpl; + final Map metadata, + final String? thumbnail}) = _$SnAttachmentImpl; const _SnAttachment._() : super._(); factory _SnAttachment.fromJson(Map json) = @@ -757,6 +778,8 @@ abstract class _SnAttachment extends SnAttachment { Map get usermeta; @override Map get metadata; + @override + String? get thumbnail; /// Create a copy of SnAttachment /// with the given fields replaced by the non-null parameter values. diff --git a/lib/types/attachment.g.dart b/lib/types/attachment.g.dart index 0e00d48..ec0282c 100644 --- a/lib/types/attachment.g.dart +++ b/lib/types/attachment.g.dart @@ -37,6 +37,7 @@ _$SnAttachmentImpl _$$SnAttachmentImplFromJson(Map json) => accountId: (json['account_id'] as num).toInt(), usermeta: json['usermeta'] as Map? ?? const {}, metadata: json['metadata'] as Map? ?? const {}, + thumbnail: json['thumbnail'] as String?, ); Map _$$SnAttachmentImplToJson(_$SnAttachmentImpl instance) => @@ -68,6 +69,7 @@ Map _$$SnAttachmentImplToJson(_$SnAttachmentImpl instance) => 'account_id': instance.accountId, 'usermeta': instance.usermeta, 'metadata': instance.metadata, + 'thumbnail': instance.thumbnail, }; _$SnAttachmentPoolImpl _$$SnAttachmentPoolImplFromJson( diff --git a/lib/widgets/account/account_select.dart b/lib/widgets/account/account_select.dart index 5d1b2de..6b4820a 100644 --- a/lib/widgets/account/account_select.dart +++ b/lib/widgets/account/account_select.dart @@ -32,7 +32,7 @@ class _AccountSelectState extends State { final List _pendingUsers = List.empty(growable: true); final List _selectedUsers = List.empty(growable: true); - int _accountId = 0; + final int _accountId = 0; Future _revertSelectedUsers() async { if (widget.initialSelection?.isEmpty ?? true) return; diff --git a/lib/widgets/attachment/attachment_item.dart b/lib/widgets/attachment/attachment_item.dart index 28194b6..7f973ab 100644 --- a/lib/widgets/attachment/attachment_item.dart +++ b/lib/widgets/attachment/attachment_item.dart @@ -80,7 +80,7 @@ class _AttachmentItemSensitiveBlur extends StatefulWidget { final Widget child; final bool isCompact; - const _AttachmentItemSensitiveBlur({super.key, required this.child, this.isCompact = false}); + const _AttachmentItemSensitiveBlur({required this.child, this.isCompact = false}); @override State<_AttachmentItemSensitiveBlur> createState() => _AttachmentItemSensitiveBlurState(); @@ -166,7 +166,6 @@ class _AttachmentItemContentVideo extends StatefulWidget { final bool isAutoload; const _AttachmentItemContentVideo({ - super.key, required this.data, this.isAutoload = false, }); @@ -207,7 +206,7 @@ class _AttachmentItemContentVideoState extends State<_AttachmentItemContentVideo ), ]; - final ratio = widget.data.metadata['ratio'] ?? 16 / 9; + final ratio = widget.data.data['ratio'] ?? 16 / 9; final sn = context.read(); @@ -216,9 +215,9 @@ class _AttachmentItemContentVideoState extends State<_AttachmentItemContentVideo behavior: HitTestBehavior.opaque, child: Stack( children: [ - if (widget.data.metadata['thumbnail'] != null) + if (widget.data.thumbnail != null) AutoResizeUniversalImage( - sn.getAttachmentUrl(widget.data.metadata['thumbnail']), + sn.getAttachmentUrl(widget.data.thumbnail!), fit: BoxFit.cover, ) else @@ -266,7 +265,7 @@ class _AttachmentItemContentVideoState extends State<_AttachmentItemContentVideo ), Text( Duration( - milliseconds: (widget.data.metadata['duration'] ?? 0).toInt() * 1000, + milliseconds: (widget.data.data['duration'] ?? 0).toInt() * 1000, ).toString(), style: GoogleFonts.robotoMono( fontSize: 12, @@ -316,7 +315,6 @@ class _AttachmentItemContentAudio extends StatefulWidget { final bool isAutoload; const _AttachmentItemContentAudio({ - super.key, required this.data, this.isAutoload = false, }); @@ -374,11 +372,11 @@ class _AttachmentItemContentAudioState extends State<_AttachmentItemContentAudio behavior: HitTestBehavior.opaque, child: Stack( children: [ - if (widget.data.metadata['thumbnail'] != null) + if (widget.data.thumbnail != null) AspectRatio( aspectRatio: 16 / 9, child: AutoResizeUniversalImage( - sn.getAttachmentUrl(widget.data.metadata['thumbnail']), + sn.getAttachmentUrl(widget.data.data['thumbnail']), fit: BoxFit.cover, ), ) @@ -459,11 +457,11 @@ class _AttachmentItemContentAudioState extends State<_AttachmentItemContentAudio return Stack( children: [ - if (widget.data.metadata['thumbnail'] != null) + if (widget.data.data['thumbnail'] != null) AspectRatio( aspectRatio: 16 / 9, child: AutoResizeUniversalImage( - sn.getAttachmentUrl(widget.data.metadata['thumbnail']), + sn.getAttachmentUrl(widget.data.data['thumbnail']), fit: BoxFit.cover, ), ), diff --git a/lib/widgets/chat/chat_message.dart b/lib/widgets/chat/chat_message.dart index 4bde90d..26080f0 100644 --- a/lib/widgets/chat/chat_message.dart +++ b/lib/widgets/chat/chat_message.dart @@ -174,7 +174,7 @@ class ChatMessage extends StatelessWidget { class _ChatMessageText extends StatelessWidget { final SnChatMessage data; - const _ChatMessageText({super.key, required this.data}); + const _ChatMessageText({required this.data}); @override Widget build(BuildContext context) { @@ -214,7 +214,7 @@ class _ChatMessageText extends StatelessWidget { class _ChatMessageSystemNotify extends StatelessWidget { final SnChatMessage data; - const _ChatMessageSystemNotify({super.key, required this.data}); + const _ChatMessageSystemNotify({required this.data}); String _formatDuration(Duration duration) { String negativeSign = duration.isNegative ? '-' : ''; diff --git a/lib/widgets/link_preview.dart b/lib/widgets/link_preview.dart index e1bfacc..cc092df 100644 --- a/lib/widgets/link_preview.dart +++ b/lib/widgets/link_preview.dart @@ -60,7 +60,6 @@ class _LinkPreviewEntry extends StatelessWidget { final SnLinkMeta meta; const _LinkPreviewEntry({ - super.key, required this.meta, }); diff --git a/lib/widgets/post/post_item.dart b/lib/widgets/post/post_item.dart index 6b3bb76..a5ebee8 100644 --- a/lib/widgets/post/post_item.dart +++ b/lib/widgets/post/post_item.dart @@ -549,7 +549,6 @@ class _PostHeadline extends StatelessWidget { final bool isEnlarge; const _PostHeadline({ - super.key, required this.data, this.isEnlarge = false, }); @@ -894,7 +893,6 @@ class _PostQuoteContent extends StatelessWidget { final bool isFlatted; const _PostQuoteContent({ - super.key, this.isRelativeDate = true, this.isFlatted = false, required this.child, @@ -962,7 +960,7 @@ class _PostQuoteContent extends StatelessWidget { class _PostTagsList extends StatelessWidget { final SnPost data; - const _PostTagsList({super.key, required this.data}); + const _PostTagsList({required this.data}); @override Widget build(BuildContext context) { @@ -1035,7 +1033,7 @@ class _PostTagsList extends StatelessWidget { class _PostVisibilityHint extends StatelessWidget { final SnPost data; - const _PostVisibilityHint({super.key, required this.data}); + const _PostVisibilityHint({required this.data}); static const List kVisibilityIcons = [ Symbols.public, @@ -1060,7 +1058,7 @@ class _PostVisibilityHint extends StatelessWidget { class _PostTruncatedHint extends StatelessWidget { final SnPost data; - const _PostTruncatedHint({super.key, required this.data}); + const _PostTruncatedHint({required this.data}); static const int kHumanReadSpeed = 238; @@ -1102,7 +1100,7 @@ class _PostTruncatedHint extends StatelessWidget { class _PostAbuseReportDialog extends StatefulWidget { final SnPost data; - const _PostAbuseReportDialog({super.key, required this.data}); + const _PostAbuseReportDialog({required this.data}); @override State<_PostAbuseReportDialog> createState() => _PostAbuseReportDialogState(); diff --git a/lib/widgets/post/post_media_pending_list.dart b/lib/widgets/post/post_media_pending_list.dart index 51e985b..afa5e5e 100644 --- a/lib/widgets/post/post_media_pending_list.dart +++ b/lib/widgets/post/post_media_pending_list.dart @@ -96,10 +96,7 @@ class PostMediaPendingList extends StatelessWidget { if (!context.mounted) return; final attach = context.read(); - final newAttach = await attach.updateOne(attachments[idx].attachment!.id, thumbnail.alt, metadata: { - ...attachments[idx].attachment!.metadata, - 'thumbnail': thumbnail.rid, - }); + final newAttach = await attach.updateOne(attachments[idx].attachment!.id, thumbnail: thumbnail.rid); onUpdate!(idx, PostWriteMedia(newAttach)); } diff --git a/pubspec.lock b/pubspec.lock index 6de3260..4153551 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -763,13 +763,13 @@ packages: source: sdk version: "0.0.0" flutter_webrtc: - dependency: transitive + dependency: "direct main" description: name: flutter_webrtc - sha256: "0e138a0a3bf6830c29c8439b17be0e222d0de27fa72f24e6aee4d34de72f22ef" + sha256: "3efe9828f19a07d29a51a726759ad0c70a840d231548a1c7d0332075a94db1df" url: "https://pub.dev" source: hosted - version: "0.12.5" + version: "0.12.5+hotfix.1" freezed: dependency: "direct dev" description: diff --git a/pubspec.yaml b/pubspec.yaml index 5bfd01d..7798a3e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -113,6 +113,7 @@ dependencies: version: ^3.0.2 flutter_colorpicker: ^1.1.0 fl_chart: ^0.70.0 + flutter_webrtc: ^0.12.5+hotfix.1 dev_dependencies: flutter_test: