How to call the icon theme for an icon - flutter

In flutter the MaterialApp widget has a theme property where you can set fonts, background colors etc... When I need a text theme for example, using the style property, I can set the theme with Theme.of(context).textTheme.title) . How would I do similar with setting the theme for icons. Icons doesn't have a style property.

You can use the IconTheme class.
new IconTheme(
data: new IconThemeData(
color: Colors.blue),
child: new Icon(Icons.add),
),
Hope it might help.

Try replacing the icons you want to style with IconButton widget which has color: property, but you should disable it to hide the effect of user clicks , or you can set the highlighting color to Colors.transparent

Related

how to change the color of the cursor in flutter search delegate?

I have implemented flutter search delegate feature in flutter app.Now I want to change the color of the cursor as it is white color and background of the search bar is also white. I need to highlight of cursor color to black.
I tried the appbarTheme inside the searchDelegate class but it doesnt work.
Add this in MaterialApp (it will change cursor color for all screens)
theme: ThemeData(
textSelectionTheme: const TextSelectionThemeData(
cursorColor: Colors.black,
),
),

Flutter - Change color of selected text in a Textfield

I have a Searchbar and due to my app theming, the text inside becomes hard to read when its selected. I would like to know if there is a way to set a different text color when it's selected.
Thanks in advance!
Flutter does not support changing the selected text color via the theme declaration in the main widget, only can change background color. You must use the SelectableText in each input style property, like as:
SelectableText(
'Example text',
style: TextStyle(color: Colors.red), // Yout text color on selected
)
Reference: https://github.com/flutter/flutter/issues/99231

Flutter's applications default color

I'm making a Welcome Screen which has two TextButtons each wrapped in a Container.
one for Creating an account and another for logging in
(both of them have some shadow below them )
I managed to make both containers in flutter but I found out that the background color of the application is not pure white (#FFFFFF) which mean if I set the color of the login container to Colors.white it won't look like the background color of the app like above picture.
So I need a way to set the color of the login container to the same color as the application.
let's avoid hard coding I don't want to determine the background color with an external tool and set it to the button.
I was thinking of taking same color as parent or something like that but I don't know if that exists.
main.dart
WelcomeScreen.dart
The scaffold background color is Grey[50]. You can set background color on scaffold like
Scaffold(
backgroundColor: Colors.white,
Or for app
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: Theme.of(context).copyWith(
scaffoldBackgroundColor: Colors.white,
),
More about Theme.

Flutter TextButton onPrimary alternative

I just started with flutter and got a question regarding the TextButton(). With an ElevatedButton I can use .styleFrom with the onPrimary property to change the color of shadowy animation which comes when I click the button.
But for my Navbar I need the TextButton, it has this effect aswell but onPrimary doesnt work there so I cannot change the shadow to another color than the default black, how can you change this style for a TextButton?
Thanks in advance
The only solution I came up with was changing
style: TextButton.styleFrom()
with ButtonStyle - you can use overlayColor to change the shadow when you press it:
style: ButtonStyle(
overlayColor: MaterialStateProperty.all<Color>(Color(0x00FFFFFF)),
),

MaterialApp ThemeData iconTheme

I have some ListTile widgets around my app, and all of them have an icon.
From here I see that I need to override my ListTile with
ListTileTheme(
iconColor: Colors.blue,
child: ..
)
since the ListTile.iconColor is gray by default and doesn't fallback to ThemeData.iconTheme.iconColor.
I wonder if there is a way to specify the list tile theme in ThemeData, so I don't have to create a new widget just for that.
For now, there isn't, but this feature may arrive in the next flutter release: https://github.com/flutter/flutter/issues/31247