Created
September 30, 2025 14:16
-
-
Save rena2019/4e47dae5cec12db0459d0386f17982ac to your computer and use it in GitHub Desktop.
Figma button with shadow
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
| import 'package:flutter/material.dart'; | |
| //figma button with shadow | |
| void main() { | |
| runApp(MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| MyApp({super.key}); | |
| double buttonWidthHeight = 170; | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| debugShowCheckedModeBanner: false, | |
| home: Scaffold(body: Center(child: | |
| ///////////////////////// | |
| Container( | |
| width: buttonWidthHeight, | |
| height: buttonWidthHeight, | |
| decoration: BoxDecoration( | |
| //add | |
| shape: BoxShape.circle, | |
| boxShadow: [ | |
| BoxShadow( | |
| color: Color(0x0E000000), | |
| blurRadius: 1.74, | |
| offset: Offset(0, 1.66), | |
| spreadRadius: 0, | |
| ), BoxShadow( | |
| color: Color(0x14000000), | |
| blurRadius: 4.19, | |
| offset: Offset(0, 3.99), | |
| spreadRadius: 0, | |
| ), BoxShadow( | |
| color: Color(0x19000000), | |
| blurRadius: 7.89, | |
| offset: Offset(0, 7.51), | |
| spreadRadius: 0, | |
| ), BoxShadow( | |
| color: Color(0x1E000000), | |
| blurRadius: 14.07, | |
| offset: Offset(0, 13.40), | |
| spreadRadius: 0, | |
| ), BoxShadow( | |
| color: Color(0x24000000), | |
| blurRadius: 26.32, | |
| offset: Offset(0, 25.07), | |
| spreadRadius: 0, | |
| ), BoxShadow( | |
| color: Color(0x33000000), | |
| blurRadius: 63, | |
| offset: Offset(0, 60), | |
| spreadRadius: 0, | |
| ) | |
| ], | |
| ), | |
| child: Stack( | |
| children: [ | |
| Positioned( | |
| left: 0, | |
| top: 0, | |
| child: Container( | |
| width: buttonWidthHeight, | |
| height: buttonWidthHeight, | |
| child: Stack( | |
| children: [ | |
| //layer1 runder dunkelgrauer aussen rand mit X (das von layer 2 überlagert wird) | |
| Positioned( | |
| left: 0, | |
| top: 0, | |
| child: Opacity( | |
| opacity: 0.70, | |
| child: Container( | |
| width: buttonWidthHeight, | |
| height: buttonWidthHeight, | |
| decoration: ShapeDecoration( | |
| image: DecorationImage( | |
| image: NetworkImage("https://ui-avatars.com/api/?rounded=true&background=ffffff&name=X"), | |
| fit: BoxFit.cover, | |
| ), | |
| shape: OvalBorder( | |
| side: BorderSide( | |
| width: 3, | |
| strokeAlign: BorderSide.strokeAlignOutside, | |
| color: const Color(0xFF5D636C), | |
| ), | |
| ), | |
| ), | |
| ), | |
| ), | |
| ),//*/ | |
| // layer 2: button rund mit O | |
| Positioned( | |
| left: 0, | |
| top: 0, | |
| child: Container( | |
| width: buttonWidthHeight, | |
| height: buttonWidthHeight, | |
| decoration: ShapeDecoration( | |
| image: DecorationImage( | |
| image: NetworkImage("https://ui-avatars.com/api/?rounded=true&background=c0c0c0&name=O"), | |
| fit: BoxFit.cover, | |
| ), | |
| shape: OvalBorder( | |
| side: BorderSide( | |
| width: 0.50, | |
| strokeAlign: BorderSide.strokeAlignOutside, | |
| color: Colors.black.withValues(alpha: 0.60), | |
| ), | |
| ), | |
| ), | |
| ), | |
| ), | |
| //layer 3: inner button O im eckigen/runden grau | |
| Positioned( | |
| left: buttonWidthHeight/4, | |
| top: buttonWidthHeight/4, | |
| child: Container( | |
| width: buttonWidthHeight/2, | |
| height: buttonWidthHeight/2, | |
| clipBehavior: Clip.antiAlias, | |
| decoration: BoxDecoration( | |
| shape: BoxShape.circle, | |
| boxShadow: [ | |
| BoxShadow( | |
| color: Color(0x7AFFFFFF), | |
| blurRadius: 0, | |
| offset: Offset(0, 0.50), | |
| spreadRadius: 0, | |
| ) | |
| ], | |
| ), | |
| child: Stack(), | |
| ), | |
| ), | |
| ], | |
| ), | |
| ), | |
| ), | |
| ], | |
| ), | |
| ) | |
| ///////////////////////// | |
| )), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment