Skip to content

Commit

Permalink
fix(repo): make stable version compatible with latest flutter versions
Browse files Browse the repository at this point in the history
  • Loading branch information
esarbanis committed Mar 5, 2024
1 parent ad3d755 commit 1945ebd
Show file tree
Hide file tree
Showing 32 changed files with 307 additions and 162 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,26 @@ Stream allows developers to rapidly deploy scalable feeds and chat messaging wit

**V4 Migration Guide**

For upgrading from V3 to V4, please refer to the [V4 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migration_guide_4_0/)
> [!WARNING]
> Flutter `> = v3.16.x` uses material 3 by default which breaks the UI of some of the components.
> If you want to use these versions, you need to set the `useMaterial3` parameter to `false`
> in the `ThemeData`.
>
> eg.
>
> ```dart
> MaterialApp(
> theme: ThemeData(
> useMaterial3: false,
> ),
> ...
> );
> ```
>
> `StreamChat` widget overrides the `useMaterial3` parameter to `false` by default
> so if you are using `StreamChat` widget, you **don't** need to set it manually.
For upgrading from V6 to V7, please refer to the [V4 Migration Guide](https://getstream.io/chat/docs/sdk/flutter/guides/migration_guide_7_0/)
## Sample apps and demos
Our team maintains a dedicated repository for full fledged sample applications and demos. Consider checking out [GetStream/flutter-samples](https://github.com/GetStream/flutter-samples) to learn more or get started by looking at our latest [Stream Chat demo](https://github.com/GetStream/flutter-samples/tree/main/packages/stream_chat_v1).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ Future<T?> showChannelInfoModalBottomSheet<T>({
/// sheet.
/// * [Scaffold.of], for information about how to obtain the [BuildContext].
/// * <https://material.io/design/components/sheets-bottom.html#standard-bottom-sheet>
PersistentBottomSheetController<T> showChannelInfoBottomSheet<T>({
PersistentBottomSheetController showChannelInfoBottomSheet<T>({

Check warning on line 324 in packages/stream_chat_flutter/lib/src/bottom_sheets/stream_channel_info_bottom_sheet.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/bottom_sheets/stream_channel_info_bottom_sheet.dart#L324

Added line #L324 was not covered by tests
required BuildContext context,
required Channel channel,
Color? backgroundColor,
Expand All @@ -336,7 +336,7 @@ PersistentBottomSheetController<T> showChannelInfoBottomSheet<T>({
VoidCallback? onDeleteConversationTap,
VoidCallback? onCancelTap,
}) =>
showBottomSheet<T>(
showBottomSheet(

Check warning on line 339 in packages/stream_chat_flutter/lib/src/bottom_sheets/stream_channel_info_bottom_sheet.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_flutter/lib/src/bottom_sheets/stream_channel_info_bottom_sheet.dart#L339

Added line #L339 was not covered by tests
context: context,
backgroundColor: backgroundColor,
elevation: elevation,
Expand Down
69 changes: 37 additions & 32 deletions packages/stream_chat_flutter/lib/src/stream_chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,40 +107,45 @@ class StreamChatState extends State<StreamChat> {
@override
Widget build(BuildContext context) {
final theme = _getTheme(context, widget.streamChatThemeData);
return Portal(
child: StreamChatConfiguration(
data: streamChatConfigData,
child: StreamChatTheme(
data: theme,
child: Builder(
builder: (context) {
final materialTheme = Theme.of(context);
final streamTheme = StreamChatTheme.of(context);
return Theme(
data: materialTheme.copyWith(
primaryIconTheme: streamTheme.primaryIconTheme,
colorScheme: materialTheme.colorScheme.copyWith(
secondary: streamTheme.colorTheme.accentPrimary,
return Theme(
data: Theme.of(context).copyWith(
useMaterial3: false,
),
child: Portal(
child: StreamChatConfiguration(
data: streamChatConfigData,
child: StreamChatTheme(
data: theme,
child: Builder(
builder: (context) {
final materialTheme = Theme.of(context);
final streamTheme = StreamChatTheme.of(context);
return Theme(
data: materialTheme.copyWith(
primaryIconTheme: streamTheme.primaryIconTheme,
colorScheme: materialTheme.colorScheme.copyWith(
secondary: streamTheme.colorTheme.accentPrimary,
),
),
),
child: StreamChatCore(
client: client,
onBackgroundEventReceived: widget.onBackgroundEventReceived,
backgroundKeepAlive: widget.backgroundKeepAlive,
connectivityStream: widget.connectivityStream,
child: Builder(
builder: (context) {
StreamChatClient.additionalHeaders = {
'X-Stream-Client':
'${StreamChatClient.defaultUserAgent}-'
'ui-${StreamChatClient.packageVersion}',
};
return widget.child ?? const Offstage();
},
child: StreamChatCore(
client: client,
onBackgroundEventReceived: widget.onBackgroundEventReceived,
backgroundKeepAlive: widget.backgroundKeepAlive,
connectivityStream: widget.connectivityStream,
child: Builder(
builder: (context) {
StreamChatClient.additionalHeaders = {
'X-Stream-Client':
'${StreamChatClient.defaultUserAgent}-'
'ui-${StreamChatClient.packageVersion}',
};
return widget.child ?? const Offstage();
},
),
),
),
);
},
);
},
),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:mocktail/mocktail.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';
import '../mocks.dart';

void main() {
Expand Down Expand Up @@ -42,8 +43,8 @@ void main() {
'golden test for the name "demo user"',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
MaterialAppWrapper(
home: const Scaffold(
body: Center(
child: SizedBox(
width: 100,
Expand All @@ -64,8 +65,8 @@ void main() {
'golden test for the name "demo"',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
MaterialAppWrapper(
home: const Scaffold(
body: Center(
child: SizedBox(
width: 100,
Expand All @@ -85,8 +86,8 @@ void main() {
'control special character test',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
MaterialAppWrapper(
home: const Scaffold(
body: Center(
child: SizedBox(
width: 100,
Expand All @@ -109,8 +110,8 @@ void main() {
'control special character test 2',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
MaterialAppWrapper(
home: const Scaffold(
body: Center(
child: SizedBox(
width: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:mocktail/mocktail.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';
import '../mocks.dart';

void main() {
Expand Down Expand Up @@ -95,7 +96,7 @@ void main() {
'golden test for the group with "user123" and "user456"',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
home: StreamChat(
client: client,
streamChatThemeData: StreamChatThemeData.light(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:mocktail/mocktail.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';
import '../mocks.dart';

void main() {
Expand Down Expand Up @@ -49,7 +50,7 @@ void main() {
(WidgetTester tester) async {
when(() => user.online).thenReturn(true);
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
builder: (context, child) {
return StreamChatConfiguration(
data: StreamChatConfigurationData(),
Expand Down Expand Up @@ -82,7 +83,7 @@ void main() {
(WidgetTester tester) async {
when(() => user.online).thenReturn(false);
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
builder: (context, child) {
return StreamChatConfiguration(
data: StreamChatConfigurationData(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';

void main() {
group('AttachmentModalSheet tests', () {
testWidgets('Appears on tap', (tester) async {
Expand Down Expand Up @@ -117,7 +119,7 @@ void main() {
'golden test for AttachmentModalSheet',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
home: Scaffold(
body: Builder(builder: (context) {
return Center(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';
import '../mocks.dart';

void main() {
Expand Down Expand Up @@ -71,7 +72,7 @@ void main() {
'golden test for EditMessageSheet',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
builder: (context, child) => StreamChat(
client: MockClient(),
child: child,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';
import '../mocks.dart';

void main() {
Expand Down Expand Up @@ -77,7 +78,7 @@ void main() {
'golden test for ErrorAlertSheet',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
builder: (context, child) => StreamChat(
client: MockClient(),
child: child,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';
import '../mocks.dart';

void main() {
Expand Down Expand Up @@ -273,7 +274,7 @@ void main() {
.thenAnswer((i) => Stream.value(1));

await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
home: StreamChat(
client: client,
child: StreamChannel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:stream_chat_flutter/src/context_menu_items/download_menu_item.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';
import '../mocks.dart';

void main() {
Expand Down Expand Up @@ -31,7 +32,7 @@ void main() {
'golden test for DownloadMenuItem',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
builder: (context, child) => StreamChatTheme(
data: StreamChatThemeData.light(),
child: child!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:stream_chat_flutter/src/context_menu_items/stream_chat_context_menu_item.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';
import '../mocks.dart';

void main() {
Expand All @@ -29,7 +30,7 @@ void main() {
'golden test for StreamChatContextMenuItem',
(WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
builder: (context, child) => StreamChatTheme(
data: StreamChatThemeData.light(),
child: child!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:stream_chat_flutter/src/dialogs/confirmation_dialog.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';

void main() {
testWidgets('ChannelInfoDialog shows info and members', (tester) async {
await tester.pumpWidget(
Expand Down Expand Up @@ -38,7 +40,7 @@ void main() {

testGoldens('golden test for ConfirmationDialog', (tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
home: Scaffold(
body: Builder(
builder: (context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:stream_chat_flutter/src/dialogs/delete_message_dialog.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';

void main() {
testWidgets('DeleteMessageDialog', (tester) async {
await tester.pumpWidget(
Expand All @@ -30,7 +32,7 @@ void main() {

testGoldens('golden test for DeleteMessageDialog', (tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
home: Scaffold(
body: Builder(
builder: (context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import 'package:golden_toolkit/golden_toolkit.dart';
import 'package:stream_chat_flutter/src/dialogs/message_dialog.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';

import '../material_app_wrapper.dart';

void main() {
testWidgets('MessageDialog shows default info', (tester) async {
await tester.pumpWidget(
Expand Down Expand Up @@ -57,7 +59,7 @@ void main() {

testGoldens('golden test for default MessageDialog', (tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
home: Scaffold(
body: Builder(
builder: (context) {
Expand All @@ -78,7 +80,7 @@ void main() {

testGoldens('golden test for custom MessageDialog', (tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
home: Scaffold(
body: Builder(
builder: (context) {
Expand All @@ -103,7 +105,7 @@ void main() {
testGoldens('golden test for custom MessageDialog with no body',
(tester) async {
await tester.pumpWidget(
MaterialApp(
MaterialAppWrapper(
home: Scaffold(
body: Builder(
builder: (context) {
Expand Down
Loading

0 comments on commit 1945ebd

Please sign in to comment.