dismissible_expanded_list 0.2.1 dismissible_expanded_list: ^0.2.1 copied to clipboard
A Flutter package to provided dismissible and expanded list.
import 'package:dismissible_expanded_list/dismissible_expanded_list.dart';
import 'package:dismissible_expanded_list/model/entry.dart';
import 'package:example/mock.dart';
import 'package:flutter/material.dart';
void main() {
runApp(ExpansionTileSample());
}
class ExpansionTileSample extends StatefulWidget {
@override
_ExpansionTileSampleState createState() => _ExpansionTileSampleState();
}
class _ExpansionTileSampleState extends State<ExpansionTileSample> {
String title = 'Not Yet Selected';
String selectedId = '1';
final List<ExpandableListItem> list = mockData;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('ExpansionTile'),
),
body: Row(
children: <Widget>[
Expanded(
flex: 2,
child: Container(
margin: EdgeInsets.only(
left: 5.0, top: 5.0, bottom: 5.0, right: 2.0),
height: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.0)),
child: Text(title),
),
),
Expanded(
flex: 1,
child: ListView.builder(
itemBuilder: (BuildContext context, int index) =>
DismissibleExpandableList(
parentIndex: index,
entry: list[index],
elevation: 3.0,
titleStyle: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
titleSelectedStyle: TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold,
color: Colors.green,
),
subTitleStyle: TextStyle(
color: Colors.blue,
fontSize: 12.0,
),
subTitleSelectedStyle: TextStyle(
color: Colors.green,
fontSize: 12.0,
),
removeTileOnDismiss: false,
allowBatchSwipe: true,
allowChildSwipe: false,
allowParentSelection: true,
showBorder: false,
showInfoBadge: true,
selectedId: selectedId,
rightSwipeColor: Colors.green,
leftSwipeColor: Colors.red,
lineColor: Colors.grey[400],
badgeWidth: 80.0,
selectionColor: Color(0xFFFFE082),
trailingIcon: Icons.info_outline,
onItemClick:
(parentIndex, childIndex, ExpandableListItem item) {
print('onItemClick called');
setState(() {
if (childIndex == -1) {
title = mockData[parentIndex].title;
selectedId = mockData[parentIndex].id;
} else {
selectedId =
mockData[parentIndex].children[childIndex].id;
title =
mockData[parentIndex].children[childIndex].title;
}
});
},
),
itemCount: mockData.length,
),
)
],
),
),
);
}
}