Skip to content

Instantly share code, notes, and snippets.

@SouravKumarPandit
Created June 13, 2019 04:36
Show Gist options
  • Save SouravKumarPandit/a6c6066b41c135ba148295c4546552a2 to your computer and use it in GitHub Desktop.
Save SouravKumarPandit/a6c6066b41c135ba148295c4546552a2 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
typedef Widget CLListItemBuilder(BuildContext context, String itemString);
class CLCustomItemRow extends StatefulWidget {
final CLListItemBuilder clListItemBuilder;
final Widget child;
final List<String> itemList;
CLCustomItemRow({
@required this.clListItemBuilder,
@required this.itemList = const [],
this.child,
});
@override
CustomItemRow createState() {
return CustomItemRow();
}
}
class CustomItemRow extends State<CLCustomItemRow> {
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.all(8.0),
child: InkWell(
onTap: (){},
child: Column(
children: <Widget>[
getItemRow(widget.itemList[0], widget.itemList[1], 1),
getItemRow(widget.itemList[2], widget.itemList[3], 2),
Divider(
color: Theme.of(context).primaryColor,
)
],
),
),
);
}
Row getItemRow(String s1, String s2, int iColumNo) {
return Row(
children: <Widget>[
Expanded(
child: Text(
s1 ?? '',
style: iColumNo == 1
? TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 16)
: TextStyle(color: Colors.grey, fontSize: 14),
maxLines: 2,
),
flex: 6,
),
Expanded(
flex: 1,
child: Container(),
),
Expanded(
flex: 3,
child: Text(
s2 ?? '',
textAlign: TextAlign.end,
style: TextStyle(
color: Colors.grey, fontWeight: FontWeight.bold, fontSize: 12),
),
)
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment