migrate error builder callback using typedef
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) {
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,6 +3,7 @@ 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';
|
||||||
|
|
||||||
/// [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.
|
||||||
@@ -83,6 +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 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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user