Does ListTile widgets automatically inherit the listTile theme data declared in the app's theme in flutter?
I gave a shape in the themedata, but it is not reflecting in the ui
Related
I've seen some posts recommending to set fontSize or TextStyle for Text widget using Theme
// textStyle
Theme.of(context).textTheme.bodySmall
OR
// fontSize
Theme.of(context).textTheme.bodySmall.fontSize
What benefit will I get by setting these parameters using Theme.of(context) at runtime, when I can simply declare font sizes as constants?
You can either define app-wide themes or use Theme widgets that represent the colors and font styles for a particular part of the application. App-wide themes are Theme widgets created at the root of an app by the MaterialApp.
After defining a Theme, use it within your widgets. Flutter’s Material widgets also use your Theme to set the background colors and font styles for AppBars, Buttons, Checkboxes, and more.
You can ref this below link:
https://docs.flutter.dev/cookbook/design/themes
How can i make this dropdown style in flutter,
also the CupertinoSwitch color change like this one ---background color white & Button color Amber.
Thanks
You could probably use an AnimatedContainer in combination with the expandable package to achieve most of the UI for this widget.
As for the Cupertino switch, you have a property in the widget itself to set a color when the button is active:
https://api.flutter.dev/flutter/cupertino/CupertinoSwitch/activeColor.html
Is it necessary to use wrap another widget (ie Text, image etc) inside the Container widget as a child, if we want to apply styling to the child widget? In other words, can I apply styling to my Text or Image widgets without wrapping them inside Container widgets?
Yes its is necessary to wrap your widget using a Container or DecoratedBox.
The reason is that in flutter decorations are applied using the BoxDecoration class. If you want use styles like Borders, Background Colors Shadows etc you would need to use a Widget that uses a BoxDecoration.
If you don't want to use a Container you can use the DecoratedBox widget provided by flutter amongst others.
If you want to apply styles only to your text data, then you don't need to use Container or DecoratedBox, as pure text styles can be provided to the Text Widget, by providing the style property with the a TextStyle Class.
DecoratedBox Widget Docs
BoxDecoration Docs
TextStyle Docs
is it possible to influence the textStyle of a Button through the theme? In this particular case, I want every button label to have a specific fontWeight.
The ButtonTextTheme is only responsible for colors.
I know I can style the child of the button itself but I wanted to have the styling on theme level.
Now I'd need to create a custom Button Widget that does that for me
I am developing an app using Flutter. If I choose MaterialApp as the parent widget of my app, all Text widgets in my app are underlined yellow. On the other hand, if I just use Material as the parent widget, no yellow lines are shown under the Text widgets.
What is the difference between Material and MaterialApp?
MaterialApp is a widget that introduces many interesting tools such as Navigator or Theme to help you develop your app.
Material is, on the other hand, a widget used to define a UI element respecting Material rules. It defines what elevation is, shape, and stuff. Then reused by many material widgets such as Appbar or Card or FloatingButton.
The yellow underlines you can find in Text is introduced by MaterialApp as a fallback Theme. It is here for debug purpose, to warn you that you need to use Material somewhere above your Text.
In short, use both. You should have a MaterialApp near the root of your app. And then use widgets that introduce a Material instance (Such a Scaffold, Appbar, Dialog, ...) when you want to use Text or InkWell.
MaterialApp : The MaterialApp configures the top-level Navigator to search for routes or to define Home.
Material : For child UI widgets rendering & effects.