Skip to content

Instantly share code, notes, and snippets.

@PanJ
Created September 18, 2017 15:32
Show Gist options
  • Select an option

  • Save PanJ/90e4f1ea815c6767601d9e87711a9bb2 to your computer and use it in GitHub Desktop.

Select an option

Save PanJ/90e4f1ea815c6767601d9e87711a9bb2 to your computer and use it in GitHub Desktop.
Sample Flutter
@override
class ChatMessage extends StatelessWidget {
ChatMessage({this.snapshot, this.animation});
final DataSnapshot snapshot;
final Animation animation;
Widget build(BuildContext context) {
return new SizeTransition(
sizeFactor: new CurvedAnimation(
parent: animation, curve: Curves.easeOut),
axisAlignment: 0.0,
child: new Container(
margin: const EdgeInsets.symmetric(vertical: 10.0),
child: new Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Container(
margin: const EdgeInsets.only(right: 16.0),
child: new CircleAvatar(backgroundImage: new NetworkImage(snapshot.value['senderPhotoUrl'])),
),
new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Text(
snapshot.value['senderName'],
style: Theme.of(context).textTheme.subhead),
new Container(
margin: const EdgeInsets.only(top: 5.0),
child: snapshot.value['imageUrl'] != null ?
new Image.network(
snapshot.value['imageUrl'],
width: 250.0,
) :
new Text(snapshot.value['text']),
),
],
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment