import
'package:flutter/material.dart'
;
import
'package:folding_cell/folding_cell.dart'
;
void
main() {
runApp(MaterialApp(
home: RunMyApp(),
debugShowCheckedModeBanner:
false
,
title:
'FoldingCell'
,
theme: ThemeData(primarySwatch: Colors.green),
));
}
class
RunMyApp extends StatelessWidget {
final _foldingCellKey = GlobalKey<SimpleFoldingCellState>();
RunMyApp({super.key});
@override
Widget build(BuildContext context) {
return
Scaffold(
appBar: AppBar(
title: Text(
"Flutter - Folding Cell"
),
),
body: Container(
color: Color.fromARGB(255, 235, 225, 228),
alignment: Alignment.topCenter,
child: SimpleFoldingCell.create(
key: _foldingCellKey,
frontWidget: _buildFrontWidget(),
innerWidget: _buildInnerWidget(),
cellSize: Size(MediaQuery.of(context).size.width, 140),
padding: EdgeInsets.all(15),
animationDuration: Duration(milliseconds: 300),
borderRadius: 10,
onOpen: () => print(
'cell opened'
),
onClose: () => print(
'cell closed'
),
),
),
);
}
Widget _buildFrontWidget() {
return
Container(
color: Color.fromARGB(255, 6, 144, 43),
alignment: Alignment.center,
child: Stack(
children: [
Align(
alignment: Alignment.center,
child: Text(
"Geeks For Geeks"
,
style: TextStyle(
color: Colors.black45,
fontSize: 40,
fontWeight: FontWeight.bold,
),
),
),
Positioned(
right: 10,
bottom: 10,
child: TextButton(
onPressed: () => _foldingCellKey.currentState?.toggleFold(),
child: Text(
"OPEN"
,
),
style: TextButton.styleFrom(
backgroundColor: Colors.white,
minimumSize: Size(80, 40),
),
),
)
],
),
);
}
Widget _buildInnerWidget() {
return
Container(
color: Color.fromARGB(255, 144, 189, 241),
padding: EdgeInsets.only(top: 10),
child: Stack(
children: [
Align(
alignment: Alignment.topCenter,
child: Text(
"Geeks For Geeks"
,
style: TextStyle(
color: Colors.black45,
fontSize: 40,
fontWeight: FontWeight.bold,
),
),
),
Align(
alignment: Alignment.center,
child: Text(
"Hello, How are you"
,
style: TextStyle(
color: Colors.black45,
fontSize: 40,
fontWeight: FontWeight.bold,
),
),
),
Positioned(
right: 10,
bottom: 10,
child: TextButton(
onPressed: () => _foldingCellKey.currentState?.toggleFold(),
child: Text(
"Close"
,
),
style: TextButton.styleFrom(
backgroundColor: Colors.white,
minimumSize: Size(80, 40),
),
),
),
],
),
);
}
}