fix pana checks

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2023-04-20 17:20:04 +05:30
committed by xsahil03x
parent 4341a377b6
commit 1c4fda8465
9 changed files with 91 additions and 97 deletions
@@ -7,8 +7,7 @@ import 'package:flutter/widgets.dart';
/// A registry to track some [Element]s in the tree. /// A registry to track some [Element]s in the tree.
class RegistryWidget extends StatefulWidget { class RegistryWidget extends StatefulWidget {
/// Creates a [RegistryWidget]. /// Creates a [RegistryWidget].
const RegistryWidget({Key? key, this.elementNotifier, required this.child}) const RegistryWidget({super.key, this.elementNotifier, required this.child});
: super(key: key);
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
final Widget child; final Widget child;
@@ -28,8 +27,7 @@ class RegistryWidget extends StatefulWidget {
/// [RegistryWidget]. /// [RegistryWidget].
class RegisteredElementWidget extends ProxyWidget { class RegisteredElementWidget extends ProxyWidget {
/// Creates a [RegisteredElementWidget]. /// Creates a [RegisteredElementWidget].
const RegisteredElementWidget({Key? key, required Widget child}) const RegisteredElementWidget({super.key, required super.child});
: super(key: key, child: child);
@override @override
Element createElement() => _RegisteredElement(this); Element createElement() => _RegisteredElement(this);
@@ -47,10 +45,9 @@ class _RegistryWidgetState extends State<RegistryWidget> {
class _InheritedRegistryWidget extends InheritedWidget { class _InheritedRegistryWidget extends InheritedWidget {
const _InheritedRegistryWidget({ const _InheritedRegistryWidget({
Key? key,
required this.state, required this.state,
required Widget child, required super.child,
}) : super(key: key, child: child); });
final _RegistryWidgetState state; final _RegistryWidgetState state;
@@ -59,7 +56,7 @@ class _InheritedRegistryWidget extends InheritedWidget {
} }
class _RegisteredElement extends ProxyElement { class _RegisteredElement extends ProxyElement {
_RegisteredElement(ProxyWidget widget) : super(widget); _RegisteredElement(super.widget);
@override @override
void notifyClients(ProxyWidget oldWidget) {} void notifyClients(ProxyWidget oldWidget) {}
@@ -25,7 +25,7 @@ import 'package:stream_chat_flutter/scrollable_positioned_list/src/scroll_view.d
class PositionedList extends StatefulWidget { class PositionedList extends StatefulWidget {
/// Create a [PositionedList]. /// Create a [PositionedList].
const PositionedList({ const PositionedList({
Key? key, super.key,
required this.itemCount, required this.itemCount,
required this.itemBuilder, required this.itemBuilder,
this.separatorBuilder, this.separatorBuilder,
@@ -44,9 +44,8 @@ class PositionedList extends StatefulWidget {
this.addRepaintBoundaries = true, this.addRepaintBoundaries = true,
this.addAutomaticKeepAlives = true, this.addAutomaticKeepAlives = true,
this.keyboardDismissBehavior, this.keyboardDismissBehavior,
}) : assert((positionedIndex == 0) || (positionedIndex < itemCount), }) : assert((positionedIndex == 0) || (positionedIndex < itemCount),
'positionedIndex cannot be 0 and must be smaller than itemCount'), 'positionedIndex cannot be 0 and must be smaller than itemCount');
super(key: key);
/// Called to find the new index of a child based on its key in case of /// Called to find the new index of a child based on its key in case of
/// reordering. /// reordering.
@@ -272,7 +271,7 @@ class _PositionedListState extends State<PositionedList> {
: widget.reverse : widget.reverse
? widget.padding?.copyWith(left: 0) ? widget.padding?.copyWith(left: 0)
: widget.padding?.copyWith(right: 0)) ?? : widget.padding?.copyWith(right: 0)) ??
const EdgeInsets.all(0); EdgeInsets.zero;
EdgeInsets get _centerSliverPadding => widget.scrollDirection == Axis.vertical EdgeInsets get _centerSliverPadding => widget.scrollDirection == Axis.vertical
? widget.reverse ? widget.reverse
@@ -283,14 +282,14 @@ class _PositionedListState extends State<PositionedList> {
bottom: bottom:
widget.positionedIndex == 0 ? widget.padding!.bottom : 0, widget.positionedIndex == 0 ? widget.padding!.bottom : 0,
) ?? ) ??
const EdgeInsets.all(0) EdgeInsets.zero
: widget.padding?.copyWith( : widget.padding?.copyWith(
top: widget.positionedIndex == 0 ? widget.padding!.top : 0, top: widget.positionedIndex == 0 ? widget.padding!.top : 0,
bottom: widget.positionedIndex == widget.itemCount - 1 bottom: widget.positionedIndex == widget.itemCount - 1
? widget.padding!.bottom ? widget.padding!.bottom
: 0, : 0,
) ?? ) ??
const EdgeInsets.all(0) EdgeInsets.zero
: widget.reverse : widget.reverse
? widget.padding?.copyWith( ? widget.padding?.copyWith(
left: widget.positionedIndex == widget.itemCount - 1 left: widget.positionedIndex == widget.itemCount - 1
@@ -298,23 +297,23 @@ class _PositionedListState extends State<PositionedList> {
: 0, : 0,
right: widget.positionedIndex == 0 ? widget.padding!.right : 0, right: widget.positionedIndex == 0 ? widget.padding!.right : 0,
) ?? ) ??
const EdgeInsets.all(0) EdgeInsets.zero
: widget.padding?.copyWith( : widget.padding?.copyWith(
left: widget.positionedIndex == 0 ? widget.padding!.left : 0, left: widget.positionedIndex == 0 ? widget.padding!.left : 0,
right: widget.positionedIndex == widget.itemCount - 1 right: widget.positionedIndex == widget.itemCount - 1
? widget.padding!.right ? widget.padding!.right
: 0, : 0,
) ?? ) ??
const EdgeInsets.all(0); EdgeInsets.zero;
EdgeInsets get _trailingSliverPadding => EdgeInsets get _trailingSliverPadding =>
widget.scrollDirection == Axis.vertical widget.scrollDirection == Axis.vertical
? widget.reverse ? widget.reverse
? widget.padding?.copyWith(bottom: 0) ?? const EdgeInsets.all(0) ? widget.padding?.copyWith(bottom: 0) ?? EdgeInsets.zero
: widget.padding?.copyWith(top: 0) ?? const EdgeInsets.all(0) : widget.padding?.copyWith(top: 0) ?? EdgeInsets.zero
: widget.reverse : widget.reverse
? widget.padding?.copyWith(right: 0) ?? const EdgeInsets.all(0) ? widget.padding?.copyWith(right: 0) ?? EdgeInsets.zero
: widget.padding?.copyWith(left: 0) ?? const EdgeInsets.all(0); : widget.padding?.copyWith(left: 0) ?? EdgeInsets.zero;
void _schedulePositionNotificationUpdate() { void _schedulePositionNotificationUpdate() {
if (!updateScheduled) { if (!updateScheduled) {
@@ -7,8 +7,7 @@ import 'package:flutter/widgets.dart';
/// Widget whose [Element] calls a callback when the element is mounted. /// Widget whose [Element] calls a callback when the element is mounted.
class PostMountCallback extends StatelessWidget { class PostMountCallback extends StatelessWidget {
/// Creates a [PostMountCallback] widget. /// Creates a [PostMountCallback] widget.
const PostMountCallback({required this.child, this.callback, Key? key}) const PostMountCallback({required this.child, this.callback, super.key});
: super(key: key);
/// The widget below this widget in the tree. /// The widget below this widget in the tree.
final Widget child; final Widget child;
@@ -24,7 +23,7 @@ class PostMountCallback extends StatelessWidget {
} }
class _PostMountCallbackElement extends StatelessElement { class _PostMountCallbackElement extends StatelessElement {
_PostMountCallbackElement(PostMountCallback widget) : super(widget); _PostMountCallbackElement(PostMountCallback super.widget);
@override @override
void mount(Element? parent, dynamic newSlot) { void mount(Element? parent, dynamic newSlot) {
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:stream_chat_flutter/scrollable_positioned_list/src/viewport.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 { class UnboundedCustomScrollView extends CustomScrollView {
/// {@macro custom_scroll_view} /// {@macro custom_scroll_view}
const UnboundedCustomScrollView({ const UnboundedCustomScrollView({
Key? key, super.key,
Axis scrollDirection = Axis.vertical, super.scrollDirection,
bool reverse = false, super.reverse,
ScrollController? controller, super.controller,
bool? primary, super.primary,
ScrollPhysics? physics, super.physics,
bool shrinkWrap = false, super.shrinkWrap,
Key? center, super.center,
double anchor = 0.0, double anchor = 0.0,
double? cacheExtent, super.cacheExtent,
List<Widget> slivers = const <Widget>[], super.slivers,
int? semanticChildCount, super.semanticChildCount,
DragStartBehavior dragStartBehavior = DragStartBehavior.start, super.dragStartBehavior,
ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior, ScrollViewKeyboardDismissBehavior? keyboardDismissBehavior,
}) : _anchor = anchor, }) : _anchor = anchor,
super( super(
key: key,
keyboardDismissBehavior: keyboardDismissBehavior ?? keyboardDismissBehavior: keyboardDismissBehavior ??
ScrollViewKeyboardDismissBehavior.manual, 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 // [CustomScrollView] enforces constraints on [CustomScrollView.anchor], so
@@ -35,7 +35,7 @@ class ScrollablePositionedList extends StatefulWidget {
const ScrollablePositionedList.builder({ const ScrollablePositionedList.builder({
required this.itemCount, required this.itemCount,
required this.itemBuilder, required this.itemBuilder,
Key? key, super.key,
this.itemScrollController, this.itemScrollController,
ItemPositionsListener? itemPositionsListener, ItemPositionsListener? itemPositionsListener,
this.initialScrollIndex = 0, this.initialScrollIndex = 0,
@@ -52,16 +52,15 @@ class ScrollablePositionedList extends StatefulWidget {
this.findChildIndexCallback, this.findChildIndexCallback,
this.keyboardDismissBehavior, this.keyboardDismissBehavior,
}) : itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?, }) : itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?,
separatorBuilder = null, separatorBuilder = null;
super(key: key);
/// Create a [ScrollablePositionedList] whose items are provided by /// Create a [ScrollablePositionedList] whose items are provided by
/// [itemBuilder] and separators provided by [separatorBuilder]. /// [itemBuilder] and separators provided by [separatorBuilder].
const ScrollablePositionedList.separated({ const ScrollablePositionedList.separated({
required this.itemCount, required this.itemCount,
required this.itemBuilder, required this.itemBuilder,
required this.separatorBuilder, required IndexedWidgetBuilder this.separatorBuilder,
Key? key, super.key,
this.itemScrollController, this.itemScrollController,
ItemPositionsListener? itemPositionsListener, ItemPositionsListener? itemPositionsListener,
this.initialScrollIndex = 0, this.initialScrollIndex = 0,
@@ -77,9 +76,7 @@ class ScrollablePositionedList extends StatefulWidget {
this.minCacheExtent, this.minCacheExtent,
this.findChildIndexCallback, this.findChildIndexCallback,
this.keyboardDismissBehavior, this.keyboardDismissBehavior,
}) : assert(separatorBuilder != null, 'seperatorBuilder cannot be null'), }) : itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?;
itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?,
super(key: key);
/// Called to find the new index of a child based on its key in case of /// Called to find the new index of a child based on its key in case of
/// reordering. /// reordering.
@@ -280,7 +277,7 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
void initState() { void initState() {
super.initState(); super.initState();
final ItemPosition? initialPosition = final ItemPosition? initialPosition =
PageStorage.of(context)!.readState(context); PageStorage.of(context).readState(context);
primary primary
..target = initialPosition?.index ?? widget.initialScrollIndex ..target = initialPosition?.index ?? widget.initialScrollIndex
..alignment = initialPosition?.itemLeadingEdge ?? widget.initialAlignment; ..alignment = initialPosition?.itemLeadingEdge ?? widget.initialAlignment;
@@ -572,7 +569,7 @@ class _ScrollablePositionedListState extends State<ScrollablePositionedList>
.where((ItemPosition position) => .where((ItemPosition position) =>
position.itemLeadingEdge < 1 && position.itemTrailingEdge > 0); position.itemLeadingEdge < 1 && position.itemTrailingEdge > 0);
if (itemPositions.isNotEmpty) { if (itemPositions.isNotEmpty) {
PageStorage.of(context)!.writeState( PageStorage.of(context).writeState(
context, context,
itemPositions.reduce((value, element) => itemPositions.reduce((value, element) =>
value.itemLeadingEdge < element.itemLeadingEdge ? value : element), value.itemLeadingEdge < element.itemLeadingEdge ? value : element),
@@ -19,24 +19,15 @@ import 'package:flutter/widgets.dart';
class UnboundedViewport extends Viewport { class UnboundedViewport extends Viewport {
/// {@macro unbounded_viewport} /// {@macro unbounded_viewport}
UnboundedViewport({ UnboundedViewport({
Key? key, super.key,
AxisDirection axisDirection = AxisDirection.down, super.axisDirection,
AxisDirection? crossAxisDirection, super.crossAxisDirection,
double anchor = 0.0, double anchor = 0.0,
required ViewportOffset offset, required super.offset,
Key? center, super.center,
double? cacheExtent, super.cacheExtent,
List<Widget> slivers = const <Widget>[], super.slivers,
}) : _anchor = anchor, }) : _anchor = anchor;
super(
key: key,
axisDirection: axisDirection,
crossAxisDirection: crossAxisDirection,
offset: offset,
center: center,
cacheExtent: cacheExtent,
slivers: slivers,
);
// [Viewport] enforces constraints on [Viewport.anchor], so we need our own // [Viewport] enforces constraints on [Viewport.anchor], so we need our own
// version. // version.
@@ -68,22 +59,14 @@ class UnboundedViewport extends Viewport {
class UnboundedRenderViewport extends RenderViewport { class UnboundedRenderViewport extends RenderViewport {
/// Creates a viewport for [RenderSliver] objects. /// Creates a viewport for [RenderSliver] objects.
UnboundedRenderViewport({ UnboundedRenderViewport({
AxisDirection axisDirection = AxisDirection.down, super.axisDirection,
required AxisDirection crossAxisDirection, required super.crossAxisDirection,
required ViewportOffset offset, required super.offset,
double anchor = 0.0, double anchor = 0.0,
List<RenderSliver>? children, super.children,
RenderSliver? center, super.center,
double? cacheExtent, super.cacheExtent,
}) : _anchor = anchor, }) : _anchor = anchor;
super(
axisDirection: axisDirection,
crossAxisDirection: crossAxisDirection,
offset: offset,
center: center,
cacheExtent: cacheExtent,
children: children,
);
static const int _maxLayoutCycles = 10; static const int _maxLayoutCycles = 10;
+16 -1
View File
@@ -28,7 +28,7 @@ dependencies:
http_parser: ^4.0.0 http_parser: ^4.0.0
image_gallery_saver: ^1.7.1 image_gallery_saver: ^1.7.1
image_picker: ^0.8.2 image_picker: ^0.8.2
jiffy: ^5.0.0 jiffy: ^6.1.0
lottie: ^2.0.0 lottie: ^2.0.0
meta: ^1.8.0 meta: ^1.8.0
path_provider: ^2.0.9 path_provider: ^2.0.9
@@ -46,6 +46,21 @@ dependencies:
video_thumbnail: ^0.5.0 video_thumbnail: ^0.5.0
flutter: 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: assets:
- images/ - images/
- svgs/ - svgs/
@@ -3,7 +3,6 @@ import 'dart:math';
import 'package:stream_chat/stream_chat.dart' hide Success; 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/paged_value_notifier.dart';
import 'package:stream_chat_flutter_core/src/stream_channel_list_event_handler.dart'; import 'package:stream_chat_flutter_core/src/stream_channel_list_event_handler.dart';
/// The default channel page limit to load. /// The default channel page limit to load.
@@ -53,12 +52,12 @@ class StreamChannelListController extends PagedValueNotifier<int, Channel> {
this.limit = defaultChannelPagedLimit, this.limit = defaultChannelPagedLimit,
this.messageLimit, this.messageLimit,
this.memberLimit, this.memberLimit,
}) : _eventHandler = eventHandler ?? StreamChannelListEventHandler(), })
: _eventHandler = eventHandler ?? StreamChannelListEventHandler(),
super(const PagedValue.loading()); super(const PagedValue.loading());
/// Creates a [StreamChannelListController] from the passed [value]. /// Creates a [StreamChannelListController] from the passed [value].
StreamChannelListController.fromValue( StreamChannelListController.fromValue(super.value, {
super.value, {
required this.client, required this.client,
StreamChannelListEventHandler? eventHandler, StreamChannelListEventHandler? eventHandler,
this.filter, this.filter,
@@ -247,8 +246,10 @@ class StreamChannelListController extends PagedValueNotifier<int, Channel> {
_channelEventSubscription = client _channelEventSubscription = client
.on() .on()
.skip(1) // Skipping the last emitted event. .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) { .listen((event) {
print('event: $event');
// Only handle the event if the value is in success state. // Only handle the event if the value is in success state.
if (value.isNotSuccess) return; if (value.isNotSuccess) return;
@@ -20,3 +20,19 @@ dev_dependencies:
dart_code_metrics: ^4.16.0 dart_code_metrics: ^4.16.0
flutter_test: flutter_test:
sdk: flutter 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