Created
June 25, 2021 07:03
-
-
Save pinkeshdarji/afd1c0934ffd2a38a264e71d0325c701 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MessageListView( | |
messageBuilder: _messageBuilder, | |
) | |
----------- | |
Widget _messageBuilder( | |
BuildContext context, | |
MessageDetails details, | |
List<Message> messages, | |
) { | |
Message message = details.message; | |
final isCurrentUser = StreamChat. | |
(context).user.id == message.user.id; | |
final textAlign = isCurrentUser ? TextAlign.right : TextAlign.left; | |
final color = isCurrentUser ? Colors. | |
: Colors. | |
; | |
return FutureBuilder<String>( | |
future: AppE2EE().decrypt(message.text), // a Future<String> or null | |
builder: (BuildContext context, AsyncSnapshot<String> snapshot) { | |
switch (snapshot.connectionState) { | |
case ConnectionState.none: | |
case ConnectionState.waiting: | |
default: | |
if (snapshot.hasError) | |
return Text('Error: ${snapshot.error}'); | |
else | |
return Padding( | |
padding: EdgeInsets.all(5.0), | |
child: Container( | |
decoration: BoxDecoration( | |
border: Border.all(color: color, width: 1), | |
borderRadius: BorderRadius.all( | |
Radius.circular(5.0), | |
), | |
), | |
child: ListTile( | |
title: Text( | |
snapshot.data, | |
textAlign: textAlign, | |
), | |
), | |
), | |
); | |
} | |
}, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment