简体   繁体   中英

Weird Black Background in Flutter's OutlineButton Widget

I'm using Flutter's OutlineButton Widget, and I can't figure out how to remove that weird black background highlight when the button is clicked / pressed.

CLICK FOR VIDEO OF ISSUE

This is the button:

OutlineButton(
  highlightElevation: 1.0,
  onPressed: () => onRequestAllowLocation(context),
  child: Text(
    "ALLOW LOCATION",
    style: TextStyle(fontWeight: FontWeight.w600, fontSize: 16),
  ),
  borderSide: BorderSide(color: MyApp.accentColor, width: 2.0),
  textColor: MyApp.accentColor,
  shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(16.0))),
)

And here's the app's theme:

ThemeData(
  fontFamily: 'Dosis',
  brightness: Brightness.dark,
  primarySwatch: Colors.blue,
  accentColor: accentColor,
  highlightColor: highlightColor,
  buttonColor: accentColor,
  indicatorColor: accentColor,
  backgroundColor: primaryColor,
  scaffoldBackgroundColor: primaryColor,
  primaryColor: primaryColor,
)

PS None of the const colors I provide above are black.

It's the shadow. Stop setting highlightElevation and it will go away. From OutlineButton class docs :

The button's highlightElevation, which defines the size of the drop shadow when the button is pressed, is 0.0 (no shadow) by default. If highlightElevation is given a value greater than 0.0 then the button becomes a cross between RaisedButton and FlatButton: a bordered button whose elevation increases and whose background becomes opaque when the button is pressed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM