revert typinh indicator to stateless widget
This commit is contained in:
@@ -3,7 +3,7 @@ import 'package:lottie/lottie.dart';
|
|||||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||||
|
|
||||||
/// Widget to show the current list of typing users
|
/// Widget to show the current list of typing users
|
||||||
class TypingIndicator extends StatefulWidget {
|
class TypingIndicator extends StatelessWidget {
|
||||||
/// Instantiate a new TypingIndicator
|
/// Instantiate a new TypingIndicator
|
||||||
const TypingIndicator({
|
const TypingIndicator({
|
||||||
Key? key,
|
Key? key,
|
||||||
@@ -29,21 +29,16 @@ class TypingIndicator extends StatefulWidget {
|
|||||||
/// Alignment of the typing indicator
|
/// Alignment of the typing indicator
|
||||||
final Alignment alignment;
|
final Alignment alignment;
|
||||||
|
|
||||||
@override
|
|
||||||
_TypingIndicatorState createState() => _TypingIndicatorState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _TypingIndicatorState extends State<TypingIndicator> {
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final channelState =
|
final channelState =
|
||||||
widget.channel?.state ?? StreamChannel.of(context).channel.state!;
|
channel?.state ?? StreamChannel.of(context).channel.state!;
|
||||||
|
|
||||||
final altWidget = Align(
|
final altWidget = Align(
|
||||||
key: const Key('alternative'),
|
key: const Key('alternative'),
|
||||||
alignment: widget.alignment,
|
alignment: alignment,
|
||||||
child: Container(
|
child: Container(
|
||||||
child: widget.alternativeWidget ?? const Offstage(),
|
child: alternativeWidget ?? const Offstage(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return BetterStreamBuilder<List<User>>(
|
return BetterStreamBuilder<List<User>>(
|
||||||
@@ -54,10 +49,10 @@ class _TypingIndicatorState extends State<TypingIndicator> {
|
|||||||
child: data.isNotEmpty == true
|
child: data.isNotEmpty == true
|
||||||
? Padding(
|
? Padding(
|
||||||
key: const Key('main'),
|
key: const Key('main'),
|
||||||
padding: widget.padding,
|
padding: padding,
|
||||||
child: Align(
|
child: Align(
|
||||||
key: const Key('typings'),
|
key: const Key('typings'),
|
||||||
alignment: widget.alignment,
|
alignment: alignment,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
@@ -70,7 +65,7 @@ class _TypingIndicatorState extends State<TypingIndicator> {
|
|||||||
// ignore: lines_longer_than_80_chars
|
// ignore: lines_longer_than_80_chars
|
||||||
' ${data[0].name}${data.length == 1 ? '' : ' and ${data.length - 1} more'} ${data.length == 1 ? 'is' : 'are'} typing',
|
' ${data[0].name}${data.length == 1 ? '' : ' and ${data.length - 1} more'} ${data.length == 1 ? 'is' : 'are'} typing',
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
style: widget.style,
|
style: style,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user