Skip to content

Commit

Permalink
Fixed Dart SDK version for Flutter 3.22.x (#9) and Updated dependenci…
Browse files Browse the repository at this point in the history
…es (#12)
  • Loading branch information
rickypid authored Oct 26, 2024
1 parent 0bdfa89 commit 4b5d150
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 119 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## [1.0.1] - 2024-08-30
## [1.1.0] - 2024-08-30
#### [@danbeech](https://github.com/danbeech)
#### [@rickypid](https://github.com/rickypid)

### Fixed

* Fixed update room call
* Fixed Dart SDK version for Flutter 3.22.x (#9)
* Updated dependencies

## [1.0.0] - 2024-06-19
#### [@rickypid](https://github.com/rickypid)
Expand Down
26 changes: 1 addition & 25 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
analyzer:
plugins:
- dart_code_metrics

include: package:flutter_lints/flutter.yaml

linter:
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
- always_declare_return_types
- avoid_unused_constructor_parameters
- directives_ordering
Expand All @@ -24,23 +18,5 @@ linter:
- unawaited_futures
- use_named_constants
- use_super_parameters
- require_trailing_commas

dart_code_metrics:
rules:
- always-remove-listener
- avoid-unused-parameters
- format-comment
- member-ordering:
alphabetize: false
order:
- constructors
- public-fields
- public-getters
- public-setters
- private-fields
- private-getters
- private-setters
- public-methods
- private-methods
- no-boolean-literal-compare
- prefer-trailing-comma
28 changes: 1 addition & 27 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
analyzer:
plugins:
- dart_code_metrics

include: package:flutter_lints/flutter.yaml

linter:
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
- always_declare_return_types
- avoid_unused_constructor_parameters
- directives_ordering
Expand All @@ -24,25 +18,5 @@ linter:
- unawaited_futures
- use_named_constants
- use_super_parameters
- require_trailing_commas

dart_code_metrics:
rules-exclude:
- lib/firebase_options.dart
rules:
- always-remove-listener
- avoid-unused-parameters
- format-comment
- member-ordering:
alphabetize: false
order:
- constructors
- public-fields
- public-getters
- public-setters
- private-fields
- private-getters
- private-setters
- public-methods
- private-methods
- no-boolean-literal-compare
- prefer-trailing-comma
26 changes: 15 additions & 11 deletions example/lib/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,12 @@ class _ChatPageState extends State<ChatPage> {
final bytes = result.files.single.bytes;
final name = result.files.single.name;
final mimeType = lookupMimeType(name, headerBytes: bytes);
final reference = await Supabase.instance.client.storage
.from(buket)
.uploadBinary(
'${widget.room.id}/${const Uuid().v1()}-$name', bytes!,
fileOptions: FileOptions(contentType: mimeType));
final reference =
await Supabase.instance.client.storage.from(buket).uploadBinary(
'${widget.room.id}/${const Uuid().v1()}-$name',
bytes!,
fileOptions: FileOptions(contentType: mimeType),
);
final url =
'${Supabase.instance.client.storage.url}/object/authenticated/$reference';
final message = types.PartialFile(
Expand Down Expand Up @@ -127,10 +128,12 @@ class _ChatPageState extends State<ChatPage> {
final name = result.name;
final mimeType = lookupMimeType(name, headerBytes: bytes);
try {
final reference = await Supabase.instance.client.storage
.from(buket)
.uploadBinary('${widget.room.id}/${const Uuid().v1()}-$name', bytes,
fileOptions: FileOptions(contentType: mimeType));
final reference =
await Supabase.instance.client.storage.from(buket).uploadBinary(
'${widget.room.id}/${const Uuid().v1()}-$name',
bytes,
fileOptions: FileOptions(contentType: mimeType),
);
final url =
'${Supabase.instance.client.storage.url}/object/authenticated/$reference';
final message = types.PartialImage(
Expand Down Expand Up @@ -219,8 +222,9 @@ class _ChatPageState extends State<ChatPage> {
message.author.id !=
SupabaseChatCore.instance.supabaseUser!.id) {
await SupabaseChatCore.instance.updateMessage(
message.copyWith(status: types.Status.seen),
widget.room.id);
message.copyWith(status: types.Status.seen),
widget.room.id,
);
}
},
onEndReached: _chatController.loadPreviousMessages,
Expand Down
3 changes: 2 additions & 1 deletion example/lib/rooms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ class _RoomsPageState extends State<RoomsPage> {
leading: _buildAvatar(room),
title: Text(room.name ?? ''),
subtitle: Text(
'${timeago.format(DateTime.now().subtract(Duration(milliseconds: DateTime.now().millisecondsSinceEpoch - (room.updatedAt ?? 0))), locale: 'en_short')} ${room.lastMessages != null && room.lastMessages!.isNotEmpty && room.lastMessages!.first is types.TextMessage ? (room.lastMessages!.first as types.TextMessage).text : ''}'),
'${timeago.format(DateTime.now().subtract(Duration(milliseconds: DateTime.now().millisecondsSinceEpoch - (room.updatedAt ?? 0))), locale: 'en_short')} ${room.lastMessages != null && room.lastMessages!.isNotEmpty && room.lastMessages!.first is types.TextMessage ? (room.lastMessages!.first as types.TextMessage).text : ''}',
),
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
Expand Down
34 changes: 17 additions & 17 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@ name: example
description: A new Flutter project.
publish_to: 'none'

version: 1.0.0+1
version: 1.1.0

environment:
sdk: '>=3.4.1 <4.0.0'
sdk: '>=3.4.0 <4.0.0'

dependencies:
cupertino_icons: ^1.0.6
dio: ^5.4.2+1
faker: ^2.1.0
file_picker: ^8.0.0+1
file_saver: ^0.2.12
cupertino_icons: ^1.0.8
dio: ^5.7.0
faker: ^2.2.0
file_picker: ^8.1.3
file_saver: ^0.2.14
flutter:
sdk: flutter
flutter_chat_types: ^3.6.2
flutter_chat_ui: ^1.6.12
flutter_chat_ui: ^1.6.15
flutter_login: ^5.0.0
flutter_supabase_chat_core:
path: ../
flutter_svg: ^2.0.10+1
http: ^1.2.1
image_picker: ^1.0.7
mime: ^1.0.5
open_filex: ^4.4.0
path_provider: ^2.1.2
supabase_flutter: ^2.4.0
timeago: ^3.6.1
uuid: ^4.3.3
http: ^1.2.2
image_picker: ^1.1.2
mime: ^1.0.6
open_filex: ^4.5.0
path_provider: ^2.1.4
supabase_flutter: ^2.8.0
timeago: ^3.7.0
uuid: ^4.5.1

dev_dependencies:
flutter_lints: ^3.0.2
flutter_lints: ^5.0.0
flutter_test:
sdk: flutter

Expand Down
2 changes: 1 addition & 1 deletion lib/flutter_supabase_chat_core.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library flutter_supabase_chat_core;
library;

export 'src/class/supabase_chat_controller.dart';
export 'src/class/supabase_chat_core.dart';
Expand Down
19 changes: 10 additions & 9 deletions lib/src/class/supabase_chat_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@ class SupabaseChatController {
client
.channel('${config.schema}:${config.messagesTableName}:${_room.id}')
.onPostgresChanges(
event: PostgresChangeEvent.all,
schema: config.schema,
table: config.messagesTableName,
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.eq,
column: 'roomId',
value: _room.id,
),
callback: (payload) => _onData([payload.newRecord]))
event: PostgresChangeEvent.all,
schema: config.schema,
table: config.messagesTableName,
filter: PostgresChangeFilter(
type: PostgresChangeFilterType.eq,
column: 'roomId',
value: _room.id,
),
callback: (payload) => _onData([payload.newRecord]),
)
.subscribe();
return _controller.stream;
}
Expand Down
37 changes: 22 additions & 15 deletions lib/src/class/supabase_chat_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,11 @@ class SupabaseChatCore {
client
.channel('${config.schema}:${config.roomsTableName}')
.onPostgresChanges(
event: PostgresChangeEvent.all,
schema: config.schema,
table: config.roomsTableName,
callback: (payload) => onData([payload.newRecord]))
event: PostgresChangeEvent.all,
schema: config.schema,
table: config.roomsTableName,
callback: (payload) => onData([payload.newRecord]),
)
.subscribe();
return controller.stream;
}
Expand Down Expand Up @@ -417,7 +418,9 @@ class SupabaseChatCore {
.schema(config.schema)
.from(config.roomsTableName)
.update({'updatedAt': DateTime.now().millisecondsSinceEpoch}).eq(
'id', roomId);
'id',
roomId,
);
}
}

Expand Down Expand Up @@ -448,11 +451,13 @@ class SupabaseChatCore {
if (supabaseUser == null) return;

final roomMap = room.toJson();
roomMap.removeWhere((key, value) =>
key == 'createdAt' ||
key == 'id' ||
key == 'lastMessages' ||
key == 'users');
roomMap.removeWhere(
(key, value) =>
key == 'createdAt' ||
key == 'id' ||
key == 'lastMessages' ||
key == 'users',
);

if (room.type == types.RoomType.direct) {
roomMap['imageUrl'] = null;
Expand All @@ -462,11 +467,13 @@ class SupabaseChatCore {
roomMap['lastMessages'] = room.lastMessages?.map((m) {
final messageMap = m.toJson();

messageMap.removeWhere((key, value) =>
key == 'author' ||
key == 'createdAt' ||
key == 'id' ||
key == 'updatedAt');
messageMap.removeWhere(
(key, value) =>
key == 'author' ||
key == 'createdAt' ||
key == 'id' ||
key == 'updatedAt',
);

messageMap['authorId'] = m.author.id;

Expand Down
18 changes: 10 additions & 8 deletions lib/src/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ Future<List<types.Room>> processRoomsRows(
String usersCollectionName,
String schema,
) async =>
await Future.wait(rows.map(
(doc) => processRoomRow(
doc,
supabaseUser,
instance,
usersCollectionName,
schema,
await Future.wait(
rows.map(
(doc) => processRoomRow(
doc,
supabaseUser,
instance,
usersCollectionName,
schema,
),
),
));
);

/// Returns a [types.Room] created from Firebase document.
Future<types.Room> processRoomRow(
Expand Down
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ name: flutter_supabase_chat_core
description: >
Actively maintained, community-driven Supabase BaaS for chat applications
with an optional chat UI.
version: 1.0.0
version: 1.1.0
homepage: https://flutter-supabase-chat-core.insideapp.it
repository: https://github.com/insideapp-srl/flutter_supabase_chat_core

environment:
sdk: '>=3.4.1 <4.0.0'
sdk: '>=3.4.0 <4.0.0'
flutter: '>=3.22.0'

dependencies:
flutter:
sdk: flutter
flutter_chat_types: ^3.6.2
meta: ^1.11.0
supabase_flutter: ^2.4.0
supabase_flutter: ^2.8.0

dev_dependencies:
flutter_lints: ^3.0.2
flutter_lints: ^5.0.0
flutter_test:
sdk: flutter

0 comments on commit 4b5d150

Please sign in to comment.