Merge pull request #1506 from GetStream/fix/pana
This commit is contained in:
@@ -27,7 +27,7 @@ dependencies:
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^2.3.3
|
||||
dart_code_metrics: ^5.7.0
|
||||
dart_code_metrics: ^5.7.2
|
||||
freezed: ^2.3.2
|
||||
json_serializable: ^6.6.1
|
||||
mocktail: ^0.3.0
|
||||
|
||||
+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;
|
||||
|
||||
|
||||
@@ -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/
|
||||
@@ -54,7 +69,7 @@ flutter:
|
||||
uses-material-design: true
|
||||
|
||||
dev_dependencies:
|
||||
dart_code_metrics: ^5.7.0
|
||||
dart_code_metrics: ^5.7.2
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
golden_toolkit: ^0.15.0
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -21,7 +21,7 @@ dependencies:
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^2.3.3
|
||||
dart_code_metrics: ^5.7.0
|
||||
dart_code_metrics: ^5.7.2
|
||||
fake_async: ^1.2.0
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
@@ -17,6 +17,22 @@ dependencies:
|
||||
stream_chat_flutter: ^5.3.0
|
||||
|
||||
dev_dependencies:
|
||||
dart_code_metrics: ^4.16.0
|
||||
dart_code_metrics: ^5.7.2
|
||||
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
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
## Upcoming
|
||||
|
||||
- Updated `drift` to `^2.7.0`.
|
||||
- Updated dependencies to resolvable versions.
|
||||
|
||||
## 5.1.0
|
||||
|
||||
@@ -3,7 +3,6 @@ targets:
|
||||
builders:
|
||||
drift_dev:
|
||||
options:
|
||||
generate_connect_constructor: true
|
||||
data_class_to_companions: false
|
||||
apply_converters_on_variables: true
|
||||
generate_values_in_copy_with: true
|
||||
|
||||
@@ -6,7 +6,21 @@ import 'package:drift/drift.dart';
|
||||
/// by the sqlite backend.
|
||||
class ListConverter<T> extends TypeConverter<List<T>, String> {
|
||||
@override
|
||||
List<T>? mapToDart(String? fromDb) {
|
||||
List<T> fromSql(String fromDb) {
|
||||
return List<T>.from(jsonDecode(fromDb) ?? []);
|
||||
}
|
||||
|
||||
@override
|
||||
String toSql(List<T> value) {
|
||||
return jsonEncode(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps a nullable [List] of type [T] into a nullable [String] understood
|
||||
/// by the sqlite backend.
|
||||
class NullableListConverter<T> extends TypeConverter<List<T>?, String?> {
|
||||
@override
|
||||
List<T>? fromSql(String? fromDb) {
|
||||
if (fromDb == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -14,7 +28,7 @@ class ListConverter<T> extends TypeConverter<List<T>, String> {
|
||||
}
|
||||
|
||||
@override
|
||||
String? mapToSql(List<T>? value) {
|
||||
String? toSql(List<T>? value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,21 @@ import 'package:drift/drift.dart';
|
||||
/// by the sqlite backend.
|
||||
class MapConverter<T> extends TypeConverter<Map<String, T>, String> {
|
||||
@override
|
||||
Map<String, T>? mapToDart(String? fromDb) {
|
||||
Map<String, T> fromSql(String fromDb) {
|
||||
return Map<String, T>.from(jsonDecode(fromDb) ?? {});
|
||||
}
|
||||
|
||||
@override
|
||||
String toSql(Map<String, T> value) {
|
||||
return jsonEncode(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps a nullable [Map] of type [String], [T] into a nullable [String]
|
||||
/// understood by the sqlite backend.
|
||||
class NullableMapConverter<T> extends TypeConverter<Map<String, T>?, String?> {
|
||||
@override
|
||||
Map<String, T>? fromSql(String? fromDb) {
|
||||
if (fromDb == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -14,7 +28,7 @@ class MapConverter<T> extends TypeConverter<Map<String, T>, String> {
|
||||
}
|
||||
|
||||
@override
|
||||
String? mapToSql(Map<String, T>? value) {
|
||||
String? toSql(Map<String, T>? value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+3
-6
@@ -6,7 +6,7 @@ import 'package:stream_chat/stream_chat.dart';
|
||||
class MessageSendingStatusConverter
|
||||
extends TypeConverter<MessageSendingStatus, int> {
|
||||
@override
|
||||
MessageSendingStatus? mapToDart(int? fromDb) {
|
||||
MessageSendingStatus fromSql(int fromDb) {
|
||||
switch (fromDb) {
|
||||
case 0:
|
||||
return MessageSendingStatus.sending;
|
||||
@@ -22,13 +22,12 @@ class MessageSendingStatusConverter
|
||||
return MessageSendingStatus.deleting;
|
||||
case 6:
|
||||
return MessageSendingStatus.failed_delete;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return MessageSendingStatus.sending;
|
||||
}
|
||||
|
||||
@override
|
||||
int? mapToSql(MessageSendingStatus? value) {
|
||||
int toSql(MessageSendingStatus value) {
|
||||
switch (value) {
|
||||
case MessageSendingStatus.sending:
|
||||
return 0;
|
||||
@@ -44,8 +43,6 @@ class MessageSendingStatusConverter
|
||||
return 5;
|
||||
case MessageSendingStatus.failed_delete:
|
||||
return 6;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
|
||||
part of 'channel_dao.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// DaoGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$ChannelDaoMixin on DatabaseAccessor<DriftChatDatabase> {
|
||||
$ChannelsTable get channels => attachedDatabase.channels;
|
||||
$UsersTable get users => attachedDatabase.users;
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
|
||||
part of 'channel_query_dao.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// DaoGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$ChannelQueryDaoMixin on DatabaseAccessor<DriftChatDatabase> {
|
||||
$ChannelQueriesTable get channelQueries => attachedDatabase.channelQueries;
|
||||
$ChannelsTable get channels => attachedDatabase.channels;
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
|
||||
part of 'connection_event_dao.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// DaoGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$ConnectionEventDaoMixin on DatabaseAccessor<DriftChatDatabase> {
|
||||
$ConnectionEventsTable get connectionEvents =>
|
||||
attachedDatabase.connectionEvents;
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
part of 'member_dao.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// DaoGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$MemberDaoMixin on DatabaseAccessor<DriftChatDatabase> {
|
||||
$ChannelsTable get channels => attachedDatabase.channels;
|
||||
$MembersTable get members => attachedDatabase.members;
|
||||
$UsersTable get users => attachedDatabase.users;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
part of 'message_dao.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// DaoGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$MessageDaoMixin on DatabaseAccessor<DriftChatDatabase> {
|
||||
$ChannelsTable get channels => attachedDatabase.channels;
|
||||
$MessagesTable get messages => attachedDatabase.messages;
|
||||
$UsersTable get users => attachedDatabase.users;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
part of 'pinned_message_dao.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// DaoGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$PinnedMessageDaoMixin on DatabaseAccessor<DriftChatDatabase> {
|
||||
$ChannelsTable get channels => attachedDatabase.channels;
|
||||
$PinnedMessagesTable get pinnedMessages => attachedDatabase.pinnedMessages;
|
||||
$UsersTable get users => attachedDatabase.users;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
|
||||
part of 'pinned_message_reaction_dao.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// DaoGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$PinnedMessageReactionDaoMixin on DatabaseAccessor<DriftChatDatabase> {
|
||||
$ChannelsTable get channels => attachedDatabase.channels;
|
||||
$PinnedMessagesTable get pinnedMessages => attachedDatabase.pinnedMessages;
|
||||
$PinnedMessageReactionsTable get pinnedMessageReactions =>
|
||||
attachedDatabase.pinnedMessageReactions;
|
||||
$UsersTable get users => attachedDatabase.users;
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
|
||||
part of 'reaction_dao.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// DaoGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$ReactionDaoMixin on DatabaseAccessor<DriftChatDatabase> {
|
||||
$ChannelsTable get channels => attachedDatabase.channels;
|
||||
$MessagesTable get messages => attachedDatabase.messages;
|
||||
$ReactionsTable get reactions => attachedDatabase.reactions;
|
||||
$UsersTable get users => attachedDatabase.users;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
part of 'read_dao.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// DaoGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$ReadDaoMixin on DatabaseAccessor<DriftChatDatabase> {
|
||||
$ChannelsTable get channels => attachedDatabase.channels;
|
||||
$ReadsTable get reads => attachedDatabase.reads;
|
||||
$UsersTable get users => attachedDatabase.users;
|
||||
}
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
|
||||
part of 'user_dao.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// DaoGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// ignore_for_file: type=lint
|
||||
mixin _$UserDaoMixin on DatabaseAccessor<DriftChatDatabase> {
|
||||
$UsersTable get users => attachedDatabase.users;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:stream_chat/stream_chat.dart';
|
||||
|
||||
import 'package:stream_chat_persistence/src/converter/converter.dart';
|
||||
import 'package:stream_chat_persistence/src/dao/dao.dart';
|
||||
import 'package:stream_chat_persistence/src/entity/entity.dart';
|
||||
@@ -37,18 +36,12 @@ part 'drift_chat_database.g.dart';
|
||||
],
|
||||
)
|
||||
class DriftChatDatabase extends _$DriftChatDatabase {
|
||||
/// Creates a new moor chat database instance
|
||||
/// Creates a new drift chat database instance
|
||||
DriftChatDatabase(
|
||||
this._userId,
|
||||
QueryExecutor executor,
|
||||
) : super(executor);
|
||||
|
||||
/// Instantiate a new database instance
|
||||
DriftChatDatabase.connect(
|
||||
this._userId,
|
||||
DatabaseConnection connection,
|
||||
) : super.connect(connection);
|
||||
|
||||
final String _userId;
|
||||
|
||||
/// User id to which the database is connected
|
||||
@@ -56,7 +49,7 @@ class DriftChatDatabase extends _$DriftChatDatabase {
|
||||
|
||||
// you should bump this number whenever you change or add a table definition.
|
||||
@override
|
||||
int get schemaVersion => 9;
|
||||
int get schemaVersion => 10;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration => MigrationStrategy(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@ class SharedDB {
|
||||
}) async {
|
||||
final dbName = 'db_$userId';
|
||||
if (connectionMode == ConnectionMode.background) {
|
||||
return DriftChatDatabase.connect(
|
||||
return DriftChatDatabase(
|
||||
userId,
|
||||
DatabaseConnection.delayed(Future(() async {
|
||||
final isolate = await _createMoorIsolate(
|
||||
@@ -34,6 +34,7 @@ class SharedDB {
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
return DriftChatDatabase(
|
||||
userId,
|
||||
LazyDatabase(
|
||||
@@ -68,7 +69,7 @@ class SharedDB {
|
||||
logStatements: request.logStatements,
|
||||
));
|
||||
final moorIsolate = DriftIsolate.inCurrent(
|
||||
() => DatabaseConnection.fromExecutor(executor),
|
||||
() => DatabaseConnection(executor),
|
||||
);
|
||||
request.sendMoorIsolate.send(moorIsolate);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// coverage:ignore-file
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:stream_chat_persistence/src/entity/channels.dart';
|
||||
|
||||
/// Represents a [Members] table in [MoorChatDatabase].
|
||||
@DataClassName('MemberEntity')
|
||||
@@ -9,7 +10,7 @@ class Members extends Table {
|
||||
|
||||
/// The channel cid of which this user is part of
|
||||
TextColumn get channelCid =>
|
||||
text().customConstraint('REFERENCES channels(cid) ON DELETE CASCADE')();
|
||||
text().references(Channels, #cid, onDelete: KeyAction.cascade)();
|
||||
|
||||
/// The role of the user in the channel
|
||||
TextColumn get channelRole => text().nullable()();
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:drift/drift.dart';
|
||||
import 'package:stream_chat_persistence/src/converter/list_converter.dart';
|
||||
import 'package:stream_chat_persistence/src/converter/map_converter.dart';
|
||||
import 'package:stream_chat_persistence/src/converter/message_sending_status_converter.dart';
|
||||
import 'package:stream_chat_persistence/src/entity/channels.dart';
|
||||
|
||||
/// Represents a [Messages] table in [MoorChatDatabase].
|
||||
@DataClassName('MessageEntity')
|
||||
@@ -78,10 +79,11 @@ class Messages extends Table {
|
||||
|
||||
/// The channel cid of which this message is part of
|
||||
TextColumn get channelCid =>
|
||||
text().customConstraint('REFERENCES channels(cid) ON DELETE CASCADE')();
|
||||
text().references(Channels, #cid, onDelete: KeyAction.cascade)();
|
||||
|
||||
/// A Map of [messageText] translations.
|
||||
TextColumn get i18n => text().nullable().map(MapConverter<String>())();
|
||||
TextColumn get i18n =>
|
||||
text().nullable().map(NullableMapConverter<String>())();
|
||||
|
||||
/// Message custom extraData
|
||||
TextColumn get extraData => text().nullable().map(MapConverter<Object?>())();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// coverage:ignore-file
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
import 'package:stream_chat_persistence/src/entity/pinned_messages.dart';
|
||||
import 'package:stream_chat_persistence/src/entity/reactions.dart';
|
||||
|
||||
/// Represents a [PinnedMessageReactions] table in [MoorChatDatabase].
|
||||
@@ -8,6 +8,6 @@ import 'package:stream_chat_persistence/src/entity/reactions.dart';
|
||||
class PinnedMessageReactions extends Reactions {
|
||||
/// The messageId to which the reaction belongs
|
||||
@override
|
||||
TextColumn get messageId => text()
|
||||
.customConstraint('REFERENCES pinned_messages(id) ON DELETE CASCADE')();
|
||||
TextColumn get messageId =>
|
||||
text().references(PinnedMessages, #id, onDelete: KeyAction.cascade)();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// coverage:ignore-file
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
import 'package:stream_chat_persistence/src/entity/messages.dart';
|
||||
|
||||
/// Represents a [PinnedMessages] table in [MoorChatDatabase].
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// coverage:ignore-file
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:stream_chat_persistence/src/converter/map_converter.dart';
|
||||
import 'package:stream_chat_persistence/src/entity/messages.dart';
|
||||
|
||||
/// Represents a [Reactions] table in [MoorChatDatabase].
|
||||
@DataClassName('ReactionEntity')
|
||||
@@ -10,7 +11,7 @@ class Reactions extends Table {
|
||||
|
||||
/// The messageId to which the reaction belongs
|
||||
TextColumn get messageId =>
|
||||
text().customConstraint('REFERENCES messages(id) ON DELETE CASCADE')();
|
||||
text().references(Messages, #id, onDelete: KeyAction.cascade)();
|
||||
|
||||
/// The type of the reaction
|
||||
TextColumn get type => text()();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// coverage:ignore-file
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:stream_chat_persistence/src/entity/channels.dart';
|
||||
|
||||
/// Represents a [Reads] table in [MoorChatDatabase].
|
||||
@DataClassName('ReadEntity')
|
||||
@@ -12,7 +13,7 @@ class Reads extends Table {
|
||||
|
||||
/// The channel cid of which this read belongs
|
||||
TextColumn get channelCid =>
|
||||
text().customConstraint('REFERENCES channels(cid) ON DELETE CASCADE')();
|
||||
text().references(Channels, #cid, onDelete: KeyAction.cascade)();
|
||||
|
||||
/// Number of unread messages
|
||||
IntColumn get unreadMessages => integer().withDefault(const Constant(0))();
|
||||
|
||||
@@ -10,7 +10,7 @@ environment:
|
||||
flutter: ">=1.17.0"
|
||||
|
||||
dependencies:
|
||||
drift: ^1.7.1
|
||||
drift: ^2.7.0
|
||||
flutter:
|
||||
sdk: flutter
|
||||
logging: ^1.0.1
|
||||
@@ -23,8 +23,8 @@ dependencies:
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^2.3.3
|
||||
dart_code_metrics: ^4.18.0
|
||||
drift_dev: ^1.7.1
|
||||
dart_code_metrics: ^5.7.2
|
||||
drift_dev: ^2.7.0
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
mocktail: ^0.3.0
|
||||
|
||||
@@ -4,50 +4,91 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_persistence/src/converter/list_converter.dart';
|
||||
|
||||
void main() {
|
||||
group('mapToDart', () {
|
||||
group('ListConverter', () {
|
||||
final listConverter = ListConverter<String>();
|
||||
|
||||
test('should return null if nothing is provided', () {
|
||||
final res = listConverter.mapToDart(null);
|
||||
expect(res, isNull);
|
||||
});
|
||||
group('fromSql', () {
|
||||
test('should throw type error if the provided json is not a list', () {
|
||||
final json = {'test_key': 'testData'};
|
||||
expect(
|
||||
() => listConverter.fromSql(jsonEncode(json)),
|
||||
throwsA(isA<TypeError>()),
|
||||
);
|
||||
});
|
||||
|
||||
test('should throw type error if the provided json is not a list', () {
|
||||
final json = {'test_key': 'testData'};
|
||||
expect(
|
||||
() => listConverter.mapToDart(jsonEncode(json)),
|
||||
throwsA(isA<TypeError>()),
|
||||
);
|
||||
});
|
||||
|
||||
test('should throw type error if the provided json is not a list of String',
|
||||
test(
|
||||
'should throw type error if the provided json is not a list of String',
|
||||
() {
|
||||
final json = [22, 33, 44];
|
||||
expect(
|
||||
() => listConverter.mapToDart(jsonEncode(json)),
|
||||
throwsA(isA<TypeError>()),
|
||||
final json = [22, 33, 44];
|
||||
expect(
|
||||
() => listConverter.fromSql(jsonEncode(json)),
|
||||
throwsA(isA<TypeError>()),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test('should return list of String if json data list is provided', () {
|
||||
final data = ['data1', 'data2', 'data3'];
|
||||
final res = listConverter.fromSql(jsonEncode(data));
|
||||
expect(res.length, data.length);
|
||||
});
|
||||
});
|
||||
|
||||
test('should return list of String if json data list is provided', () {
|
||||
final data = ['data1', 'data2', 'data3'];
|
||||
final res = listConverter.mapToDart(jsonEncode(data));
|
||||
expect(res!.length, data.length);
|
||||
group('toSql', () {
|
||||
test('should return json string if data list is provided', () {
|
||||
final data = ['data1', 'data2', 'data3'];
|
||||
final res = listConverter.toSql(data);
|
||||
expect(res, jsonEncode(data));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
group('mapToSql', () {
|
||||
final listConverter = ListConverter<String>();
|
||||
group('NullableListConverter', () {
|
||||
final listConverter = NullableListConverter<String>();
|
||||
|
||||
test('should return null if nothing is provided', () {
|
||||
final res = listConverter.mapToSql(null);
|
||||
expect(res, isNull);
|
||||
group('fromSql', () {
|
||||
test('should return null if nothing is provided', () {
|
||||
final res = listConverter.fromSql(null);
|
||||
expect(res, isNull);
|
||||
});
|
||||
|
||||
test('should throw type error if the provided json is not a list', () {
|
||||
final json = {'test_key': 'testData'};
|
||||
expect(
|
||||
() => listConverter.fromSql(jsonEncode(json)),
|
||||
throwsA(isA<TypeError>()),
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'should throw type error if the provided json is not a list of String',
|
||||
() {
|
||||
final json = [22, 33, 44];
|
||||
expect(
|
||||
() => listConverter.fromSql(jsonEncode(json)),
|
||||
throwsA(isA<TypeError>()),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test('should return list of String if json data list is provided', () {
|
||||
final data = ['data1', 'data2', 'data3'];
|
||||
final res = listConverter.fromSql(jsonEncode(data));
|
||||
expect(res!.length, data.length);
|
||||
});
|
||||
});
|
||||
|
||||
test('should return json string if data list is provided', () {
|
||||
final data = ['data1', 'data2', 'data3'];
|
||||
final res = listConverter.mapToSql(data);
|
||||
expect(res, jsonEncode(data));
|
||||
group('toSql', () {
|
||||
test('should return null if nothing is provided', () {
|
||||
final res = listConverter.toSql(null);
|
||||
expect(res, isNull);
|
||||
});
|
||||
|
||||
test('should return json string if data list is provided', () {
|
||||
final data = ['data1', 'data2', 'data3'];
|
||||
final res = listConverter.toSql(data);
|
||||
expect(res, jsonEncode(data));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,61 +4,109 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_persistence/src/converter/map_converter.dart';
|
||||
|
||||
void main() {
|
||||
group('mapToDart', () {
|
||||
group('MapConverter', () {
|
||||
final mapConverter = MapConverter<String>();
|
||||
|
||||
test('should return null if nothing is provided', () {
|
||||
final res = mapConverter.mapToDart(null);
|
||||
expect(res, isNull);
|
||||
});
|
||||
|
||||
test('should throw type error if the provided json is not a map', () {
|
||||
const json = ['testData1', 'testData2', 'testData3'];
|
||||
expect(
|
||||
() => mapConverter.mapToDart(jsonEncode(json)),
|
||||
throwsA(isA<TypeError>()),
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'should throw type error if the provided json is not a '
|
||||
'map of String, String',
|
||||
() {
|
||||
const json = {'test_key': 22, 'test_key2': 33, 'test_key3': 44};
|
||||
group('fromSql', () {
|
||||
test('should throw type error if the provided json is not a map', () {
|
||||
const json = ['testData1', 'testData2', 'testData3'];
|
||||
expect(
|
||||
() => mapConverter.mapToDart(jsonEncode(json)),
|
||||
() => mapConverter.fromSql(jsonEncode(json)),
|
||||
throwsA(isA<TypeError>()),
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test('should return map of String, String if json data is provided', () {
|
||||
const data = {
|
||||
'test_key': 'testValue',
|
||||
'test_key2': 'testValue2',
|
||||
'test_key3': 'testValue3',
|
||||
};
|
||||
final res = mapConverter.mapToDart(jsonEncode(data));
|
||||
expect(res, data);
|
||||
test(
|
||||
'should throw type error if the provided json is not a '
|
||||
'map of String, String',
|
||||
() {
|
||||
const json = {'test_key': 22, 'test_key2': 33, 'test_key3': 44};
|
||||
expect(
|
||||
() => mapConverter.fromSql(jsonEncode(json)),
|
||||
throwsA(isA<TypeError>()),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test('should return map of String, String if json data is provided', () {
|
||||
const data = {
|
||||
'test_key': 'testValue',
|
||||
'test_key2': 'testValue2',
|
||||
'test_key3': 'testValue3',
|
||||
};
|
||||
final res = mapConverter.fromSql(jsonEncode(data));
|
||||
expect(res, data);
|
||||
});
|
||||
});
|
||||
|
||||
group('toSql', () {
|
||||
test('should return json string if data map is provided', () {
|
||||
const data = {
|
||||
'test_key': 'testValue',
|
||||
'test_key2': 'testValue2',
|
||||
'test_key3': 'testValue3',
|
||||
};
|
||||
final res = mapConverter.toSql(data);
|
||||
expect(res, jsonEncode(data));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
group('mapToSql', () {
|
||||
final mapConverter = MapConverter<String>();
|
||||
group('NullableMapConverter', () {
|
||||
final mapConverter = NullableMapConverter<String>();
|
||||
|
||||
test('should return null if nothing is provided', () {
|
||||
final res = mapConverter.mapToSql(null);
|
||||
expect(res, isNull);
|
||||
group('fromSql', () {
|
||||
test('should return null if nothing is provided', () {
|
||||
final res = mapConverter.fromSql(null);
|
||||
expect(res, isNull);
|
||||
});
|
||||
|
||||
test('should throw type error if the provided json is not a map', () {
|
||||
const json = ['testData1', 'testData2', 'testData3'];
|
||||
expect(
|
||||
() => mapConverter.fromSql(jsonEncode(json)),
|
||||
throwsA(isA<TypeError>()),
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'should throw type error if the provided json is not a '
|
||||
'map of String, String',
|
||||
() {
|
||||
const json = {'test_key': 22, 'test_key2': 33, 'test_key3': 44};
|
||||
expect(
|
||||
() => mapConverter.fromSql(jsonEncode(json)),
|
||||
throwsA(isA<TypeError>()),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test('should return map of String, String if json data is provided', () {
|
||||
const data = {
|
||||
'test_key': 'testValue',
|
||||
'test_key2': 'testValue2',
|
||||
'test_key3': 'testValue3',
|
||||
};
|
||||
final res = mapConverter.fromSql(jsonEncode(data));
|
||||
expect(res, data);
|
||||
});
|
||||
});
|
||||
|
||||
test('should return json string if data map is provided', () {
|
||||
const data = {
|
||||
'test_key': 'testValue',
|
||||
'test_key2': 'testValue2',
|
||||
'test_key3': 'testValue3',
|
||||
};
|
||||
final res = mapConverter.mapToSql(data);
|
||||
expect(res, jsonEncode(data));
|
||||
group('toSql', () {
|
||||
test('should return null if nothing is provided', () {
|
||||
final res = mapConverter.toSql(null);
|
||||
expect(res, isNull);
|
||||
});
|
||||
|
||||
test('should return json string if data map is provided', () {
|
||||
const data = {
|
||||
'test_key': 'testValue',
|
||||
'test_key2': 'testValue2',
|
||||
'test_key3': 'testValue3',
|
||||
};
|
||||
final res = mapConverter.toSql(data);
|
||||
expect(res, jsonEncode(data));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+6
-16
@@ -3,31 +3,21 @@ import 'package:stream_chat/stream_chat.dart';
|
||||
import 'package:stream_chat_persistence/src/converter/message_sending_status_converter.dart';
|
||||
|
||||
void main() {
|
||||
group('mapToDart', () {
|
||||
group('fromSql', () {
|
||||
final statusConverter = MessageSendingStatusConverter();
|
||||
|
||||
test('should return null if nothing is provided', () {
|
||||
final res = statusConverter.mapToDart(null);
|
||||
expect(res, isNull);
|
||||
});
|
||||
|
||||
test('should return expected status if status code is provided', () {
|
||||
final res = statusConverter.mapToDart(3);
|
||||
expect(res, MessageSendingStatus.updating);
|
||||
final res = statusConverter.fromSql(6);
|
||||
expect(res, MessageSendingStatus.failed_delete);
|
||||
});
|
||||
});
|
||||
|
||||
group('mapToSql', () {
|
||||
group('toSql', () {
|
||||
final statusConverter = MessageSendingStatusConverter();
|
||||
|
||||
test('should return null if nothing is provided', () {
|
||||
final res = statusConverter.mapToSql(null);
|
||||
expect(res, isNull);
|
||||
});
|
||||
|
||||
test('should return expected code if the status is provided', () {
|
||||
final res = statusConverter.mapToSql(MessageSendingStatus.updating);
|
||||
expect(res, 3);
|
||||
final res = statusConverter.toSql(MessageSendingStatus.failed_delete);
|
||||
expect(res, 6);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:stream_chat_persistence/src/db/drift_chat_database.dart';
|
||||
|
||||
DatabaseConnection _backgroundConnection() =>
|
||||
DatabaseConnection.fromExecutor(NativeDatabase.memory());
|
||||
DatabaseConnection(NativeDatabase.memory());
|
||||
|
||||
void main() {
|
||||
test(
|
||||
@@ -30,7 +30,7 @@ void main() {
|
||||
final isolate = await DriftIsolate.spawn(_backgroundConnection);
|
||||
final connection = DatabaseConnection.delayed(isolate.connect());
|
||||
|
||||
final database = DriftChatDatabase.connect(userId, connection);
|
||||
final database = DriftChatDatabase(userId, connection);
|
||||
expect(database, isNotNull);
|
||||
expect(database.userId, userId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user