Merge branches 'feature/new-ui' and 'llc-independence' of https://github.com/GetStream/stream-chat-flutter into llc-independence
This commit is contained in:
@@ -167,7 +167,7 @@ class _ChannelListViewState extends State<ChannelListView>
|
|||||||
emptyBuilder: (BuildContext context) {
|
emptyBuilder: (BuildContext context) {
|
||||||
return _buildEmptyWidget();
|
return _buildEmptyWidget();
|
||||||
},
|
},
|
||||||
errorBuilder: (Error error) {
|
errorBuilder: (BuildContext context, dynamic error) {
|
||||||
return _buildErrorWidget(context);
|
return _buildErrorWidget(context);
|
||||||
},
|
},
|
||||||
loadingBuilder: (BuildContext context) {
|
loadingBuilder: (BuildContext context) {
|
||||||
@@ -224,6 +224,7 @@ class _ChannelListViewState extends State<ChannelListView>
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
return _listItemBuilder(context, index, channels);
|
return _listItemBuilder(context, index, channels);
|
||||||
},
|
},
|
||||||
|
controller: _scrollController,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class _MessageSearchListViewState extends State<MessageSearchListView> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
errorBuilder: (error) {
|
errorBuilder: (BuildContext context, dynamic error) {
|
||||||
if (error is Error) {
|
if (error is Error) {
|
||||||
print((error).stackTrace);
|
print((error).stackTrace);
|
||||||
}
|
}
|
||||||
@@ -159,9 +159,8 @@ class _MessageSearchListViewState extends State<MessageSearchListView> {
|
|||||||
|
|
||||||
var message = error.toString();
|
var message = error.toString();
|
||||||
if (error is DioError) {
|
if (error is DioError) {
|
||||||
final dioError = error as DioError;
|
if (error.type == DioErrorType.RESPONSE) {
|
||||||
if (dioError.type == DioErrorType.RESPONSE) {
|
message = error.message;
|
||||||
message = dioError.message;
|
|
||||||
} else {
|
} else {
|
||||||
message = 'Check your connection and retry';
|
message = 'Check your connection and retry';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class HomeScreen extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
errorBuilder: (Error error) {
|
errorBuilder: (BuildContext context, dynamic error) {
|
||||||
return Center(
|
return Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Oh no, something went wrong. Please check your config.'),
|
'Oh no, something went wrong. Please check your config.'),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stream_chat/stream_chat.dart';
|
import 'package:stream_chat/stream_chat.dart';
|
||||||
import 'package:stream_chat_flutter_core/src/channels_bloc.dart';
|
import 'package:stream_chat_flutter_core/src/channels_bloc.dart';
|
||||||
|
import 'package:stream_chat_flutter_core/src/typedef.dart';
|
||||||
|
|
||||||
import 'stream_chat_core.dart';
|
import 'stream_chat_core.dart';
|
||||||
|
|
||||||
@@ -72,7 +73,7 @@ class ChannelListCore extends StatefulWidget {
|
|||||||
final ChannelListController channelListController;
|
final ChannelListController channelListController;
|
||||||
|
|
||||||
/// The builder that will be used in case of error
|
/// The builder that will be used in case of error
|
||||||
final Widget Function(Error error) errorBuilder;
|
final ErrorBuilder errorBuilder;
|
||||||
|
|
||||||
/// The builder that will be used in case of loading
|
/// The builder that will be used in case of loading
|
||||||
final WidgetBuilder loadingBuilder;
|
final WidgetBuilder loadingBuilder;
|
||||||
@@ -162,7 +163,7 @@ class _ChannelListCoreState extends State<ChannelListCore>
|
|||||||
print((snapshot.error as Error).stackTrace);
|
print((snapshot.error as Error).stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
return widget.errorBuilder(snapshot.error);
|
return widget.errorBuilder(context, snapshot.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadData() {
|
void loadData() {
|
||||||
|
|||||||
@@ -3,14 +3,9 @@ import 'dart:async';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stream_chat/stream_chat.dart';
|
import 'package:stream_chat/stream_chat.dart';
|
||||||
|
import 'package:stream_chat_flutter_core/src/typedef.dart';
|
||||||
import 'stream_channel.dart';
|
import 'stream_channel.dart';
|
||||||
|
|
||||||
/// A signature for a callback which exposes an error and returns a function.
|
|
||||||
/// This Callback can be used in cases where an API failure occurs and the widget
|
|
||||||
/// is unable to render data.
|
|
||||||
typedef StreamErrorBuilder = Widget Function(
|
|
||||||
BuildContext context, Object error);
|
|
||||||
|
|
||||||
/// [MessageListCore] is a simplified class that allows fetching a list of messages while exposing UI builders.
|
/// [MessageListCore] is a simplified class that allows fetching a list of messages while exposing UI builders.
|
||||||
/// A [MessageListController] is used to paginate data.
|
/// A [MessageListController] is used to paginate data.
|
||||||
///
|
///
|
||||||
@@ -89,7 +84,7 @@ class MessageListCore extends StatefulWidget {
|
|||||||
/// Callback triggered when an error occurs while performing the given request.
|
/// Callback triggered when an error occurs while performing the given request.
|
||||||
/// This parameter can be used to display an error message to users in the event
|
/// This parameter can be used to display an error message to users in the event
|
||||||
/// of a connection failure.
|
/// of a connection failure.
|
||||||
final StreamErrorBuilder errorWidgetBuilder;
|
final ErrorBuilder errorWidgetBuilder;
|
||||||
|
|
||||||
/// If true will show a scroll to bottom message when there are new messages and the scroll offset is not zero
|
/// If true will show a scroll to bottom message when there are new messages and the scroll offset is not zero
|
||||||
final bool showScrollToBottom;
|
final bool showScrollToBottom;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stream_chat/stream_chat.dart';
|
import 'package:stream_chat/stream_chat.dart';
|
||||||
|
import 'package:stream_chat_flutter_core/src/typedef.dart';
|
||||||
import 'message_search_bloc.dart';
|
import 'message_search_bloc.dart';
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -82,7 +83,7 @@ class MessageSearchListCore extends StatefulWidget {
|
|||||||
final WidgetBuilder emptyBuilder;
|
final WidgetBuilder emptyBuilder;
|
||||||
|
|
||||||
/// The builder that will be used in case of error
|
/// The builder that will be used in case of error
|
||||||
final Widget Function(Error error) errorBuilder;
|
final ErrorBuilder errorBuilder;
|
||||||
|
|
||||||
/// The builder that will be used in case of loading
|
/// The builder that will be used in case of loading
|
||||||
final WidgetBuilder loadingBuilder;
|
final WidgetBuilder loadingBuilder;
|
||||||
@@ -125,7 +126,7 @@ class _MessageSearchListCoreState extends State<MessageSearchListCore> {
|
|||||||
print((snapshot.error as Error).stackTrace);
|
print((snapshot.error as Error).stackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
return widget.errorBuilder(snapshot.error);
|
return widget.errorBuilder(context, snapshot.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!snapshot.hasData) {
|
if (!snapshot.hasData) {
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// A signature for a callback which exposes an error and returns a function.
|
||||||
|
/// This Callback can be used in cases where an API failure occurs and the widget
|
||||||
|
/// is unable to render data.
|
||||||
|
typedef ErrorBuilder = Widget Function(BuildContext context, Object error);
|
||||||
Reference in New Issue
Block a user