-
-
Save raviganwal/94b3b2d2e129239f34b912ef202b6641 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart'; | |
import 'package:folding_cell/folding_cell.dart'; | |
void main() => runApp(MaterialApp( | |
home: SafeArea( | |
child: Scaffold(body: Material(child: FoldingCellListViewDemo()))))); | |
class DemoModel { | |
String title, subtitle; | |
DemoModel(this.title, this.subtitle); | |
} | |
/// Example 2 folding cell inside [ListView] | |
class FoldingCellListViewDemo extends StatelessWidget { | |
final List<DemoModel> txtList = [ | |
DemoModel('title 1', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry. Lorem Ipsum has been the industry. Lorem Ipsum has been the industry.'), | |
DemoModel('title 2', 'subtitle 2'), | |
DemoModel('title 3', 'subtitle 3'), | |
DemoModel('title 4', 'subtitle 4'), | |
]; | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
color: Color(0xFF2e282a), | |
child: ListView.builder( | |
itemCount: txtList.length, | |
itemBuilder: (context, index) { | |
DemoModel model = txtList[index]; | |
return SimpleFoldingCell( | |
frontWidget: _buildFrontWidget(model), | |
innerTopWidget: _buildInnerTopWidget(model), | |
innerBottomWidget: _buildInnerBottomWidget(index), | |
cellSize: Size(MediaQuery.of(context).size.width, 125), | |
padding: EdgeInsets.all(15), | |
animationDuration: Duration(milliseconds: 300), | |
borderRadius: 10, | |
onOpen: () => print('$index cell opened'), | |
onClose: () => print('$index cell closed')); | |
}), | |
); | |
} | |
Widget _buildFrontWidget(DemoModel model) { | |
return Builder( | |
builder: (BuildContext context) { | |
return Container( | |
color: Color(0xFFffcd3c), | |
alignment: Alignment.center, | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
Text("${model.title}", | |
style: TextStyle( | |
color: Color(0xFF2e282a), | |
fontFamily: 'OpenSans', | |
fontSize: 20.0, | |
fontWeight: FontWeight.w800)), | |
FlatButton( | |
onPressed: () { | |
SimpleFoldingCellState foldingCellState = | |
context.ancestorStateOfType( | |
TypeMatcher<SimpleFoldingCellState>()); | |
foldingCellState?.toggleFold(); | |
}, | |
child: Text( | |
"Open", | |
), | |
textColor: Colors.white, | |
color: Colors.indigoAccent, | |
splashColor: Colors.white.withOpacity(0.5), | |
) | |
], | |
)); | |
}, | |
); | |
} | |
Widget _buildInnerTopWidget(DemoModel model) { | |
return Container( | |
color: Color(0xFFff9234), | |
alignment: Alignment.center, | |
child: Text("${model.subtitle}", | |
style: TextStyle( | |
color: Color(0xFF2e282a), | |
fontFamily: 'OpenSans', | |
fontSize: 14.0, | |
fontWeight: FontWeight.w400))); | |
} | |
Widget _buildInnerBottomWidget(int index) { | |
return Builder(builder: (context) { | |
return Container( | |
color: Color(0xFFecf2f9), | |
alignment: Alignment.bottomCenter, | |
child: Padding( | |
padding: EdgeInsets.only(bottom: 10), | |
child: FlatButton( | |
onPressed: () { | |
SimpleFoldingCellState foldingCellState = context | |
.ancestorStateOfType(TypeMatcher<SimpleFoldingCellState>()); | |
foldingCellState?.toggleFold(); | |
}, | |
child: Text( | |
"Close", | |
), | |
textColor: Colors.white, | |
color: Colors.indigoAccent, | |
splashColor: Colors.white.withOpacity(0.5), | |
), | |
), | |
); | |
}); | |
} | |
} |
raviganwal
commented
Nov 23, 2019
via email
THIS IS THE CODE OF MY REPO::::- https://github.com/ABINASH56/ghost-app
create a complete repo of your code I will pull it and fix.
…
On Sat, Nov 23, 2019 at 3:21 PM Ram @.***> wrote: I please help me ... — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://gist.github.com/94b3b2d2e129239f34b912ef202b6641?email_source=notifications&email_token=AFKZ2MKRUINZQQPY2FGA22LQVD4JFA5CNFSM4JPE3ZN2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAF4VHU#gistcomment-3091066, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKZ2MI2YQXYVCVQJLP2VRLQVD4JFANCNFSM4JPE3ZNQ .
https://github.com/ABINASH56/ghost-app PLEASE CHECK THIS LINK
Repo link is broken, try to create repo of your complete code so I can run that in one go only