chore: apply linter to the various example and test directories (#550)

* chore: remove examples and tests from analysis exclusion

* chore: apply linter fixes to stream_chat_flutter_core/example/main.dart

* chore: apply linter fixes to stream_chat_flutter/example/main.dart

* chore: apply linter fixes to stream_chat_persistence/example/main.dart

* chore: apply linter fixes to stream_chat/example/main.dart

* chore: apply linter fixes to stream_chat_flutter/example/split_view.dart

* chore: renamte tutorial files per linter

* chore: apply linter fixes to tutorial_part_1.dart

* chore: apply linter fixes to tutorial_part_2.dart

* chore: apply linter fixes to tutorial_part_3.dart

* chore: apply linter fixes to tutorial_part_4.dart

* chore: apply linter fixes to tutorial_part_5.dart

* chore: make a widget const in tutorial_part_5.dart

* chore: apply linter fixes to tutorial_part_6.dart

* chore: sort and update dependencies in stream_chat_persistence/example/pubspec.yaml

* chore: sort and update dependencies in stream_chat_flutter_core/example/pubspec.yaml

* chore: sort and update dependencies in stream_chat_flutter/example/pubspec.yaml

* chore: sort dependencies in stream_chat_flutter/example/pubspec.yaml

* chore: apply linter fixes to channel_test.dart

* chore: apply linter fixes to client_test.dart

* chore: apply linter fixes to client_test.dart, stream_http_client_test.dart, and token_manager_test.dart

* chore: apply linter fixes to filter_test.dart

* chore: apply linter fixes to reaction_test.dart

* chore: apply linter fixes to chat_persistence_client_test.dart

* chore: apply linter fixes to channel_image_test.dart

* chore: apply linter fixes to deleted_message_test.dart

* chore: apply linter fixes to full_screen_media_test.dart

* chore: apply linter fixes to gallery_footer_theme_test.dart

* chore: apply linter fixes to gallery_header_theme_test.dart

* chore: apply linter fixes to message_text_test.dart

* chore: apply linter fixes to reaction_bubble_test.dart

* chore: apply linter fixes to system_message_test.dart

* chore: apply linter fixes to typing_indicator_test.dart

* chore: apply linter fixes to channel_list_core_test.dart

* chore: apply linter fixes to channels_bloc_test.dart

* chore: apply linter fixes to lazy_load_scroll_view_test.dart

* chore: apply linter fixes to channel_matcher.dart

* chore: apply linter fixes to message_matcher.dart

* chore: apply linter fixes to users_matcher.dart

* chore: apply linter fixes to message_list_core_test.dart

* chore: apply linter fixes to message_search_bloc_test.dart

* chore: apply linter fixes to message_search_list_core_test.dart

* chore: apply linter fixes to stream_channel_test.dart

* chore: apply linter fixes to stream_chat_core_test.dart

* chore: apply linter fixes to user_list_core_test.dart

* chore: apply linter fixes to channel_query_dao_test.dart, message_mapper_test.dart, user_mapper_test.dart, and users_bloc_test.dart

* chore: apply some missed dartfmt

* test: regenerate failinggolden test
This commit is contained in:
Reuben Turner
2021-07-16 10:49:51 +02:00
committed by GitHub
parent 485e077596
commit b306978da6
48 changed files with 1172 additions and 1060 deletions
@@ -3,8 +3,8 @@ import 'package:stream_chat/stream_chat.dart';
import 'package:stream_chat_persistence/stream_chat_persistence.dart';
Future<void> main() async {
/// Create a new instance of [StreamChatClient] passing the apikey obtained from your
/// project dashboard.
/// Create a new instance of [StreamChatClient] passing the apikey obtained
/// from your project dashboard.
final client = StreamChatClient('b67pax5b2wdq');
WidgetsFlutterBinding.ensureInitialized();
@@ -22,12 +22,13 @@ Future<void> main() async {
await client.connectUser(
User(
id: 'cool-shadow-7',
extraData: {
extraData: const {
'image':
'https://getstream.io/random_png/?id=cool-shadow-7&amp;name=Cool+shadow',
},
),
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiY29vbC1zaGFkb3ctNyJ9.gkOlCRb1qgy4joHPaxFwPOdXcGvSPvp6QY0S4mpRkVo',
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiY29vbC1zaGFkb3ctNyJ9.'
'gkOlCRb1qgy4joHPaxFwPOdXcGvSPvp6QY0S4mpRkVo',
);
/// Creates a channel using the type `messaging` and `godevs`.
@@ -66,12 +67,10 @@ class StreamExample extends StatelessWidget {
final Channel channel;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Stream Chat Dart Example',
home: HomeScreen(channel: channel),
);
}
Widget build(BuildContext context) => MaterialApp(
title: 'Stream Chat Dart Example',
home: HomeScreen(channel: channel),
);
}
/// Main screen of our application. The layout is comprised of an [AppBar]
@@ -176,83 +175,81 @@ class _MessageViewState extends State<MessageView> {
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Expanded(
child: ListView.builder(
controller: _scrollController,
itemCount: _messages.length,
reverse: true,
itemBuilder: (BuildContext context, int index) {
final item = _messages[index];
if (item.user?.id == widget.channel.client.uid) {
return Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(8),
child: Text(item.text ?? ''),
),
);
} else {
return Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.all(8),
child: Text(item.text ?? ''),
),
);
}
},
Widget build(BuildContext context) => Column(
children: [
Expanded(
child: ListView.builder(
controller: _scrollController,
itemCount: _messages.length,
reverse: true,
itemBuilder: (BuildContext context, int index) {
final item = _messages[index];
if (item.user?.id == widget.channel.client.uid) {
return Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(8),
child: Text(item.text ?? ''),
),
);
} else {
return Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.all(8),
child: Text(item.text ?? ''),
),
);
}
},
),
),
),
Padding(
padding: const EdgeInsets.all(8),
child: Row(
children: [
Expanded(
child: TextField(
controller: _controller,
decoration: const InputDecoration(
hintText: 'Enter your message',
),
),
),
Material(
type: MaterialType.circle,
color: Colors.blue,
clipBehavior: Clip.hardEdge,
child: InkWell(
onTap: () async {
// We can send a new message by calling `sendMessage` on
// the current channel. After sending a message, the
// TextField is cleared and the list view is scrolled
// to show the new item.
if (_controller.value.text.isNotEmpty) {
await widget.channel.sendMessage(
Message(text: _controller.value.text),
);
_controller.clear();
_updateList();
}
},
child: const Padding(
padding: EdgeInsets.all(8.0),
child: Center(
child: Icon(
Icons.send,
color: Colors.white,
),
Padding(
padding: const EdgeInsets.all(8),
child: Row(
children: [
Expanded(
child: TextField(
controller: _controller,
decoration: const InputDecoration(
hintText: 'Enter your message',
),
),
),
)
],
),
)
],
);
}
Material(
type: MaterialType.circle,
color: Colors.blue,
clipBehavior: Clip.hardEdge,
child: InkWell(
onTap: () async {
// We can send a new message by calling `sendMessage` on
// the current channel. After sending a message, the
// TextField is cleared and the list view is scrolled
// to show the new item.
if (_controller.value.text.isNotEmpty) {
await widget.channel.sendMessage(
Message(text: _controller.value.text),
);
_controller.clear();
_updateList();
}
},
child: const Padding(
padding: EdgeInsets.all(8),
child: Center(
child: Icon(
Icons.send,
color: Colors.white,
),
),
),
),
)
],
),
)
],
);
}
/// Helper extension for quickly retrieving
@@ -8,9 +8,9 @@ environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
cupertino_icons: ^1.0.3
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
stream_chat_persistence:
path: ../
@@ -213,8 +213,8 @@ void main() {
test('should return sorted channels using custom field', () async {
int sortComparator(ChannelModel a, ChannelModel b) {
final aData = a.extraData['test_custom_field'] as int;
final bData = b.extraData['test_custom_field'] as int;
final aData = int.parse(a.extraData['test_custom_field'].toString());
final bData = int.parse(b.extraData['test_custom_field'].toString());
return bData.compareTo(aData);
}
@@ -173,8 +173,8 @@ void main() {
expect(entity.shadowed, message.shadowed);
expect(entity.showInChannel, message.showInChannel);
expect(entity.replyCount, message.replyCount);
expect(entity.mentionedUsers,
message.mentionedUsers.map((e) => jsonEncode(e)).toList());
expect(
entity.mentionedUsers, message.mentionedUsers.map(jsonEncode).toList());
expect(entity.reactionScores, message.reactionScores);
expect(entity.reactionCounts, message.reactionCounts);
expect(entity.status, message.status);
@@ -39,7 +39,7 @@ void main() {
lastActive: DateTime.now(),
online: math.Random().nextBool(),
banned: math.Random().nextBool(),
extraData: {'test_extra_data': 'extraData'},
extraData: const {'test_extra_data': 'extraData'},
);
final entity = user.toEntity();
expect(entity, isA<UserEntity>());