Professional Documents
Culture Documents
flutter:
sdk: flutter
flutter_slidable: ^0.6.0
Slidable(
actionPane: SlidableDrawerActionPane(),
actionExtentRatio: 0.25,
child: Container(
color: Colors.white,
child: ListTile(
leading: CircleAvatar(
backgroundColor: Colors.indigoAccent,
child: Text('$3'),
foregroundColor: Colors.white,
),
subtitle: Text('SlidableDrawerDelegate'),
),
),
actions: <Widget>[
IconSlideAction(
caption: 'Archive',
color: Colors.blue,
icon: Icons.archive,
IconSlideAction(
caption: 'Share',
color: Colors.indigo,
icon: Icons.share,
),
],
secondaryActions: <Widget>[
IconSlideAction(
caption: 'More',
color: Colors.black45,
icon: Icons.more_horiz,
),
IconSlideAction(
caption: 'Delete',
color: Colors.red,
icon: Icons.delete,
),
],
);
import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
void main() {
runApp(
MaterialApp(
home: MyApp(),
);
@override
@override
void initState() {
//adding item to list, you can add using json from network
@override
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.redAccent,
),
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.all(10),
child: Column(
children: persons.map((personone){
// you have to set key, other wise, after removing item from list, -
actionPane: SlidableDrawerActionPane(),
actionExtentRatio: 0.15,
ElevatedButton(
child: Icon(Icons.phone),
onPressed: (){
//action for phone call
},
),
],
child: Card(
child:ListTile(
title: Text(personone.name),
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(
primary: Colors.redAccent
),
child: Icon(Icons.delete),
onPressed: (){
persons.removeWhere((element){
}); //go through the loop and match content to delete from list
setState(() {
//refresh UI after deleting element from list
});
},
),
],
);
}).toList(),
),
),
);