-
-
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), | |
), | |
), | |
); | |
}); | |
} | |
} |
I meant short paragraphs of texts .I just wanted to added 3-4 lines of paragraphs inside the folded card
Check again and tell me is this what you want? if you want longer text and string in the folded card then just add inside subtitle field.
Thank you very much for this post .
How can I do proper indexing to below code .PLEASE HELP ME IF YOU ARE FREE
`import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
class ImageTile extends StatefulWidget {
@OverRide
_ImageTileState createState() => _ImageTileState();
}
class _ImageTileState extends State {
@OverRide
Widget build(BuildContext context) {
final List txtList = [
'title 1' ,
'title 2' ,
'title 3' ,
'title 4' ,
'title 5' ,
'title 6' ,
'title 7' ,
'title 8' ,
'title 9' ,
'title 10' ,
];
final List txtList1 = [
'subtitle 1' ,
'subtitle 2' ,
'subtitle 3' ,
'subtitle 4' ,
'subtitle 5' ,
'subtitle 6' ,
'subtitle 7' ,
'subtitle 8' ,
'subtitle 9' ,
'subtitle 10' ,
];
final icons = [
Icons.directions_bike,
Icons.directions_boat,
Icons.directions_bus,
Icons.directions_car,
Icons.directions_railway,
Icons.directions_run,
Icons.directions_subway,
Icons.directions_transit,
Icons.directions_walk,
Icons.accessibility
];
functionOne() {
Navigator.push(
context, new MaterialPageRoute(builder: (context) => new RamOne()));
}
functionTwo() {
Navigator.push(context, MaterialPageRoute(builder: (context) => RamTwo()));
}
functionThree() {
Navigator.push(
context, MaterialPageRoute(builder: (context) => RamThree()));
}
functionFour() {
Navigator.push(context, MaterialPageRoute(builder: (context) => RamFour()));
}
functionFive() {
Navigator.push(context, MaterialPageRoute(builder: (context) => RamFive()));
}
functionSix() {
Navigator.push(
context, new MaterialPageRoute(builder: (context) => new RamSix()));
}
functionSeven() {
Navigator.push(context, MaterialPageRoute(builder: (context) => RamSeven()));
}
functionEight() {
Navigator.push(
context, MaterialPageRoute(builder: (context) => RamEight()));
}
functionNine() {
Navigator.push(context, MaterialPageRoute(builder: (context) => RamNine()));
}
functionTen() {
Navigator.push(context, MaterialPageRoute(builder: (context) => RamTen()));
}
final List<Function> onTaps = [
functionOne,
functionTwo,
functionThree,
functionFour,
functionFive,
functionSix,
functionSeven,
functionEight,
functionNine,
functionTen,
];
return Scaffold(
body: StaggeredGridView.count(
crossAxisCount: 2,
crossAxisSpacing: 12.0,
mainAxisSpacing: 12.0,
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
children: <Widget>[
_buildTile(
Padding(
padding: const EdgeInsets.all(24.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(txtList[index],
//'Total Views',
style: TextStyle(color: Colors.blueAccent)),
Text(
txtList1[index],
//'265K',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontSize: 34.0))
],
),
Material(
color: Colors.blue,
borderRadius: BorderRadius.circular(24.0),
child: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Icon( icons[index]),
// Icons.timeline,
// color: Colors.white, size: 30.0),
)))
]),
),
),
],
staggeredTiles: [
StaggeredTile.extent(2, 220.0),
StaggeredTile.extent(2, 220.0),
StaggeredTile.extent(2, 220.0),
StaggeredTile.extent(2, 220.0),
StaggeredTile.extent(2, 220.0),
StaggeredTile.extent(2, 220.0),
StaggeredTile.extent(2, 220.0),
StaggeredTile.extent(2, 220.0),
StaggeredTile.extent(2, 220.0),
StaggeredTile.extent(2, 220.0),
],
));
}
Widget _buildTile(Widget child, {Function() onTap}) {
return Material(
elevation: 14.0,
borderRadius: BorderRadius.circular(12.0),
shadowColor: Color(0x802196F3),
child: InkWell(
onTap:() => ontaps[index](),
child: child));
}
}
`
I have asked this same question in stackoverflow https://stackoverflow.com/questions/59004532/index-flutter-grid-view
please help me ...
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
Hi, Please explain what is 'short contents' do you mean you want to add more widgets in it?