How to set the background color of a Flutter OutlineButton?How do I add a border to a flutter button?Why the Button taking the Container color not his given colorPadding around AppBar in a DefaultTabControllerFlutter : Can I add a Header Row to a ListViewHow to use drawer in Flutter without Scaffold?Scaffold.of() called with a context that does not contain a ScaffoldFlutter : Bad state: Stream has already been listened toHow to use Drawer without Scaffold.drawer?Creating a variable with an onTap navigator flutterHow to set background color for an icon button?How I can put Widget above Widget using List<Widget> widget in Flutter?How to make Flutter DropDownButton's items window scrollable?
Marketing Cloud SMS to Service Cloud Case
How to say "fit" in Latin?
Did WWII Japanese soldiers engage in cannibalism of their enemies?
Short story about a teenager who has his brain replaced with a microchip (Psychological Horror)
Why does Intel's Haswell chip allow multiplication to be twice as fast as addition?
How to realistically deal with a shield user?
Is there a loss of quality when converting RGB to HEX?
Could one become a successful researcher by writing some really good papers while being outside academia?
What are good ways to improve as a writer other than writing courses?
How do I explain to a team that the project they will work on for six months will 100% fail?
Does this put me at risk for identity theft?
Why is there a need to prevent a racist, sexist, or otherwise bigoted vendor from discriminating who they sell to?
Team goes to lunch frequently, I do intermittent fasting but still want to socialize
Why was CPU32 core created, and how is it different from 680x0 CPU cores?
Egalitarian references in Chazal
How quickly could a country build a tall concrete wall around a city?
How does The Fools Guild make its money?
Need help understanding lens reach
Should I take out a personal loan to pay off credit card debt?
Sets A such that A+A contains the largest set [0,1,..,t]
Traveling from Germany to other countries by train?
In a topological space if there exists a loop that cannot be contracted to a point does there exist a simple loop that cannot be contracted also?
Can a PC attack themselves with an unarmed strike?
Arrange a list in ascending order by deleting list elements
How to set the background color of a Flutter OutlineButton?
How do I add a border to a flutter button?Why the Button taking the Container color not his given colorPadding around AppBar in a DefaultTabControllerFlutter : Can I add a Header Row to a ListViewHow to use drawer in Flutter without Scaffold?Scaffold.of() called with a context that does not contain a ScaffoldFlutter : Bad state: Stream has already been listened toHow to use Drawer without Scaffold.drawer?Creating a variable with an onTap navigator flutterHow to set background color for an icon button?How I can put Widget above Widget using List<Widget> widget in Flutter?How to make Flutter DropDownButton's items window scrollable?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
class _HomePageState extends State<HomePage>
@override
Widget build(BuildContext context)
return Scaffold(
appBar: AppBar(
title: Text("..."),
),
body: Container(
color: Colors.green,
child: OutlineButton(
onPressed: () ,
color: Colors.orange,
highlightColor: Colors.pink,
child: Container(
color: Colors.yellow,
child: Text("A"),
),
shape: CircleBorder(),
),
),
);
The above code gives a transparent button. How can I get an orange OutlineButton?
flutter material-ui
add a comment |
class _HomePageState extends State<HomePage>
@override
Widget build(BuildContext context)
return Scaffold(
appBar: AppBar(
title: Text("..."),
),
body: Container(
color: Colors.green,
child: OutlineButton(
onPressed: () ,
color: Colors.orange,
highlightColor: Colors.pink,
child: Container(
color: Colors.yellow,
child: Text("A"),
),
shape: CircleBorder(),
),
),
);
The above code gives a transparent button. How can I get an orange OutlineButton?
flutter material-ui
Please Visit following link I think it is related to your problem...
– Faiz Fareed
Mar 27 at 7:25
add a comment |
class _HomePageState extends State<HomePage>
@override
Widget build(BuildContext context)
return Scaffold(
appBar: AppBar(
title: Text("..."),
),
body: Container(
color: Colors.green,
child: OutlineButton(
onPressed: () ,
color: Colors.orange,
highlightColor: Colors.pink,
child: Container(
color: Colors.yellow,
child: Text("A"),
),
shape: CircleBorder(),
),
),
);
The above code gives a transparent button. How can I get an orange OutlineButton?
flutter material-ui
class _HomePageState extends State<HomePage>
@override
Widget build(BuildContext context)
return Scaffold(
appBar: AppBar(
title: Text("..."),
),
body: Container(
color: Colors.green,
child: OutlineButton(
onPressed: () ,
color: Colors.orange,
highlightColor: Colors.pink,
child: Container(
color: Colors.yellow,
child: Text("A"),
),
shape: CircleBorder(),
),
),
);
The above code gives a transparent button. How can I get an orange OutlineButton?
flutter material-ui
flutter material-ui
asked Mar 27 at 6:19
ohhoohho
31.4k64 gold badges222 silver badges355 bronze badges
31.4k64 gold badges222 silver badges355 bronze badges
Please Visit following link I think it is related to your problem...
– Faiz Fareed
Mar 27 at 7:25
add a comment |
Please Visit following link I think it is related to your problem...
– Faiz Fareed
Mar 27 at 7:25
Please Visit following link I think it is related to your problem...
– Faiz Fareed
Mar 27 at 7:25
Please Visit following link I think it is related to your problem...
– Faiz Fareed
Mar 27 at 7:25
add a comment |
3 Answers
3
active
oldest
votes
To modify the backgroundColor of a OutlineButton you can use a DecoratedBox and a Theme widget. At the end of this answer you'll find a quick example.
Anyway I'd still recommend simply using the FlatButton with its color
attribute instead.
Wrap your OutlinedButton
inside a DecoratedBox
. Set the shape
of your DecoratedBox
to the same shape your OutlinedButton
. Now you can use the color
attribute of your DecoratedBox
to change the color. The result will still have a small padding around the OutlinedButton
. To remove this you can wrap the DecoratedBox
inside a Theme
in which you adjust the ButtonTheme
. Inside the ButtonTheme
you want to set materialTapTargetSize: MaterialTapTargetSize.shrinkWrap
.
The padding is added inside Flutter, to increase the tap area around the button to a minimum size of 48x48 (source). Setting materialTapTargetSize
to MaterialTapTargetSize.shrinkWrap
removes this minimum size.
FlatButton
example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
home: Scaffold(
body: Center(
child: FlatButton(
color: Colors.pinkAccent,
shape: CircleBorder(),
onPressed: () => ,
child: Text('A'),
),
),
),
);
OutlinedButton
example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
home: Scaffold(
body: Center(
child: MyButton(),
),
),
);
class MyButton extends StatelessWidget
@override
Widget build(BuildContext context)
return DecoratedBox(
decoration:
ShapeDecoration(shape: CircleBorder(), color: Colors.pinkAccent),
child: Theme(
data: Theme.of(context).copyWith(
buttonTheme: ButtonTheme.of(context).copyWith(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap)),
child: OutlineButton(
shape: CircleBorder(),
child: Text('A'),
onPressed: () => ,
),
),
);
I added aFlatButton
example, which I'd recommend because it is way more simple.
– Niklas
Mar 27 at 8:44
add a comment |
Here's way that you can check the background color of the button.
Remove hightlightColor, and try give some value to highlightElevation property of OutlineButton, then press it, you could see initially it loads orange color.
I think OutlineButton seems have its original behavior and hard to configure it. Essentially OutlineButton extends MaterialButton, so why don't you try out MaterialButton instead?
– dyGi
Mar 27 at 6:57
add a comment |
You could use FlatButton, and just set color there.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370952%2fhow-to-set-the-background-color-of-a-flutter-outlinebutton%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
To modify the backgroundColor of a OutlineButton you can use a DecoratedBox and a Theme widget. At the end of this answer you'll find a quick example.
Anyway I'd still recommend simply using the FlatButton with its color
attribute instead.
Wrap your OutlinedButton
inside a DecoratedBox
. Set the shape
of your DecoratedBox
to the same shape your OutlinedButton
. Now you can use the color
attribute of your DecoratedBox
to change the color. The result will still have a small padding around the OutlinedButton
. To remove this you can wrap the DecoratedBox
inside a Theme
in which you adjust the ButtonTheme
. Inside the ButtonTheme
you want to set materialTapTargetSize: MaterialTapTargetSize.shrinkWrap
.
The padding is added inside Flutter, to increase the tap area around the button to a minimum size of 48x48 (source). Setting materialTapTargetSize
to MaterialTapTargetSize.shrinkWrap
removes this minimum size.
FlatButton
example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
home: Scaffold(
body: Center(
child: FlatButton(
color: Colors.pinkAccent,
shape: CircleBorder(),
onPressed: () => ,
child: Text('A'),
),
),
),
);
OutlinedButton
example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
home: Scaffold(
body: Center(
child: MyButton(),
),
),
);
class MyButton extends StatelessWidget
@override
Widget build(BuildContext context)
return DecoratedBox(
decoration:
ShapeDecoration(shape: CircleBorder(), color: Colors.pinkAccent),
child: Theme(
data: Theme.of(context).copyWith(
buttonTheme: ButtonTheme.of(context).copyWith(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap)),
child: OutlineButton(
shape: CircleBorder(),
child: Text('A'),
onPressed: () => ,
),
),
);
I added aFlatButton
example, which I'd recommend because it is way more simple.
– Niklas
Mar 27 at 8:44
add a comment |
To modify the backgroundColor of a OutlineButton you can use a DecoratedBox and a Theme widget. At the end of this answer you'll find a quick example.
Anyway I'd still recommend simply using the FlatButton with its color
attribute instead.
Wrap your OutlinedButton
inside a DecoratedBox
. Set the shape
of your DecoratedBox
to the same shape your OutlinedButton
. Now you can use the color
attribute of your DecoratedBox
to change the color. The result will still have a small padding around the OutlinedButton
. To remove this you can wrap the DecoratedBox
inside a Theme
in which you adjust the ButtonTheme
. Inside the ButtonTheme
you want to set materialTapTargetSize: MaterialTapTargetSize.shrinkWrap
.
The padding is added inside Flutter, to increase the tap area around the button to a minimum size of 48x48 (source). Setting materialTapTargetSize
to MaterialTapTargetSize.shrinkWrap
removes this minimum size.
FlatButton
example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
home: Scaffold(
body: Center(
child: FlatButton(
color: Colors.pinkAccent,
shape: CircleBorder(),
onPressed: () => ,
child: Text('A'),
),
),
),
);
OutlinedButton
example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
home: Scaffold(
body: Center(
child: MyButton(),
),
),
);
class MyButton extends StatelessWidget
@override
Widget build(BuildContext context)
return DecoratedBox(
decoration:
ShapeDecoration(shape: CircleBorder(), color: Colors.pinkAccent),
child: Theme(
data: Theme.of(context).copyWith(
buttonTheme: ButtonTheme.of(context).copyWith(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap)),
child: OutlineButton(
shape: CircleBorder(),
child: Text('A'),
onPressed: () => ,
),
),
);
I added aFlatButton
example, which I'd recommend because it is way more simple.
– Niklas
Mar 27 at 8:44
add a comment |
To modify the backgroundColor of a OutlineButton you can use a DecoratedBox and a Theme widget. At the end of this answer you'll find a quick example.
Anyway I'd still recommend simply using the FlatButton with its color
attribute instead.
Wrap your OutlinedButton
inside a DecoratedBox
. Set the shape
of your DecoratedBox
to the same shape your OutlinedButton
. Now you can use the color
attribute of your DecoratedBox
to change the color. The result will still have a small padding around the OutlinedButton
. To remove this you can wrap the DecoratedBox
inside a Theme
in which you adjust the ButtonTheme
. Inside the ButtonTheme
you want to set materialTapTargetSize: MaterialTapTargetSize.shrinkWrap
.
The padding is added inside Flutter, to increase the tap area around the button to a minimum size of 48x48 (source). Setting materialTapTargetSize
to MaterialTapTargetSize.shrinkWrap
removes this minimum size.
FlatButton
example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
home: Scaffold(
body: Center(
child: FlatButton(
color: Colors.pinkAccent,
shape: CircleBorder(),
onPressed: () => ,
child: Text('A'),
),
),
),
);
OutlinedButton
example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
home: Scaffold(
body: Center(
child: MyButton(),
),
),
);
class MyButton extends StatelessWidget
@override
Widget build(BuildContext context)
return DecoratedBox(
decoration:
ShapeDecoration(shape: CircleBorder(), color: Colors.pinkAccent),
child: Theme(
data: Theme.of(context).copyWith(
buttonTheme: ButtonTheme.of(context).copyWith(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap)),
child: OutlineButton(
shape: CircleBorder(),
child: Text('A'),
onPressed: () => ,
),
),
);
To modify the backgroundColor of a OutlineButton you can use a DecoratedBox and a Theme widget. At the end of this answer you'll find a quick example.
Anyway I'd still recommend simply using the FlatButton with its color
attribute instead.
Wrap your OutlinedButton
inside a DecoratedBox
. Set the shape
of your DecoratedBox
to the same shape your OutlinedButton
. Now you can use the color
attribute of your DecoratedBox
to change the color. The result will still have a small padding around the OutlinedButton
. To remove this you can wrap the DecoratedBox
inside a Theme
in which you adjust the ButtonTheme
. Inside the ButtonTheme
you want to set materialTapTargetSize: MaterialTapTargetSize.shrinkWrap
.
The padding is added inside Flutter, to increase the tap area around the button to a minimum size of 48x48 (source). Setting materialTapTargetSize
to MaterialTapTargetSize.shrinkWrap
removes this minimum size.
FlatButton
example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
home: Scaffold(
body: Center(
child: FlatButton(
color: Colors.pinkAccent,
shape: CircleBorder(),
onPressed: () => ,
child: Text('A'),
),
),
),
);
OutlinedButton
example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget
@override
Widget build(BuildContext context)
return MaterialApp(
home: Scaffold(
body: Center(
child: MyButton(),
),
),
);
class MyButton extends StatelessWidget
@override
Widget build(BuildContext context)
return DecoratedBox(
decoration:
ShapeDecoration(shape: CircleBorder(), color: Colors.pinkAccent),
child: Theme(
data: Theme.of(context).copyWith(
buttonTheme: ButtonTheme.of(context).copyWith(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap)),
child: OutlineButton(
shape: CircleBorder(),
child: Text('A'),
onPressed: () => ,
),
),
);
edited Mar 27 at 8:39
answered Mar 27 at 8:32
NiklasNiklas
1,6258 silver badges20 bronze badges
1,6258 silver badges20 bronze badges
I added aFlatButton
example, which I'd recommend because it is way more simple.
– Niklas
Mar 27 at 8:44
add a comment |
I added aFlatButton
example, which I'd recommend because it is way more simple.
– Niklas
Mar 27 at 8:44
I added a
FlatButton
example, which I'd recommend because it is way more simple.– Niklas
Mar 27 at 8:44
I added a
FlatButton
example, which I'd recommend because it is way more simple.– Niklas
Mar 27 at 8:44
add a comment |
Here's way that you can check the background color of the button.
Remove hightlightColor, and try give some value to highlightElevation property of OutlineButton, then press it, you could see initially it loads orange color.
I think OutlineButton seems have its original behavior and hard to configure it. Essentially OutlineButton extends MaterialButton, so why don't you try out MaterialButton instead?
– dyGi
Mar 27 at 6:57
add a comment |
Here's way that you can check the background color of the button.
Remove hightlightColor, and try give some value to highlightElevation property of OutlineButton, then press it, you could see initially it loads orange color.
I think OutlineButton seems have its original behavior and hard to configure it. Essentially OutlineButton extends MaterialButton, so why don't you try out MaterialButton instead?
– dyGi
Mar 27 at 6:57
add a comment |
Here's way that you can check the background color of the button.
Remove hightlightColor, and try give some value to highlightElevation property of OutlineButton, then press it, you could see initially it loads orange color.
Here's way that you can check the background color of the button.
Remove hightlightColor, and try give some value to highlightElevation property of OutlineButton, then press it, you could see initially it loads orange color.
answered Mar 27 at 6:54
dyGidyGi
1213 bronze badges
1213 bronze badges
I think OutlineButton seems have its original behavior and hard to configure it. Essentially OutlineButton extends MaterialButton, so why don't you try out MaterialButton instead?
– dyGi
Mar 27 at 6:57
add a comment |
I think OutlineButton seems have its original behavior and hard to configure it. Essentially OutlineButton extends MaterialButton, so why don't you try out MaterialButton instead?
– dyGi
Mar 27 at 6:57
I think OutlineButton seems have its original behavior and hard to configure it. Essentially OutlineButton extends MaterialButton, so why don't you try out MaterialButton instead?
– dyGi
Mar 27 at 6:57
I think OutlineButton seems have its original behavior and hard to configure it. Essentially OutlineButton extends MaterialButton, so why don't you try out MaterialButton instead?
– dyGi
Mar 27 at 6:57
add a comment |
You could use FlatButton, and just set color there.
add a comment |
You could use FlatButton, and just set color there.
add a comment |
You could use FlatButton, and just set color there.
You could use FlatButton, and just set color there.
edited Mar 27 at 9:56
E_net4
14.2k7 gold badges41 silver badges79 bronze badges
14.2k7 gold badges41 silver badges79 bronze badges
answered Mar 27 at 8:04
knezzzknezzz
3862 silver badges7 bronze badges
3862 silver badges7 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370952%2fhow-to-set-the-background-color-of-a-flutter-outlinebutton%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please Visit following link I think it is related to your problem...
– Faiz Fareed
Mar 27 at 7:25