From 1c4fda8465c3f9b625bba1df2becf441f3fe1d15 Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 20 Apr 2023 17:18:59 +0530 Subject: [PATCH] fix pana checks Signed-off-by: xsahil03x --- .../src/element_registry.dart | 13 ++--- .../src/positioned_list.dart | 25 +++++----- .../src/post_mount_callback.dart | 5 +- .../src/scroll_view.dart | 37 +++++---------- .../src/scrollable_positioned_list.dart | 17 +++---- .../src/viewport.dart | 47 ++++++------------- packages/stream_chat_flutter/pubspec.yaml | 17 ++++++- .../src/stream_channel_list_controller.dart | 11 +++-- .../stream_chat_localizations/pubspec.yaml | 16 +++++++ 9 files changed, 91 insertions(+), 97 deletions(-) diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/element_registry.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/element_registry.dart index 218e2ca0..03f274f3 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/element_registry.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/element_registry.dart @@ -7,8 +7,7 @@ import 'package:flutter/widgets.dart'; /// A registry to track some [Element]s in the tree. class RegistryWidget extends StatefulWidget { /// Creates a [RegistryWidget]. - const RegistryWidget({Key? key, this.elementNotifier, required this.child}) - : super(key: key); + const RegistryWidget({super.key, this.elementNotifier, required this.child}); /// The widget below this widget in the tree. final Widget child; @@ -28,8 +27,7 @@ class RegistryWidget extends StatefulWidget { /// [RegistryWidget]. class RegisteredElementWidget extends ProxyWidget { /// Creates a [RegisteredElementWidget]. - const RegisteredElementWidget({Key? key, required Widget child}) - : super(key: key, child: child); + const RegisteredElementWidget({super.key, required super.child}); @override Element createElement() => _RegisteredElement(this); @@ -47,10 +45,9 @@ class _RegistryWidgetState extends State { class _InheritedRegistryWidget extends InheritedWidget { const _InheritedRegistryWidget({ - Key? key, required this.state, - required Widget child, - }) : super(key: key, child: child); + required super.child, + }); final _RegistryWidgetState state; @@ -59,7 +56,7 @@ class _InheritedRegistryWidget extends InheritedWidget { } class _RegisteredElement extends ProxyElement { - _RegisteredElement(ProxyWidget widget) : super(widget); + _RegisteredElement(super.widget); @override void notifyClients(ProxyWidget oldWidget) {} diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart index 0814ef9a..c62472ca 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/positioned_list.dart @@ -25,7 +25,7 @@ import 'package:stream_chat_flutter/scrollable_positioned_list/src/scroll_view.d class PositionedList extends StatefulWidget { /// Create a [PositionedList]. const PositionedList({ - Key? key, + super.key, required this.itemCount, required this.itemBuilder, this.separatorBuilder, @@ -44,9 +44,8 @@ class PositionedList extends StatefulWidget { this.addRepaintBoundaries = true, this.addAutomaticKeepAlives = true, this.keyboardDismissBehavior, - }) : assert((positionedIndex == 0) || (positionedIndex < itemCount), - 'positionedIndex cannot be 0 and must be smaller than itemCount'), - super(key: key); + }) : assert((positionedIndex == 0) || (positionedIndex < itemCount), + 'positionedIndex cannot be 0 and must be smaller than itemCount'); /// Called to find the new index of a child based on its key in case of /// reordering. @@ -272,7 +271,7 @@ class _PositionedListState extends State { : widget.reverse ? widget.padding?.copyWith(left: 0) : widget.padding?.copyWith(right: 0)) ?? - const EdgeInsets.all(0); + EdgeInsets.zero; EdgeInsets get _centerSliverPadding => widget.scrollDirection == Axis.vertical ? widget.reverse @@ -283,14 +282,14 @@ class _PositionedListState extends State { bottom: widget.positionedIndex == 0 ? widget.padding!.bottom : 0, ) ?? - const EdgeInsets.all(0) + EdgeInsets.zero : widget.padding?.copyWith( top: widget.positionedIndex == 0 ? widget.padding!.top : 0, bottom: widget.positionedIndex == widget.itemCount - 1 ? widget.padding!.bottom : 0, ) ?? - const EdgeInsets.all(0) + EdgeInsets.zero : widget.reverse ? widget.padding?.copyWith( left: widget.positionedIndex == widget.itemCount - 1 @@ -298,23 +297,23 @@ class _PositionedListState extends State { : 0, right: widget.positionedIndex == 0 ? widget.padding!.right : 0, ) ?? - const EdgeInsets.all(0) + EdgeInsets.zero : widget.padding?.copyWith( left: widget.positionedIndex == 0 ? widget.padding!.left : 0, right: widget.positionedIndex == widget.itemCount - 1 ? widget.padding!.right : 0, ) ?? - const EdgeInsets.all(0); + EdgeInsets.zero; EdgeInsets get _trailingSliverPadding => widget.scrollDirection == Axis.vertical ? widget.reverse - ? widget.padding?.copyWith(bottom: 0) ?? const EdgeInsets.all(0) - : widget.padding?.copyWith(top: 0) ?? const EdgeInsets.all(0) + ? widget.padding?.copyWith(bottom: 0) ?? EdgeInsets.zero + : widget.padding?.copyWith(top: 0) ?? EdgeInsets.zero : widget.reverse - ? widget.padding?.copyWith(right: 0) ?? const EdgeInsets.all(0) - : widget.padding?.copyWith(left: 0) ?? const EdgeInsets.all(0); + ? widget.padding?.copyWith(right: 0) ?? EdgeInsets.zero + : widget.padding?.copyWith(left: 0) ?? EdgeInsets.zero; void _schedulePositionNotificationUpdate() { if (!updateScheduled) { diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/post_mount_callback.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/post_mount_callback.dart index ddb3e3d4..c79c275e 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/post_mount_callback.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/post_mount_callback.dart @@ -7,8 +7,7 @@ import 'package:flutter/widgets.dart'; /// Widget whose [Element] calls a callback when the element is mounted. class PostMountCallback extends StatelessWidget { /// Creates a [PostMountCallback] widget. - const PostMountCallback({required this.child, this.callback, Key? key}) - : super(key: key); + const PostMountCallback({required this.child, this.callback, super.key}); /// The widget below this widget in the tree. final Widget child; @@ -24,7 +23,7 @@ class PostMountCallback extends StatelessWidget { } class _PostMountCallbackElement extends StatelessElement { - _PostMountCallbackElement(PostMountCallback widget) : super(widget); + _PostMountCallbackElement(PostMountCallback super.widget); @override void mount(Element? parent, dynamic newSlot) { diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart index 8aebfb23..13a7fdd3 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scroll_view.dart @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter/gestures.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; import 'package:stream_chat_flutter/scrollable_positioned_list/src/viewport.dart'; @@ -14,36 +13,24 @@ import 'package:stream_chat_flutter/scrollable_positioned_list/src/viewport.dart class UnboundedCustomScrollView extends CustomScrollView { /// {@macro custom_scroll_view} const UnboundedCustomScrollView({ - Key? key, - Axis scrollDirection = Axis.vertical, - bool reverse = false, - ScrollController? controller, - bool? primary, - ScrollPhysics? physics, - bool shrinkWrap = false, - Key? center, + super.key, + super.scrollDirection, + super.reverse, + super.controller, + super.primary, + super.physics, + super.shrinkWrap, + super.center, double anchor = 0.0, - double? cacheExtent, - List slivers = const [], - int? semanticChildCount, - DragStartBehavior dragStartBehavior = DragStartBehavior.start, + super.cacheExtent, + super.slivers, + super.semanticChildCount, + super.dragStartBehavior, ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior, }) : _anchor = anchor, super( - key: key, keyboardDismissBehavior: keyboardDismissBehavior ?? ScrollViewKeyboardDismissBehavior.manual, - scrollDirection: scrollDirection, - reverse: reverse, - controller: controller, - primary: primary, - physics: physics, - shrinkWrap: shrinkWrap, - center: center, - cacheExtent: cacheExtent, - semanticChildCount: semanticChildCount, - dragStartBehavior: dragStartBehavior, - slivers: slivers, ); // [CustomScrollView] enforces constraints on [CustomScrollView.anchor], so diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart index 72ebb659..5d307158 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/scrollable_positioned_list.dart @@ -35,7 +35,7 @@ class ScrollablePositionedList extends StatefulWidget { const ScrollablePositionedList.builder({ required this.itemCount, required this.itemBuilder, - Key? key, + super.key, this.itemScrollController, ItemPositionsListener? itemPositionsListener, this.initialScrollIndex = 0, @@ -52,16 +52,15 @@ class ScrollablePositionedList extends StatefulWidget { this.findChildIndexCallback, this.keyboardDismissBehavior, }) : itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?, - separatorBuilder = null, - super(key: key); + separatorBuilder = null; /// Create a [ScrollablePositionedList] whose items are provided by /// [itemBuilder] and separators provided by [separatorBuilder]. const ScrollablePositionedList.separated({ required this.itemCount, required this.itemBuilder, - required this.separatorBuilder, - Key? key, + required IndexedWidgetBuilder this.separatorBuilder, + super.key, this.itemScrollController, ItemPositionsListener? itemPositionsListener, this.initialScrollIndex = 0, @@ -77,9 +76,7 @@ class ScrollablePositionedList extends StatefulWidget { this.minCacheExtent, this.findChildIndexCallback, this.keyboardDismissBehavior, - }) : assert(separatorBuilder != null, 'seperatorBuilder cannot be null'), - itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?, - super(key: key); + }) : itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?; /// Called to find the new index of a child based on its key in case of /// reordering. @@ -280,7 +277,7 @@ class _ScrollablePositionedListState extends State void initState() { super.initState(); final ItemPosition? initialPosition = - PageStorage.of(context)!.readState(context); + PageStorage.of(context).readState(context); primary ..target = initialPosition?.index ?? widget.initialScrollIndex ..alignment = initialPosition?.itemLeadingEdge ?? widget.initialAlignment; @@ -572,7 +569,7 @@ class _ScrollablePositionedListState extends State .where((ItemPosition position) => position.itemLeadingEdge < 1 && position.itemTrailingEdge > 0); if (itemPositions.isNotEmpty) { - PageStorage.of(context)!.writeState( + PageStorage.of(context).writeState( context, itemPositions.reduce((value, element) => value.itemLeadingEdge < element.itemLeadingEdge ? value : element), diff --git a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/viewport.dart b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/viewport.dart index 01dce022..7d2d6b9f 100644 --- a/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/viewport.dart +++ b/packages/stream_chat_flutter/lib/scrollable_positioned_list/src/viewport.dart @@ -19,24 +19,15 @@ import 'package:flutter/widgets.dart'; class UnboundedViewport extends Viewport { /// {@macro unbounded_viewport} UnboundedViewport({ - Key? key, - AxisDirection axisDirection = AxisDirection.down, - AxisDirection? crossAxisDirection, + super.key, + super.axisDirection, + super.crossAxisDirection, double anchor = 0.0, - required ViewportOffset offset, - Key? center, - double? cacheExtent, - List slivers = const [], - }) : _anchor = anchor, - super( - key: key, - axisDirection: axisDirection, - crossAxisDirection: crossAxisDirection, - offset: offset, - center: center, - cacheExtent: cacheExtent, - slivers: slivers, - ); + required super.offset, + super.center, + super.cacheExtent, + super.slivers, + }) : _anchor = anchor; // [Viewport] enforces constraints on [Viewport.anchor], so we need our own // version. @@ -68,22 +59,14 @@ class UnboundedViewport extends Viewport { class UnboundedRenderViewport extends RenderViewport { /// Creates a viewport for [RenderSliver] objects. UnboundedRenderViewport({ - AxisDirection axisDirection = AxisDirection.down, - required AxisDirection crossAxisDirection, - required ViewportOffset offset, + super.axisDirection, + required super.crossAxisDirection, + required super.offset, double anchor = 0.0, - List? children, - RenderSliver? center, - double? cacheExtent, - }) : _anchor = anchor, - super( - axisDirection: axisDirection, - crossAxisDirection: crossAxisDirection, - offset: offset, - center: center, - cacheExtent: cacheExtent, - children: children, - ); + super.children, + super.center, + super.cacheExtent, + }) : _anchor = anchor; static const int _maxLayoutCycles = 10; diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index d67aa740..e740b068 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -28,7 +28,7 @@ dependencies: http_parser: ^4.0.0 image_gallery_saver: ^1.7.1 image_picker: ^0.8.2 - jiffy: ^5.0.0 + jiffy: ^6.1.0 lottie: ^2.0.0 meta: ^1.8.0 path_provider: ^2.0.9 @@ -46,6 +46,21 @@ dependencies: video_thumbnail: ^0.5.0 flutter: + plugin: + platforms: + android: + default_package: stream_chat_flutter + ios: + default_package: stream_chat_flutter + windows: + default_package: stream_chat_flutter + linux: + default_package: stream_chat_flutter + macos: + default_package: stream_chat_flutter + web: + default_package: stream_chat_flutter + assets: - images/ - svgs/ diff --git a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart index 71bc0694..7a729512 100644 --- a/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart +++ b/packages/stream_chat_flutter_core/lib/src/stream_channel_list_controller.dart @@ -3,7 +3,6 @@ import 'dart:math'; import 'package:stream_chat/stream_chat.dart' hide Success; import 'package:stream_chat_flutter_core/src/paged_value_notifier.dart'; - import 'package:stream_chat_flutter_core/src/stream_channel_list_event_handler.dart'; /// The default channel page limit to load. @@ -53,12 +52,12 @@ class StreamChannelListController extends PagedValueNotifier { this.limit = defaultChannelPagedLimit, this.messageLimit, this.memberLimit, - }) : _eventHandler = eventHandler ?? StreamChannelListEventHandler(), + }) + : _eventHandler = eventHandler ?? StreamChannelListEventHandler(), super(const PagedValue.loading()); /// Creates a [StreamChannelListController] from the passed [value]. - StreamChannelListController.fromValue( - super.value, { + StreamChannelListController.fromValue(super.value, { required this.client, StreamChannelListEventHandler? eventHandler, this.filter, @@ -247,8 +246,10 @@ class StreamChannelListController extends PagedValueNotifier { _channelEventSubscription = client .on() .skip(1) // Skipping the last emitted event. - // We only need to handle the latest events. + // We only need to handle the latest events. .listen((event) { + print('event: $event'); + // Only handle the event if the value is in success state. if (value.isNotSuccess) return; diff --git a/packages/stream_chat_localizations/pubspec.yaml b/packages/stream_chat_localizations/pubspec.yaml index 7462a287..f1ec0fe9 100644 --- a/packages/stream_chat_localizations/pubspec.yaml +++ b/packages/stream_chat_localizations/pubspec.yaml @@ -20,3 +20,19 @@ dev_dependencies: dart_code_metrics: ^4.16.0 flutter_test: sdk: flutter + +flutter: + plugin: + platforms: + android: + default_package: stream_chat_localizations + ios: + default_package: stream_chat_localizations + windows: + default_package: stream_chat_localizations + linux: + default_package: stream_chat_localizations + macos: + default_package: stream_chat_localizations + web: + default_package: stream_chat_localizations