+5
-8
@@ -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<RegistryWidget> {
|
||||
|
||||
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) {}
|
||||
|
||||
+12
-13
@@ -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<PositionedList> {
|
||||
: 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<PositionedList> {
|
||||
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<PositionedList> {
|
||||
: 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) {
|
||||
|
||||
+2
-3
@@ -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) {
|
||||
|
||||
@@ -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<Widget> slivers = const <Widget>[],
|
||||
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
|
||||
|
||||
+7
-10
@@ -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<ScrollablePositionedList>
|
||||
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<ScrollablePositionedList>
|
||||
.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),
|
||||
|
||||
@@ -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<Widget> slivers = const <Widget>[],
|
||||
}) : _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<RenderSliver>? 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;
|
||||
|
||||
|
||||
@@ -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/
|
||||
|
||||
@@ -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<int, Channel> {
|
||||
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<int, Channel> {
|
||||
_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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user