Flutter, AppBar Color change - flutter

Is there a way that the AppBars color can be changed through a gradient and opacity as an example? From something lighter to something darker to see the icons above the phone clearer.

Fixed.
appBar: AppBar(
brightness: Brightness.light,
backgroundColor: Colors.white,
elevation: 0.0,

if I understand correctly you want to change the appbar color with one of these methods :
1) change AppBar color only
witch will affect the background of appbar only
appBar: AppBar(
backgroundColor: PrimaryColor,
),
1) change primary App color swatch :
witch will change all the colors of buttons , etc to a certain color including appbar
MaterialApp(
primaryColor: Colors.red,
)
2) Switch to dark mode :
witch will invert the colors of all app to dark mode
MaterialApp(
title: title,
theme: ThemeData.dark(),
)

Related

Flutter Material 3 Changed colors, and fonts

So I just decided to give Material 3 a shot in Flutter and it changed a whole lot of colors, and fonts etc.
I knew certain things would look different like more rounded corners on my cards but I wasn't expecting all the fonts and card colors to change. I literally just added the useMaterial3: true, to the code below:
child: MaterialApp(
debugShowCheckedModeBanner: false,
routes: appRoutes,
theme: ThemeData(
useMaterial3: true,
scaffoldBackgroundColor: const Color(0xFF2b8293),
),
home: const CheckLogin(),
),
Here is an example of what has changed with before and after pictures:
Anyway to change the default card color, and title fonts so I do not have to change them in every view in the app one by one?
Also odd to see the vertical 3 dot icon changed to dark while the search Icon did not. Thanks!
You can override the default theme on materialApp.
theme: ThemeData(
useMaterial3: true,
scaffoldBackgroundColor: const Color(0xFF2b8293),
appBarTheme: AppBarTheme(
titleTextStyle: TextStyle(...),
iconTheme: IconThemeData(
...
)
)
),

flutter: custom color for App Bar with ThemeData

How can I make a custom color for App Bar with ThemeData?
accentColor is deprecated while colorScheme: ColorScheme.fromSwatch(primarySwatch: Colors.indigo)) expects type MaterialColor.
I know that I can make it this way
Scaffold(
appBar: AppBar(
backgroundColor: Color(0xFF0A0E21),
title: Text('CAPTION'),
),
But I want to specify it in ThemeData
Rather than overriding everything, it often makes sense to extend the parent theme. You can handle this by using the copyWith() method.
More about extending-the-parent-theme.
return MaterialApp(
home: const T1(),
theme: Theme.of(context).copyWith(
appBarTheme: Theme.of(context).appBarTheme.copyWith(
backgroundColor: const Color(0xFF0A0E21),
),
),
As you mentioned, the first way is to set it with backroundColor property.
If this property is null, then the AppBarTheme.backgroundColor is used. AppBarTheme can be set using appBarTheme property of ThemeData.
If AppBarTheme.backgroundColor is also null, then AppBar uses the overall theme's ColorScheme.primary if the overall theme's brightness is Brightness.light, and ColorScheme.surface if the overall theme's brightness is Brightness.dark.

Flutter: Change Statusbar Text Color not working properly

Almost all the Q/A referred on Stackoverflow related to the same topic but didn't get proper solutions.
Main Question: My app having the primary color blue and I want to set Statusbar Text Color white.
What I have tried:
Using SystemChrome: (Using the following code, It's just changing the color of status bar text in the first screen only, other screens are having blue/black combination background/foreground.)
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: MaterialColor(0xFF084775, color), // status bar color
statusBarBrightness: Brightness.light,//status bar brightness
statusBarIconBrightness:Brightness.light , //status barIcon Brightness
));
Screenshots:
Splash Screen:
Dashboard Screen:
Using ThemeData : (This method gives the same result as the above screenshot).
theme: ThemeData(
brightness: Brightness.light, // ADDED THIS LINE..
primarySwatch: MaterialColor(0xFF084775, color),
accentColor: Color(0xffe46b10),
unselectedWidgetColor: Colors.grey,
fontFamily: 'SourceSansPro',
),
I have also checked github issue link but not worked for me.
I just need to change Statusbar Text Color to White. Any help?
To apply for all appBar use
return MaterialApp(
theme: ThemeData(
appBarTheme: Theme.of(context).appBarTheme.copyWith(brightness: Brightness.dark),
),
debugShowCheckedModeBanner: false,
// home: InvoiceList(),
home: widget());
I hope it will works.
Thank you.
As of Flutter 2
return MaterialApp(
theme: ThemeData(
appBarTheme: Theme.of(context)
.appBarTheme
.copyWith(systemOverlayStyle: SystemUiOverlayStyle.light)),
debugShowCheckedModeBanner: false,
home: widget());

How to change the statuts bar color for android in a flutter app?

I use a Scafold which has an app bar with grey background and black as text color. I want to have the status bar transparent and the text also black. Unfortunately the text color is white not matter what I've treid. After reading this post and this one, I've tried the code below, but the text color is still white.
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light.copyWith(
statusBarColor: Colors.black.withOpacity(0.0), // Color for Android
statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.light,
));
Update:
To make it more clear: In the emulator the bar looks like this which is fine:
On my phone the text color is white, so you can't see it:
To change the app bar theme, you can use appBarTheme property of ThemeData class and to change the text color of AppBar, you can use the textTheme property and set it as you want. The textstyle used for the text in AppBar is headline6, so you can do something like this.
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
//here we are applying the theme to appbar.
appBarTheme: AppBarTheme(
color: Colors.black.withOpacity(0.0),
brightness: Brightness.dark,
),
//here we are setting the theme to the text
primaryTextTheme: TextTheme(
headline6: TextStyle(
color: Colors.black,
)),
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
You can check the below simple code.
Scaffold(
backgroundColor: Colors.red,
appBar: AppBar(
backgroundColor: Colors.transparent,
title: Text(
"Demo",
style: TextStyle(color: Colors.black),
),
centerTitle: true,
),
body:....,)

How to center the title of an AppBar with theme [FLUTTER]

I want to center all the titles in my app with theme, theres a way to do it ?
Centering App Bar using Theme
theme: ThemeData(
appBarTheme: AppBarTheme(centerTitle: true),),
use centerTitle: true
appBar: AppBar(
centerTitle: true,
title: Text("Appbar Title"),
),