Last active
March 30, 2019 20:44
-
-
Save chrislentz/9752cf09120d1c8f5c4f9198402d097f to your computer and use it in GitHub Desktop.
This is the full code sample used in my "Flutter Dismissible (Swipe Left)" example on Instagram.
This file contains hidden or 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
import 'package:flutter/material.dart'; | |
void main() => runApp(ExampleApp()); | |
class ExampleApp extends StatelessWidget { | |
final items = List<String>.generate(20, (i) => "Swipe To The Right"); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
body: ListView.builder( | |
itemCount: items.length, | |
itemBuilder: (context, index) { | |
final item = items[index]; | |
return Dismissible( | |
key: Key(item), | |
background: Container( | |
alignment: AlignmentDirectional.centerStart, | |
color: Color(0xff8fc3ff), | |
child: Padding( | |
padding: EdgeInsets.fromLTRB(0.0, 0.0, 10.0, 0.0), | |
child: Row( | |
children: [ | |
Padding( | |
padding: EdgeInsets.fromLTRB(10.0, 0.0, 5.0, 0.0), | |
child: Icon( | |
Icons.mail, | |
color: Colors.white, | |
size: 18.0, | |
), | |
), | |
Text( | |
'Unread', | |
style: TextStyle( | |
fontSize: 14.0, | |
color: Colors.white, | |
), | |
), | |
], | |
), | |
), | |
), | |
direction: DismissDirection.startToEnd, | |
child: Container( | |
decoration: BoxDecoration( | |
border: Border( | |
bottom: BorderSide( | |
color: Colors.grey, | |
), | |
), | |
), | |
child: ListTile( | |
title: Text('$item'), | |
), | |
), | |
); | |
}, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment