Created
October 20, 2025 13:10
-
-
Save shafayathossain/4d34899844753e223e99de4eac9fd905 to your computer and use it in GitHub Desktop.
Flutter Preview - Example Widget
This file contains hidden or 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
| class SimpleWidget extends StatelessWidget { | |
| final String text; | |
| final IconData icon; | |
| const SimpleWidget({ | |
| super.key, | |
| required this.text, | |
| required this.icon, | |
| }); | |
| @override | |
| Widget build(BuildContext context) { | |
| final isRTL = Directionality.of(context) == TextDirection.rtl; | |
| return LayoutBuilder( | |
| builder: (context, constraints) { | |
| final isWide = constraints.maxWidth > 400; | |
| return Card( | |
| child: Padding( | |
| padding: const EdgeInsets.all(16), | |
| child: Flex( | |
| direction: isWide ? Axis.horizontal : Axis.vertical, | |
| mainAxisSize: isWide ? MainAxisSize.max : MainAxisSize.min, | |
| textDirection: isRTL ? TextDirection.rtl : TextDirection.ltr, | |
| children: [ | |
| Icon(icon, size: isWide ? 32 : 24), | |
| SizedBox(width: 8, height: 8), | |
| Text( | |
| text, | |
| style: Theme.of(context).textTheme.titleSmall, | |
| textAlign: TextAlign.center, | |
| textDirection: isRTL ? TextDirection.rtl : TextDirection.ltr, | |
| ), | |
| ], | |
| ), | |
| ), | |
| ); | |
| }, | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment