-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class ExpandableText extends StatefulWidget { | ||
const ExpandableText({ | ||
Key? key, | ||
required this.text, | ||
}) : super(key: key); | ||
|
||
final String text; | ||
|
||
@override | ||
_ExpandableTextState createState() => _ExpandableTextState(); | ||
} | ||
|
||
class _ExpandableTextState extends State<ExpandableText> { | ||
bool _isExpanded = false; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (_isExpanded) { | ||
return Card( | ||
child: Padding( | ||
padding: const EdgeInsets.all(15.0), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Text( | ||
widget.text, | ||
softWrap: true, | ||
), | ||
IconButton( | ||
onPressed: onPressed, | ||
icon: const Icon(Icons.keyboard_arrow_up, size: 50)), | ||
], | ||
), | ||
)); | ||
} | ||
|
||
return Stack(alignment: Alignment.bottomCenter, children: [ | ||
Card( | ||
child: Container( | ||
padding: const EdgeInsets.only(top: 15, left: 15, right: 15), | ||
height: 100, | ||
child: Text( | ||
widget.text, | ||
overflow: TextOverflow.fade, | ||
maxLines: 3, | ||
softWrap: true, | ||
))), | ||
Positioned( | ||
bottom: 10, | ||
child: IconButton( | ||
onPressed: onPressed, | ||
icon: const Icon(Icons.keyboard_arrow_down, size: 50))) | ||
]); | ||
} | ||
|
||
void onPressed() { | ||
setState(() { | ||
_isExpanded = !_isExpanded; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters