Theme responsible for CircularProgressIndicator - flutter

I want to give every CircularProgressIndicator a color in my app but what attribute is responsible for it in MaterialApp widget:
MaterialApp(
theme: ThemeData(
// what is the attribute for this widget.
)
)
I used both accentColor and colorScheme.secondary but still not change.

You can use accentColor to change the color of CircularProgressIndicator. It will look like this:
theme: ThemeData(
accentColor: Colors.red,
EDIT:
In the newest version of Flutter, you should use colorScheme instead of accentColor.
colorScheme: ColorScheme.fromSwatch().copyWith(
secondary: Colors.red,
),

In ThemeData there is progressIndicatorTheme attribute which you can assign ProgressIndicatorThemeData constructor to it, and there you can change the default color of ProgressIndicator.

Related

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 Extend ThemeData, add colours etc

I am trying to extend the color scheme used by my first app. I created a separate file that contains the following:
import 'package:flutter/cupertino.dart';
class Testy extends CupertinoThemeData {
final Color bgws = Color.fromRGBO(120, 120, 120, 1);
}
I then imported it into Main.Dart but cannot see how to use my new color. I thought Testy.bgws would do it but clearly I am missing something.
You can use default textTheme without Cupertino
like
final ThemeData appThemeLight = ThemeData(
/// theme
brightness: Brightness.light,
/// screen
primaryColor: Colors.blue,
/// brightness color
accentColor: Colors.white,
/// opacity color
hintColor: Colors.grey,
/// here you can add cupertino
cupertinoOverrideTheme: CupertinoThemeData(
primaryColor: Colors.black,
),
....
and use it Theme.of(context)...
also don't forget add appThemeLight to MaterialApp like theme: appThemeLight

Changing one property of ThemeData.dark()

I have a theme that can be changed. ThemeData.dark() and ThemeData() . I want to change the default accentColor 's value of the ThemeData.dark(). Is this possible? My codes in main are like this:
theme: snapshot.data
? ThemeData.dark()
: ThemeData(
accentColor: Colors.white,
canvasColor: Colors.blue[400],
appBarTheme: AppBarTheme(color: Colors.blue[400])),
Yes! ThemeData has a method called copyWith where you can copy the original and assign new values to only those you want to change. In your case, it would be something like this:
ThemeData.dark().copyWith(accentColor: Colors.black)

how to set whole app background color in flutter

is there a way to set whole app backgorundcolor in flutter. For example i want to use white background on all screens. so the first thing i do is manually setting background color to all screens. But i think its overkill. and i am looking for the a shortcut to achieve it.
i have tried below code but couldn't get achieve what i wanted.
#override
Widget build(BuildContext context) {
return BlocProvider<SplashBloc>(
bloc: splashBloc,
child: MaterialApp(
theme: new ThemeData(scaffoldBackgroundColor: Colors.white),
home: Splash(),
),
);
}
}
In main.dart, use,
MaterialApp(
theme: ThemeData(
scaffoldBackgroundColor: Colors.white),
),
This will change the background color of the entire app provided you are returning Scaffold in the build Widget.
You use use the theme in your MaterialApp Widget to set up the theme colors for your entire app like so:
MaterialApp(
theme: ThemeData(
primaryIconTheme: IconThemeData(color: Colors.white),
primaryColor: Color.fromRGBO(254, 248, 248, 1),
appBarTheme: AppBarTheme(
color: <color_of_choice>,
),
),
Your backgroundColor will assume the primaryColor above.
Read all about it here.

Single color for all background pages in flutter

Is there an option where we can give a single color to the background of every pages in flutter. I couldn't find one in flutter.
MaterialApp has a theme property which you can adjust the ScaffoldBackgroundColor with:
MaterialApp(
theme: ThemeData(
scaffoldBackgroundColor: Colors.white, //your preferred color
),
);