Skip to content

Instantly share code, notes, and snippets.

@mohammedsalem97
Last active December 20, 2019 00:13
Show Gist options
  • Save mohammedsalem97/5d6acee35917e54350eb3b3116a8ac00 to your computer and use it in GitHub Desktop.
Save mohammedsalem97/5d6acee35917e54350eb3b3116a8ac00 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override
build(context) {
return MaterialApp(
theme: ThemeData(
primaryColor: Colors.purple,
),
home: Scaffold(
key: _scaffoldKey,
appBar: AppBar(
elevation: 0.0,
title: Text('Title'),
centerTitle: true,
leading: IconButton(
icon: Icon(Icons.menu),
onPressed: () {
_scaffoldKey.currentState.openDrawer();
},
),
),
drawer: SizedBox(
width: 250.0,
child: Container(
color: Colors.red.withOpacity(0.55),
),
),
body: ListView.builder(
physics: BouncingScrollPhysics(),
itemBuilder: (context, index) {
var _name = index.isOdd ? "Ahmed Abdo" : "Reda Ali";
return Hero(
tag: "$index",
child: Dismissible(
key: Key("$index"),
child: Material(
child: ListTile(
title: Text(_name),
subtitle: Text("He's my friend"),
trailing: Row(mainAxisSize: MainAxisSize.min, children: [
Icon(Icons.thumb_up, color: Colors.blue),
SizedBox(width: 15.0),
Icon(Icons.thumb_down, color: Colors.red)
]),
leading: CircleAvatar(
backgroundColor: index.isOdd ? Colors.red : Colors.blue,
child: Text("${index + 1}"),
),
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => HelloPage(
name: _name,
tag: "$index",
)));
},
),
),
onDismissed: (direction) {
print(" item number $index has been deleted !");
},
background: Container(
color: Colors.red,
),
),
);
},
),
),
);
}
}
class HelloPage extends StatelessWidget {
final String name;
final String tag;
HelloPage({this.name = "Mohammed", this.tag = ""});
@override
build(context) {
return Scaffold(
appBar: AppBar(),
body: Center(
child: Hero(
tag: "${this.tag}",
child: Text("Hello ${this.name} !"),
)),
);
}
}
@mohammedsalem97
Copy link
Author

this simple example of flutter app home page with a ListView.builder containiing ListTiles with title and subtitle and a leading Avatar
and a trailing as a Row with two icons children

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment