-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.dart
107 lines (103 loc) · 3.33 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import 'package:flutter/material.dart';
import 'package:gradient_elevated_button/gradient_elevated_button.dart';
import 'package:gradient_elevated_button/inherited/gradient_elevated_theme_data.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return GradientButtonThemeData(
data: GradientElevatedButton.styleFrom(
gradient: const LinearGradient(
colors: [Colors.blue, Colors.green],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
foregroundColor: Colors.black,
),
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Gradient Elevated Button',
theme: ThemeData(
primarySwatch: Colors.blue,
colorScheme: const ColorScheme.light(
primary: Color.fromARGB(255, 166, 206, 57),
secondary: Color.fromARGB(255, 0, 175, 173)),
elevatedButtonTheme: ElevatedButtonThemeData(
style: GradientElevatedButton.styleFrom(
gradient: const LinearGradient(
colors: [
Color.fromARGB(255, 227, 17, 60),
Color.fromARGB(255, 0, 175, 173),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
foregroundColor: Colors.red,
side: const BorderSide(),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
),
padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 25),
))),
home: const MyHomePage(),
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({
super.key,
});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Gradient Elevated Button'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GradientElevatedButton(
onPressed: () {
// 255, 166, 206, 57
},
style: GradientElevatedButton.styleFrom(
gradient: const LinearGradient(
colors: [
Colors.red,
Colors.green,
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
padding:
const EdgeInsets.symmetric(vertical: 25, horizontal: 25),
),
child:
const Text("This is Gradient Elevated Button style from UI"),
),
const SizedBox(
height: 50,
),
GradientElevatedButton(
onPressed: () {},
child: const Text("This is Gradient Elevated Button From Theme"),
),
],
),
),
);
}
}