Created
July 2, 2025 07:08
-
-
Save Lxxyx/ab06d7c9f23afe4c89a135eb90268b81 to your computer and use it in GitHub Desktop.
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'; | |
| void main() => runApp(const MyApp()); | |
| class MyApp extends StatelessWidget { | |
| const MyApp({super.key}); | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Fancy Button', | |
| debugShowCheckedModeBanner: false, | |
| theme: ThemeData( | |
| colorSchemeSeed: Colors.blue, | |
| ), | |
| home: const MyHomePage(title: 'Fancy Button'), | |
| ); | |
| } | |
| } | |
| class MyHomePage extends StatefulWidget { | |
| final String title; | |
| const MyHomePage({ | |
| super.key, | |
| required this.title, | |
| }); | |
| @override | |
| State<MyHomePage> createState() => _MyHomePageState(); | |
| } | |
| class _MyHomePageState extends State<MyHomePage> { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: Text(widget.title), | |
| ), | |
| body: Center( | |
| child: FancyButton( | |
| onPressed: () { | |
| // Handle button press here | |
| }, | |
| text: 'Fancy Button', | |
| icon: Icons.favorite, | |
| color: Colors.purple, | |
| ), | |
| ), | |
| ); | |
| } | |
| } | |
| class FancyButton extends StatelessWidget { | |
| final VoidCallback onPressed; | |
| final String text; | |
| final IconData icon; | |
| final Color color; | |
| const FancyButton({ | |
| super.key, | |
| required this.onPressed, | |
| required this.text, | |
| required this.icon, | |
| required this.color, | |
| }); | |
| @override | |
| Widget build(BuildContext context) { | |
| return GestureDetector( | |
| onTap: onPressed, | |
| child: Container( | |
| padding: const EdgeInsets.all(16), | |
| decoration: BoxDecoration( | |
| boxShadow: [ | |
| BoxShadow( | |
| color: color.withOpacity(0.5), | |
| spreadRadius: 2, | |
| blurRadius: 10, | |
| ), | |
| ], | |
| color: color, | |
| borderRadius: BorderRadius.circular(10), | |
| ), | |
| child: Row( | |
| mainAxisSize: MainAxisSize.min, | |
| children: [ | |
| Icon( | |
| icon, | |
| color: Colors.white, | |
| ), | |
| const SizedBox(width: 10), | |
| Text( | |
| text, | |
| style: const TextStyle( | |
| color: Colors.white, | |
| fontSize: 18, | |
| fontWeight: FontWeight.bold, | |
| ), | |
| ), | |
| ], | |
| ), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment