notes icon indicating copy to clipboard operation
notes copied to clipboard

flutter OutlineButton border color

Open onmyway133 opened this issue 5 years ago • 3 comments

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") },
    );

onmyway133 avatar Mar 11 '19 08:03 onmyway133

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), ), )

IamAKX avatar Jul 23 '20 20:07 IamAKX

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
          ),
        )));
  }
}

msgtobala avatar Aug 04 '20 20:08 msgtobala

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))),
    )

F4pl0 avatar Mar 22 '21 17:03 F4pl0