Skip to content

Commit 8fd677a

Browse files
committed
transparent button color fixing
1 parent 2bb7eaa commit 8fd677a

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ class _MyHomePageState extends State<MyHomePage> {
170170
onPressed: null,
171171
child: Text("share"),
172172
icon: Icon(Icons.share),
173-
type: GFType.transparent,
174173
shape: GFShape.pills,
174+
type: GFType.transparent,
175175
),
176176
],
177177
),

lib/colors/gf_color.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22

3+
34
enum GFColor {
45
primary,
56
secondary,
@@ -15,6 +16,7 @@ enum GFColor {
1516
transparent
1617
}
1718

19+
1820
const PRIMARY = Color(0xff3f6ad8);
1921
const SECONDARY = Color(0xff6c757c);
2022
const SUCCESS =Color(0xff3ac47c);

lib/components/button/gf_button.dart

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ class GFButton extends StatefulWidget {
116116
/// on true state default box shadow appears around button
117117
final bool buttonBoxShadow;
118118

119+
/// A set of thirteen colors that can be used to derive the button theme's
120+
/// colors.
121+
///
122+
/// This property was added much later than the theme's set of highly
123+
/// specific colors, like [ThemeData.buttonColor], [ThemeData.highlightColor],
124+
/// [ThemeData.splashColor] etc.
125+
///
126+
/// The colors for new button classes can be defined exclusively in terms
127+
/// of [colorScheme]. When it's possible, the existing buttons will
128+
/// (continue to) gradually migrate to it.
129+
final ColorScheme colorScheme;
130+
119131
/// Create buttons of all types. check out [GFIconButton] for icon buttons, and [GFBadge] for badges
120132
const GFButton({
121133
Key key,
@@ -144,7 +156,7 @@ class GFButton extends StatefulWidget {
144156
this.child,
145157
this.type = GFType.solid,
146158
this.shape = GFShape.standard,
147-
this.color = GFColor.primary,
159+
this.color,
148160
this.textColor = GFColor.dark,
149161
this.position = GFPosition.start,
150162
this.size = GFSize.medium,
@@ -153,6 +165,7 @@ class GFButton extends StatefulWidget {
153165
this.icon,
154166
this.blockButton,
155167
this.fullWidthButton,
168+
this.colorScheme,
156169
}) : materialTapTargetSize =
157170
materialTapTargetSize ?? MaterialTapTargetSize.padded,
158171
assert(shape != null, 'Button shape can not be null'),
@@ -333,7 +346,6 @@ class _GFButtonState extends State<GFButton> {
333346
borderRadius: BorderRadius.circular(50.0), side: shapeBorder);
334347
}
335348

336-
337349
return Semantics(
338350
container: true,
339351
button: true,
@@ -368,9 +380,9 @@ class _GFButtonState extends State<GFButton> {
368380
),
369381
child: Material(
370382
textStyle: widget.textStyle == null ? TextStyle(color: this.textColor, fontSize: 14) : widget.textStyle,
371-
shape: widget.type == GFType.transparent ? null : widget.borderShape== null ? shape : widget.borderShape,
372-
color: widget.type != GFType.outline || widget.type == null ? this.color : Theme.of(context).canvasColor,
373-
type: widget.type == GFType.transparent ? MaterialType.transparency : MaterialType.button,
383+
shape: widget.type == GFType.transparent ? null : widget.borderShape == null ? shape : widget.borderShape,
384+
color: widget.type != GFType.transparent ? this.color : null,
385+
// type: widget.type == GFType.transparent ? null : MaterialType.button,
374386
animationDuration: widget.animationDuration,
375387
clipBehavior: widget.clipBehavior,
376388
child: InkWell(

0 commit comments

Comments
 (0)