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
@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.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');
/// Set the current user. In a production scenario, this should be done using
@@ -13,12 +13,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',
);
runApp(
@@ -29,36 +30,36 @@ Future<void> main() async {
}
/// Example application using Stream Chat core widgets.
/// Stream Chat Core is a set of Flutter wrappers which provide basic functionality
/// for building Flutter applications using Stream.
/// Stream Chat Core is a set of Flutter wrappers which provide basic
/// functionality for building Flutter applications using Stream.
///
/// If you'd prefer using pre-made UI widgets for your app, please see our other
/// package, `stream_chat_flutter`.
class StreamExample extends StatelessWidget {
/// Minimal example using Stream's core Flutter package.
/// If you'd prefer using pre-made UI widgets for your app, please see our other
/// package, `stream_chat_flutter`.
///
/// If you'd prefer using pre-made UI widgets for your app, please see our
/// other package, `stream_chat_flutter`.
const StreamExample({
Key? key,
required this.client,
}) : super(key: key);
/// Instance of Stream Client.
/// Stream's [StreamChatClient] can be used to connect to our servers and set the default
/// user for the application. Performing these actions trigger a websocket connection
/// allowing for real-time updates.
/// Stream's [StreamChatClient] can be used to connect to our servers and
/// set the default user for the application. Performing these actions
/// trigger a websocket connection allowing for real-time updates.
final StreamChatClient client;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Stream Chat Core Example',
home: HomeScreen(),
builder: (context, child) => StreamChatCore(
client: client,
child: child!,
),
);
}
Widget build(BuildContext context) => MaterialApp(
title: 'Stream Chat Core Example',
home: HomeScreen(),
builder: (context, child) => StreamChatCore(
client: client,
child: child!,
),
);
}
/// Basic layout displaying a list of [Channel]s the user is a part of.
@@ -67,104 +68,108 @@ class StreamExample extends StatelessWidget {
/// [ChannelListCore] is a `builder` with callbacks for constructing UIs based
/// on different scenarios.
class HomeScreen extends StatelessWidget {
/// Builds a basic layout displaying a list of [Channel]s the user is a
/// part of.
HomeScreen({Key? key}) : super(key: key);
/// Controller used for loading more data and controlling pagination in
/// [ChannelListCore].
final channelListController = ChannelListController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Channels'),
),
body: ChannelsBloc(
child: ChannelListCore(
channelListController: channelListController,
filter: Filter.and([
Filter.equal('type', 'messaging'),
Filter.in_('members', [
StreamChatCore.of(context).user!.id,
])
]),
emptyBuilder: (BuildContext context) {
return Center(
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: const Text('Channels'),
),
body: ChannelsBloc(
child: ChannelListCore(
channelListController: channelListController,
filter: Filter.and([
Filter.equal('type', 'messaging'),
Filter.in_('members', [
StreamChatCore.of(context).user!.id,
])
]),
emptyBuilder: (BuildContext context) => const Center(
child: Text('Looks like you are not in any channels'),
);
},
loadingBuilder: (BuildContext context) {
return Center(
),
loadingBuilder: (BuildContext context) => const Center(
child: SizedBox(
height: 100.0,
width: 100.0,
height: 100,
width: 100,
child: CircularProgressIndicator(),
),
);
},
errorBuilder: (
BuildContext context,
dynamic error,
) {
return Center(
),
errorBuilder: (
BuildContext context,
dynamic error,
) =>
Center(
child: Text(
'Oh no, something went wrong. Please check your config. ${error}'),
);
},
listBuilder: (
BuildContext context,
List<Channel> channels,
) =>
LazyLoadScrollView(
onEndOfPage: () async {
channelListController.paginateData!();
},
child: ListView.builder(
itemCount: channels.length,
itemBuilder: (BuildContext context, int index) {
final _item = channels[index];
return ListTile(
title: Text(_item.name!),
subtitle: StreamBuilder<Message?>(
stream: _item.state!.lastMessageStream,
initialData: _item.state!.lastMessage,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(snapshot.data!.text!);
}
return SizedBox();
},
),
onTap: () {
/// Display a list of messages when the user taps on an item.
/// We can use [StreamChannel] to wrap our [MessageScreen] screen
/// with the selected channel.
///
/// This allows us to use a built-in inherited widget for accessing
/// our `channel` later on.
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => StreamChannel(
channel: _item,
child: MessageScreen(),
),
),
);
},
);
'Oh no, something went wrong. '
'Please check your config. $error',
),
),
listBuilder: (
BuildContext context,
List<Channel> channels,
) =>
LazyLoadScrollView(
onEndOfPage: () async {
channelListController.paginateData!();
},
child: ListView.builder(
itemCount: channels.length,
itemBuilder: (BuildContext context, int index) {
final _item = channels[index];
return ListTile(
title: Text(_item.name!),
subtitle: StreamBuilder<Message?>(
stream: _item.state!.lastMessageStream,
initialData: _item.state!.lastMessage,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(snapshot.data!.text!);
}
return const SizedBox();
},
),
onTap: () {
/// Display a list of messages when the user taps on
/// an item. We can use [StreamChannel] to wrap our
/// [MessageScreen] screen with the selected channel.
///
/// This allows us to use a built-in inherited widget
/// for accessing our `channel` later on.
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => StreamChannel(
channel: _item,
child: const MessageScreen(),
),
),
);
},
);
},
),
),
),
),
),
);
}
);
}
/// A list of messages sent in the current channel.
/// When a user taps on a channel in [HomeScreen], a navigator push [MessageScreen]
/// to display the list of messages in the selected channel.
/// When a user taps on a channel in [HomeScreen], a navigator push
/// [MessageScreen] to display the list of messages in the selected channel.
///
/// This is implemented using [MessageListCore], a convenience builder with
/// callbacks for building UIs based on different api results.
class MessageScreen extends StatefulWidget {
/// Build a MessageScreen
const MessageScreen({Key? key}) : super(key: key);
@override
_MessageScreenState createState() => _MessageScreenState();
}
@@ -198,8 +203,8 @@ class _MessageScreenState extends State<MessageScreen> {
@override
Widget build(BuildContext context) {
/// To access the current channel, we can use the `.of()` method on [StreamChannel]
/// to fetch the closest instance.
/// To access the current channel, we can use the `.of()` method on
/// [StreamChannel] to fetch the closest instance.
final channel = StreamChannel.of(context).channel;
return Scaffold(
appBar: AppBar(
@@ -210,7 +215,7 @@ class _MessageScreenState extends State<MessageScreen> {
if (snapshot.hasData && snapshot.data!.isNotEmpty) {
return Text('${snapshot.data!.first.name} is typing...');
}
return SizedBox();
return const SizedBox();
},
),
),
@@ -224,57 +229,52 @@ class _MessageScreenState extends State<MessageScreen> {
},
child: MessageListCore(
messageListController: messageListController,
emptyBuilder: (BuildContext context) {
return Center(
child: Text('Nothing here yet'),
);
},
loadingBuilder: (BuildContext context) {
return Center(
child: SizedBox(
height: 100.0,
width: 100.0,
child: CircularProgressIndicator(),
),
);
},
emptyBuilder: (BuildContext context) => const Center(
child: Text('Nothing here yet'),
),
loadingBuilder: (BuildContext context) => const Center(
child: SizedBox(
height: 100,
width: 100,
child: CircularProgressIndicator(),
),
),
messageListBuilder: (
BuildContext context,
List<Message> messages,
) {
return ListView.builder(
controller: _scrollController,
itemCount: messages.length,
reverse: true,
itemBuilder: (BuildContext context, int index) {
final item = messages[index];
final client = StreamChatCore.of(context).client;
if (item.user!.id == client.uid) {
return Align(
alignment: Alignment.centerRight,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(item.text!),
),
);
} else {
return Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(item.text!),
),
);
}
},
);
},
) =>
ListView.builder(
controller: _scrollController,
itemCount: messages.length,
reverse: true,
itemBuilder: (BuildContext context, int index) {
final item = messages[index];
final client = StreamChatCore.of(context).client;
if (item.user!.id == 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!),
),
);
}
},
),
errorBuilder: (BuildContext context, error) {
print(error.toString());
return Center(
return const Center(
child: SizedBox(
height: 100.0,
width: 100.0,
height: 100,
width: 100,
child:
Text('Oh no, an error occured. Please see logs.'),
),
@@ -21,14 +21,14 @@ environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.3
flutter:
sdk: flutter
stream_chat_flutter_core:
path: ../
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0
dev_dependencies:
flutter_test: