Skip to content

Instantly share code, notes, and snippets.

@pinkeshdarji
Created June 25, 2021 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinkeshdarji/afd1c0934ffd2a38a264e71d0325c701 to your computer and use it in GitHub Desktop.
Save pinkeshdarji/afd1c0934ffd2a38a264e71d0325c701 to your computer and use it in GitHub Desktop.
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