notes
notes copied to clipboard
flutter OutlineButton border color
Setting borderSide and shape has no effect, until I add onPress handler
return OutlineButton(
child: Row(
children: <Widget>[
Image.asset('res/images/google.png', width: 30, height: 30),
Text('Login with Google', style: TextStyle(color: Colors.white))
]
),
borderSide: BorderSide(width: 2.0, color: Colors.white),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
onPressed: () => { print("hello world") },
);
Same code worked for me
OutlineButton( onPressed: () { chosenTime = 15; }, borderSide: BorderSide(width: 1.0, color: THEME_COLOR), child: Text( '15 Min', style: TextStyle(fontSize: 12), ), )
Use BorderSide will help
import 'package:flutter/material.dart';
class BorderColorButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Border Color Button Example'),
),
body: Center(
child: OutlineButton(
child: Text('Button to Click'),
onPressed: () {}, //callback when button is clicked
borderSide: BorderSide(
color: Colors.red, //Color of the border
style: BorderStyle.solid, //Style of the border
width: 0.8, //width of the border
),
)));
}
}
This solved for me for some reason, this is in flutter 1.24.0-10.2.pre (beta, linux)
everything had to be wrapped in OutlinedButton.styleFrom
in style
of a OutlinedButton
, because latest version of Flutter seems to have removed all styling attributes from the core OutlinedButton
OutlinedButton(
child: Text("Test button", style: TextStyle(color: Color(0xffffffff))),
style: OutlinedButton.styleFrom(
padding: EdgeInsets.only(top: 16, bottom: 16, left: 28, right: 28),
side: BorderSide(width: 2, color: Color(0xffffffff)),
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(40.0))),
)