Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know which theme data changes what in Flutter

Tags:

flutter

dart

In Flutter, it is pretty hard to find out what theme property changes what part of the app. For example, the background color of AppBar defaults to the primaryColor of the theme being used. I do not see this written anywhere in the documentation of the AppBar

https://docs.flutter.io/flutter/material/AppBar-class.html

How are we supposed to know which theme property will change what parts of our widgets?

like image 388
dshukertjr Avatar asked Oct 05 '18 14:10

dshukertjr


People also ask

How do I use a theme in flutter?

After defining a Theme, use it within your own widgets. Flutter’s Material widgets also use your Theme to set the background colors and font styles for AppBars, Buttons, Checkboxes, and more. To share a Theme across an entire app, provide a ThemeData to the MaterialApp constructor. If no theme is provided, Flutter creates a default theme for you.

How to control the design across the entire app in flutter?

We can use the Flutter theme property of the MaterialApp Widget, to control the design across the entire app. However, we can do that in various ways. Previously, we have been building an interesting Quiz App.

What is the difference between app-wide themes and theme widgets?

You can either define app-wide themes, or use Theme widgets that define the colors and font styles for a particular part of the application. In fact, app-wide themes are just Theme widgets created at the root of an app by the MaterialApp. After defining a Theme, use it within your own widgets.

Why are the default colors changing in the theme system?

The motivation for these changes is to make the theme system easier to understand and use. The default colors for all components are to be defined by the components themselves and based on the color scheme.


1 Answers

This answer was from @Aristidios - inappropriately deleted by @BhargavRao.

It isn't a great answer, but in 3 1/2 years this excellent question still doesn't have a better one :


If your still searching - Please checkout this great guide from Vivek Yadav - in his article he details each & everyone of the ThemeData parameters :

https://medium.com/flutter-community/themes-in-flutter-part-1-75f52f2334ea


And here is a short-hand copy of all the Theme properties:

ThemeData({
  Brightness brightness,
  MaterialColor primarySwatch,
  Color primaryColor,
  Brightness primaryColorBrightness,
  Color primaryColorLight,
  Color primaryColorDark,
  Color accentColor,
  Brightness accentColorBrightness,
  Color canvasColor,
  Color scaffoldBackgroundColor,
  Color bottomAppBarColor,
  Color cardColor,
  Color dividerColor,
  Color focusColor,
  Color hoverColor,
  Color highlightColor,
  Color splashColor,
  InteractiveInkFeatureFactory splashFactory,
  Color selectedRowColor,
  Color unselectedWidgetColor,
  Color disabledColor,
  Color buttonColor,
  ButtonThemeData buttonTheme,
  ToggleButtonsThemeData toggleButtonsTheme,
  Color secondaryHeaderColor,
  Color textSelectionColor,
  Color cursorColor,
  Color textSelectionHandleColor,
  Color backgroundColor,
  Color dialogBackgroundColor,
  Color indicatorColor,
  Color hintColor,
  Color errorColor,
  Color toggleableActiveColor,
  String fontFamily,
  TextTheme textTheme,
  TextTheme primaryTextTheme,
  TextTheme accentTextTheme,
  InputDecorationTheme inputDecorationTheme,
  IconThemeData iconTheme,
  IconThemeData primaryIconTheme,
  IconThemeData accentIconTheme,
  SliderThemeData sliderTheme,
  TabBarTheme tabBarTheme,
  TooltipThemeData tooltipTheme,
  CardTheme cardTheme,
  ChipThemeData chipTheme,
  TargetPlatform platform,
  MaterialTapTargetSize materialTapTargetSize,
  bool applyElevationOverlayColor,
  PageTransitionsTheme pageTransitionsTheme,
  AppBarTheme appBarTheme,
  BottomAppBarTheme bottomAppBarTheme,
  ColorScheme colorScheme,
  DialogTheme dialogTheme,
  FloatingActionButtonThemeData floatingActionButtonTheme,
  Typography typography,
  CupertinoThemeData cupertinoOverrideTheme,
  SnackBarThemeData snackBarTheme,
  BottomSheetThemeData bottomSheetTheme,
  PopupMenuThemeData popupMenuTheme,
  MaterialBannerThemeData bannerTheme,
  DividerThemeData dividerTheme,
  ButtonBarThemeData buttonBarTheme,
})
like image 97
kris Avatar answered Oct 13 '22 17:10

kris