Fix a couple Vale linter warnings

This commit is contained in:
Jeroen Leenarts
2022-12-06 15:41:05 +01:00
parent dbbb2f26be
commit a338b9b95f
67 changed files with 303 additions and 303 deletions
@@ -23,7 +23,7 @@ Filter.equal('type', 'messaging'),
#### Filter.notEqual
The 'notEqual' filter gets the objects where the given key does not have the specified value.
The `notEqual` filter gets the objects where the given key does not have the specified value.
```dart
Filter.notEqual('type', 'messaging'),
@@ -63,20 +63,20 @@ Filter.lessOrEqual('count', 5),
#### Filter.in_
The 'in_' filter allows getting objects where the key matches any in a specified array.
The `in_` filter allows getting objects where the key matches any in a specified array.
```dart
Filter.in_('members', [user.id])
```
:::note
Since 'in' is a keyword in Dart, the filter has an underscore added. This does not apply to the 'notIn'
Since 'in' is a keyword in Dart, the filter has an underscore added. This does not apply to the `notIn`
keyword.
:::
#### Filter.notIn
The 'notIn' filter allows getting objects where the key matches none in a specified array.
The `notIn` filter allows getting objects where the key matches none in a specified array.
```dart
Filter.notIn('members', [user.id])
@@ -108,7 +108,7 @@ Filter.exists('name')
#### Filter.notExists
The 'notExists' filter checks if the specified key doesn't exist. This is a simplified call to `Filter.exists`
The `notExists` filter checks if the specified key doesn't exist. This is a simplified call to `Filter.exists`
with the value set to false.
```dart
@@ -27,7 +27,7 @@ final client = StreamChatClient(
)..chatPersistenceClient = CustomChatPersistentClient();
```
We provide an official persistent client in the [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence)
We provide an official persistent client in the [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence)
package that works using the library [moor](https://moor.simonbinder.eu), an SQLite ORM.
Add this to your package's `pubspec.yaml` file, using the latest version.
@@ -154,7 +154,7 @@ Running the above will give this:
![](../assets/authentication_demo_app.jpg)
The `Auth` widget handles all of the authentication logic. It initializes a `FirebaseAuth.instance` and uses that
in the `createAccount`, `signIn` and `signOut` methods. There is a button to envoke each of these methods.
in the `createAccount`, `signIn` and `signOut` methods. There is a button to invoke each of these methods.
The `FirebaseFunctions.instance` will be used later in this guide.
@@ -288,7 +288,7 @@ firebase deploy --only functions
### Create a Stream User and Get the User's Token
In the `createStreamUserAndGetToken` cloud function you create an `onCall` HTTPS handler, which exposes
a cloud function that can be envoked from your Flutter app.
a cloud function that can be invoked from your Flutter app.
```js
// Create a Stream user and return auth token.
@@ -324,13 +324,13 @@ by ensuring that `context.auth` is not null. If it is null, then it throws an `H
message. This error can be caught in your Flutter application.
If the caller is authenticated the function proceeds to use the `serverClient` to create a new Stream Chat
user by calling the `upsertUser` method and passing in some user data. It uses the authenticated caller's **uid** as an **id**.
user by calling the `upsertUser` method and passing in some user data. It uses the authenticated caller's **`uid`** as an **id**.
After the user is created it generates a token for that user. This token is then returned to the caller.
To call this from Flutter, you will need to use the `cloud_functions` package.
Update the **createAccount** method in your Flutter code to the following:
Update the **`createAccount`** method in your Flutter code to the following:
```dart
Future<void> createAccount() async {
@@ -354,7 +354,7 @@ in the request.
Once you have the Stream user token, you can authenticate your Stream Chat user as you normally would.
Please see our [initialization documention](https://getstream.io/chat/docs/flutter-dart/init_and_users/?language=dart) for more information.
Please see our [initialization documentation](https://getstream.io/chat/docs/flutter-dart/init_and_users/?language=dart) for more information.
As you can see below, the User ID matches on both Firebase's and Stream's user database.
@@ -372,7 +372,7 @@ As you can see below, the User ID matches on both Firebase's and Stream's user d
The `getStreamUserToken` cloud function is very similar to the `createStreamUserAndGetToken` function. The only difference is
that it only creates a user token and does not create a new user account on Stream.
Update the **signIn** method in your Flutter code to the following:
Update the **`signIn`** method in your Flutter code to the following:
```dart
Future<void> signIn() async {
@@ -433,7 +433,7 @@ exports.deleteStreamUser = functions.auth.user().onDelete((user, context) => {
```
In this function, you are listening to delete events on Firebase auth. When an account is deleted, this function will be triggered, and you can get the
user's **uid** and call the `deleteUser` method on the `serverClient`.
user's **`uid`** and call the `deleteUser` method on the `serverClient`.
This is not an external cloud function; it can only be triggered when an
account is deleted.
@@ -21,7 +21,7 @@ Make sure to check [this section](https://getstream.io/chat/docs/flutter-dart/pu
### Setup FCM
To integrate push notifications in your Flutter app you need to use the package [firebase_messaging](https://pub.dev/packages/firebase_messaging).
To integrate push notifications in your Flutter app you need to use the package [`firebase_messaging`](https://pub.dev/packages/firebase_messaging).
Follow the [Firebase documentation](https://firebase.flutter.dev/docs/messaging/overview/) to know how to set up the plugin for both Android and iOS.
@@ -61,7 +61,7 @@ Upload the `Server Key` in your chat dashboard
:::note
We are setting up the Android section, but this will work for both Android and iOS if you're using Firebase for both of them!
We are setting up the Android section, but this will work for both Android and iOS if you're using Firebase for both of them.
:::
#### Step 6
@@ -97,21 +97,21 @@ firebaseMessaging.onTokenRefresh.listen((token) {
### Possible issues
We only send push notifications when the user doesn't have any active websocket connection (which is established when you call `client.connectUser`). If you set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) property of the StreamChat widget, when your app goes to background, your device will keep the ws connection alive for 1 minute, and so within this period, you won't receive any push notification.
We only send push notifications when the user doesn't have any active web socket connection (which is established when you call `client.connectUser`). If you set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) property of the StreamChat widget, when your app goes to background, your device will keep the WS connection alive for 1 minute, and so within this period, you won't receive any push notification.
Make sure to read the [general push docs](https://getstream.io/chat/docs/flutter-dart/push_introduction/?language=dart) in order to avoid known gotchas that may make your relationship with notifications go bad 😢
### Testing if Push Notifications are Setup Correctly
If you're not sure if you've set up push notifications correctly (e.g. you don't always receive them, they work unreliably), you can follow these steps to make sure your config is correct and working:
If you're not sure if you've set up push notifications correctly (for example you don't always receive them, they work unreliably), you can follow these steps to make sure your configuration is correct and working:
1. Clone our repo for push testing git clone [email protected]:GetStream/chat-push-test.git
1. Clone our repository for push testing git clone [email protected]:GetStream/chat-push-test.git
2. `cd flutter`
3. In folder run `flutter pub get`
4. Input your api key and secret in `lib/main.dart`
4. Input your API key and secret in `lib/main.dart`
5. Change the bundle identifier/application ID and development team/user so you can run the app in your device (**do not** run on iOS simulator, Android emulator is fine)
@@ -137,11 +137,11 @@ You should get a test push notification
The [StreamChat](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat-class.html) widget lets you define a [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html) handler in order to handle events while the app is in the background, but the client is still connected.
This is useful because it lets you keep the connection alive in cases in which the app goes in the background just for some seconds (eg: multitasking, picking pictures from the gallery...)
This is useful because it lets you keep the connection alive in cases in which the app goes in the background just for some seconds (for example multitasking, picking pictures from the gallery...)
You can even customize the [backgroundKeepAlive](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/backgroundKeepAlive.html) duration.
In order to show notifications in such a case we suggest using the package [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications); follow the package guide to successfully set up the plugin.
In order to show notifications in such a case we suggest using the package [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications); follow the package guide to successfully set up the plugin.
Once that's done you should set the [onBackgroundEventReceived](https://pub.dev/documentation/stream_chat_flutter/latest/stream_chat_flutter/StreamChat/onBackgroundEventReceived.html); here is an example:
@@ -234,7 +234,7 @@ To do this we need to update the push notification data payload at Stream Dashbo
}
```
Then we need to integrate the package [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, learn [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up.
Then we need to integrate the package [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, learn [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up.
Then during the call `firebaseMessaging.configure(...)` we need to set the `onBackgroundMessage` parameter using a TOP-LEVEL or STATIC function to handle background messages; here is an example:
@@ -17,7 +17,7 @@ You can read more about Streams [push delivery logic](https://getstream.io/ch
### Setup FCM
To integrate push notifications in your Flutter app, you need to use the package [firebase_messaging](https://pub.dev/packages/firebase_messaging).
To integrate push notifications in your Flutter app, you need to use the package [`firebase_messaging`](https://pub.dev/packages/firebase_messaging).
Follow the [Firebase documentation](https://firebase.flutter.dev/docs/messaging/overview/) to set up the plugin for Android and iOS.
@@ -55,7 +55,7 @@ You can upload your Firebase credentials using either the dashboard or the app s
![](../../assets/firebase_notifications_toggle-5aeabfcbdc24cb8f1fea7d41d0e845fc.png)
3. Enter your Firebase Credentials and press "Save".
3. Enter your Firebase Credentials and press `"Save"`.
##### Using the API
@@ -86,7 +86,7 @@ firebaseMessaging.onTokenRefresh.listen((token) {
});
```
Push Notifications v2 also supports specifying a name to the push device tokens you register. By setting the optional `pushProviderName` param in the `addDevice` call you can support different configurations between the device and the `PushProvider`.
Push Notifications v2 also supports specifying a name to the push device tokens you register. By setting the optional `pushProviderName` parameter in the `addDevice` call you can support different configurations between the device and the `PushProvider`.
```dart
firebaseMessaging.onTokenRefresh.listen((token) {
@@ -105,7 +105,7 @@ On iOS we send both a **notification** and a **data** payload.
This means you don't need to do anything special to get the notification to show up. However, you might want to handle the data payload to perform some logic when the user taps on the notification.
To update the template, you can use a backend SDK.
For example, using the javascript SDK:
For example, using the JavaScript SDK:
```js
const client = StreamChat.getInstance(api_key, api_secret);
@@ -181,13 +181,13 @@ void handleNotification(
FirebaseMessaging.onBackgroundMessage(onBackgroundMessage);
```
In the above example, you get the message details using the `getMessage` method and then you use the [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications) package to show the actual notification.
In the above example, you get the message details using the `getMessage` method and then you use the [`flutter_local_notifications`](https://pub.dev/packages/flutter_local_notifications) package to show the actual notification.
##### Using a Template on Android
It's still possible to add a **notification** payload to Android notifications.
You can do so by adding a template using a backend SDK.
For example, using the javascript SDK:
For example, using the JavaScript SDK:
```js
const client = StreamChat.getInstance(api_key, api_secret);
@@ -211,11 +211,11 @@ Make sure to read the [general push notification docs](https://getstream.io/chat
### Testing if Push Notifications are Setup Correctly
If you're not sure whether you've set up push notifications correctly, for example, you don't always receive them, or they dont work reliably, then you can follow these steps to make sure your config is correct and working:
1. Clone our repo for push testing: `git clone [email protected]:GetStream/chat-push-test.git`
If you're not sure whether you've set up push notifications correctly, for example, you don't always receive them, or they dont work reliably, then you can follow these steps to make sure your configuration is correct and working:
1. Clone our repository for push testing: `git clone [email protected]:GetStream/chat-push-test.git`
2. `cd flutter`
3. In that folder run `flutter pub get`
4. Input your api key and secret in `lib/main.dart`
4. Input your API key and secret in `lib/main.dart`
5. Change the bundle identifier/application ID and development team/user so you can run the app on your physical device.**Do not** run on an iOS simulator, as it will not work. Testing on an Android emulator is fine.
6. Add your `google-services.json/GoogleService-Info.plist`
7. Run the app
@@ -257,7 +257,7 @@ Take a look at the [Stream Chat v1 sample app](https://github.com/GetStream/flut
When the app is closed you may want to save received messages when you receive them via a notification so that later on when you open the app they're already there.
To do this you need to integrate the package [stream_chat_persistence](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, see [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up.
To do this you need to integrate the package [`stream_chat_persistence`](https://pub.dev/packages/stream_chat_persistence) in our app that exports a persistence client, see [here](https://pub.dev/packages/stream_chat_persistence#usage) how to set it up.
Then calling `FirebaseMessaging.onBackgroundMessage(...)` you need to use a TOP-LEVEL or STATIC function to handle background messages; here is an example:
@@ -37,7 +37,7 @@ Check out the diagram below for an example:
### Dependencies
Add the [webcrypto](https://pub.dev/packages/webcrypto) package in your `pubspec.yaml` file.
Add the [`webcrypto`](https://pub.dev/packages/webcrypto) package in your `pubspec.yaml` file.
```yaml
dependencies:
@@ -77,9 +77,9 @@ class JsonWebKeyPair {
}
```
### Generate a Crypto Key
### Generate a Cryptographic Key
Next, create a symmetric **Crypto Key** using the keys generated in the previous step.
Next, create a symmetric **Cryptographic Key** using the keys generated in the previous step.
You will use those keys to encrypt and decrypt messages.
```dart
@@ -108,7 +108,7 @@ Future<List<int>> deriveKey(String senderJwk, String receiverJwk) async {
### Encrypting Messages
Once you have generated the **Crypto Key**, you're ready to encrypt the message.
Once you have generated the **Cryptographic Key**, you're ready to encrypt the message.
You can use the **AES-GCM** algorithm for its known security and performance balance and good browser availability.
```dart
@@ -254,6 +254,6 @@ StreamMessageListView(
),
```
That's it! That's all you need to implement E2EE in a Stream powered chat app.
That's it. That's all you need to implement E2EE in a Stream powered chat app.
For more details, check out our [end-to-end encrypted chat article](https://getstream.io/blog/end-to-end-encrypted-chat-in-flutter/#whats-end-to-end-encryption).
@@ -14,7 +14,7 @@ If you find any bugs or have any questions, please file an [issue on our GitHub
Code examples:
- See our [Stream Chat Flutter tutorial](https://getstream.io/chat/flutter/tutorial/) for an up-to-date guide using the latest Stream Chat version.
- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our fully-fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1).
- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our full fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1).
All of our documentation has also been updated to support v4, so all of the guides and examples will have updated code.
@@ -209,10 +209,10 @@ Let's explore some examples of the functional differences when using the new `St
The **StreamChannelListController** provides various methods, such as:
- **deleteChannel**
- **loadMore**
- **muteChannel**
- **deleteChannel**
- **`deleteChannel`**
- **`loadMore`**
- **`muteChannel`**
- **`deleteChannel`**
For a complete list with additional information, see the code documentation.
@@ -537,7 +537,7 @@ Creating a separate controller allows easier control over the message input cont
The widget is also separated into smaller components: `StreamCountDownButton`, `StreamAttachmentPicker`, etc.
> ❗The `MessageInputController` is exposed by the **stream_chat_flutter_core** package. This allows you to use the controller even if you're not using the UI components.
> ❗The `MessageInputController` is exposed by the **`stream_chat_flutter_core`** package. This allows you to use the controller even if you're not using the UI components.
As a result of this extra control, it is no longer needed for the new `StreamMessageInput` widget to expose these `MessageInput` arguments:
@@ -734,7 +734,7 @@ The controller makes it much simpler to dynamically modify the message input.
## Stream Chat Flutter Core
Various changes have been made to the Core package, most notably, the indroduction of all of the controllers mentioned above.
Various changes have been made to the Core package, most notably, the introduction of all of the controllers mentioned above.
These controllers replace the business logic implementations (Bloc). Please note that this is not related to the well-known Flutter Bloc package, but instead refers to the naming we used for our business logic components.
@@ -16,7 +16,7 @@ If you find any bugs or have any questions, please file an [issue on our GitHub
Code examples:
- See our [Stream Chat Flutter tutorial](https://getstream.io/chat/flutter/tutorial/) for an up-to-date guide using the latest Stream Chat version.
- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our fully-fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1).
- See the [Stream Flutter Samples repository](https://github.com/GetStream/flutter-samples) with our full fledged messaging [sample application](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1).
Our documentation has also been updated to support v5, so all guides and examples will have updated code.
@@ -59,7 +59,7 @@ The user experience of interacting with a desktop application differs from a mob
- Input controls: touch, keyboard, and mouse interactions
- Native file system or gallery access (as well as sharing functionality)
- Shortcuts
- Dialogs
- Dialog screens
By default, Stream Chat Flutter will use the correct input controls and visual elements for the target platform. For example, touch and swipe controls will be the default on mobile, while on web and desktop these will be disabled and interactions with the mouse and keyboard will be preferred.
@@ -70,7 +70,7 @@ On desktop and web it's also possible to add attachments by simply dragging them
- Right-click context menus for messages and full-screen attachments.
- Upload and download attachments using the native desktop file system.
- Press the "enter" key to send a message.
- If you are quoting a message and have not yet typed any text, you can press the "esc" key to remove the quoted message.
- If you are quoting a message and have not yet typed any text, you can press the `"esc"` key to remove the quoted message.
- A dedicated "X" button for removing a quoted message with your mouse.
- Drag and drop attachment files to `StreamMessageInput`.
- New `StreamMessageInput.draggingBorder` property to customize the border color of the message input when dropping a file.
@@ -81,10 +81,10 @@ On desktop and web it's also possible to add attachments by simply dragging them
- Gallery navigation controls with keyboard shortcuts (left and right arrow keys).
- Appropriate message sizing for large screens.
- Right-click context menu for `StreamMessageListView` items.
- `StreamMessageListView` items not swipeable on desktop & web.
- `StreamMessageListView` items not swipe-able on desktop & web.
- Video support for Windows & Linux through `dart_vlc`.
- Video support for macOS through `video_player_macos`.
- Replace bottom sheets with dialogs where appropriate.
- Replace bottom sheets with dialog screens where appropriate.
## What's New?
@@ -118,7 +118,7 @@ Check out the dedicated [guide](../../02-customization/01-custom-widgets/05-cust
The following was also introduced:
- Added support for additional text field params in`StreamMessageInput`: `maxLines`, `minLines`, `textInputAction`, `keyboardType`, and `textCapitalization`.
- Added support for additional text field parameters in`StreamMessageInput`: `maxLines`, `minLines`, `textInputAction`, `keyboardType`, and `textCapitalization`.
- Added `showStreamAttachmentPickerModalBottomSheet` to show the attachment picker modal bottom sheet.
- Added `onQuotedMessageCleared` to `StreamMessageInput`
- `selected` and `selectedTileColor` to `StreamChannelListTile`
@@ -196,7 +196,7 @@ Both of these will ensure the route is disposed of and the user is disconnected
Another approach would be to introduce a new [Navigator](https://api.flutter.dev/flutter/widgets/Navigator-class.html).
This has the benefit that everything related to Stream chat is contained to a specific part of the widget tree.
### Defining Routes and Subroutes
### Defining Routes and Nested Routes
In this example, our application has the following routes.
@@ -208,7 +208,7 @@ const routeChatChannels = 'chat_channels';
const routeChatChannel = 'chat_channel';
```
For the `/chat/` subroutes (**routePrefixChat**), this approach initializes Stream Chat in our application and introduces a nested navigator.
For the `/chat/` nested routes (**routePrefixChat**), this approach initializes Stream Chat in our application and introduces a nested navigator.
Lets explore the code:
@@ -267,7 +267,7 @@ In the above code youre:
1. Creating a navigator key, passing it to `MaterialApp`, and exposing it to the whole application using Provider (you can expose it however you want).
2. Creating `onGenerateRoute` that specifies what page to show depending on the route. Most importantly, if the route contains the **routePrefixChat,** it navigates to the **ChatSetup** page and passes in the remainder of the route.
For example, `Navigator.pushNamed(context, routeChatHome)` will navigate to the **ChatSetup** page and pass in the subroute **routeChatChannels.**
For example, `Navigator.pushNamed(context, routeChatHome)` will navigate to the **ChatSetup** page and pass in the nested route **routeChatChannels.**
### Stream Chat Initialization, User Connection, and Nested Navigation
@@ -456,7 +456,7 @@ This final example will be a combination of the first two options. The following
### Application Routes and Conditional Stream Initialization
For this example we have the following routes and subroutes:
For this example we have the following routes and nested routes:
```dart
|_ '/' -> home page
@@ -553,7 +553,7 @@ If youre unfamiliar with GoRouter it will help to first read the documentatio
There are a few important things to note in the above code:
- Define our routes and subroutes
- Define our routes and nested routes
- Specify the initial route with `initialLocation`
- Use the `navigatorBuilder` to wrap certain routes with **StreamChat** and **ChatSetup**.
- The `wasPreviousRouteChat` \***\*boolean is used to determine if the previous route was a chat route. This is important because when you press the back button from the `/chat` route and navigate to the `/` route, the **StreamChat** widget still needs to be accessible while the navigation transition occurs. However, if you then navigate to the `/setting` route, you no longer need the **StreamChat\*\* widget and can safely remove it.