Skip to content

Instantly share code, notes, and snippets.

@bharatmk256
Last active September 8, 2020 11:55
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 bharatmk256/153c2f2fb8cfa16e0a525e7fd28ac078 to your computer and use it in GitHub Desktop.
Save bharatmk256/153c2f2fb8cfa16e0a525e7fd28ac078 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(title: "Twitter Clone", home: MyHomePage());
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Home"),
centerTitle: true,
),
bottomNavigationBar: BottomAppBar(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(
icon: Icon(
Icons.home,
color: Colors.blue,
),
onPressed: () {},
),
IconButton(
icon: Icon(
Icons.search,
color: Colors.black45,
),
onPressed: () {},
),
IconButton(
icon: Icon(
Icons.notifications,
color: Colors.black45,
),
onPressed: () {},
),
IconButton(
icon: Icon(
Icons.mail_outline,
color: Colors.black45,
),
onPressed: () {},
),
],
),
),
body: ListView(
children: [
listOfTweets(),
listOfTweets(),
listOfTweets(),
listOfTweets(),
listOfTweets(),
listOfTweets(),
listOfTweets(),
listOfTweets(),
listOfTweets(),
listOfTweets(),
listOfTweets(),
listOfTweets(),
listOfTweets(),
],
),
);
}
Widget listOfTweets() {
return Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
tweetAvatar(),
tweetBody(),
]);
}
Widget tweetAvatar() {
return Container(
margin: const EdgeInsets.all(10.0),
child: CircleAvatar(
backgroundImage: NetworkImage("https://placeimg.com/480/480/any"),
),
);
}
Widget tweetBody() {
return Expanded(
child: Column(
children: [
Row(
children: [
Container(
margin: const EdgeInsets.only(right: 5.0),
child: Text(
'Flutter',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
),
),
),
Text(
'@FlutterDev * 5m',
style: TextStyle(
color: Colors.grey,
),
),
Spacer(),
IconButton(
icon: Icon(
Icons.keyboard_arrow_down,
size: 14.0,
color: Colors.grey,
),
onPressed: () {},
),
],
),
Text(
"Hello world this is first tweet from flutter dev Hello world this is first tweet from flutter dev Hello world this is first tweet from flutter dev",
overflow: TextOverflow.clip,
),
Container(
margin: const EdgeInsets.only(top: 10.0, right: 20.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
tweetIconButton(Icons.comment, "222"),
tweetIconButton(Icons.repeat, "2k"),
tweetIconButton(Icons.favorite_border, "22k"),
tweetIconButton(Icons.share, ""),
],
),
),
],
),
);
}
Widget tweetIconButton(IconData icon, String text) {
return Row(
children: [
Icon(
icon,
size: 18.0,
color: Colors.black45,
),
Container(
margin: const EdgeInsets.all(6.0),
child: Text(
text,
style: TextStyle(
color: Colors.black45,
fontSize: 14.0,
),
),
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment