How to Remove Glow Effect from Flutter Slider Widget? - flutter

With a Slider widget in Flutter, there is a glow effect that radiates from the "thumb" (selection dot) when touch down is active (when user is using the slider):
This is a "material behavior" that I would like to disable for a more flat design.
Is there a way to remove this in some way, preferably via an argument to the slider?
I noticed that the glow color comes from the "activeColor" argument, but if you change it to transparent, it also affects the "active" section of the slider which is unusable:
I would like to avoid re-writing my own slider just for this.

To change a single Slider, use a SliderTheme widget to change the overlayColor to transparent.
SliderTheme(
data: SliderThemeData(
overlayColor: Colors.transparent, // <- disable "glow effect"
),
child: Slider(
value: _value,
onChanged: (v) => setState(() => _value = v),
),
)
To change all Sliders in the app, you can modify it at Theme level, for example:
MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
sliderTheme: SliderThemeData(
overlayColor: Colors.transparent, // <- disable "glow effect"
),
),
home: const MyHomePage(),
);
EDIT from OP:
It is apparently also important (maybe a bug as of Flutter 3.3.10) that if you have customized the activeColor argument your slider, you must instead set it using the activeTrackColor argument of the slider theme (not as an argument to the slider), otherwise the overlayColor set in the theme will have no effect.

Related

Is there any way to remove the stretch effect when scrolling a list in flutter using material 3?

Left is what the old material design had which was a glow effect.
Right is what the new material design has which is a stretch effect.
Inside the Material widget, set the theme property to this:
theme: ThemeData().copyWith(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.red,
),
),

How can I change the color of that purple thing?

How can I change the color of that purple thing?
This Color depends on your Theme Color, try the below code, I hope it helps you :
TextField(cursorColor: Colors.red)//change color your need
You have two possibilities:
Change it in all your code. In your main file change it like this :
return MaterialApp(
title: 'Demo',
theme: ThemeData(
primarySwatch: Colors.orange, // Or another color
),
home: Home() // Your home page,
);
Change it in this part only
TextField( cursorColor: Colors.orange) // or another color
In your TextField, specify the cursorColor property, like this:
TextField(
...
// put here the color you want
cursorColor: Colors.green
)

Change highlight colour for textfield in flutter

Is there any way to change the colour of a Textfield's highlight in Flutter?
So when I highlight it does not look like this:
Thank you!
Solution 1. You can change the textSelectionColor in the theme of your app:
theme: ThemeData.dark().copyWith(
textSelectionColor: Colors.black
),
Solution 2. You can change the textSelectionColor only for a specific TextField by wrapping it with a Theme widget:
Theme(
data: ThemeData(
textSelectionColor: Colors.black,
),
child: TextField(
),
),

What is the proper way of using ThemeData copyWith in flutter MaterialApp widget?

I was trying to change the accentColor after copying the ThemeData.light(), then I have this sample screen with a FloatingActionButton
class Sample extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
)}}
Then in the main widget in main.dart to call runApp, if I set the ThemeData for the MaterialApp widget like this, The FloatingActionButton will have a color of orange.
theme: ThemeData(
accentColor: Colors.orange
)
but if I tried to inherit the color from the Themedata.light().copyWith, the FloatingActionButton will still have the color blue from the light theme.
theme: ThemeData.light().copyWith(
accentColor: Colors.orange
)
I was expecting the FloatingActionButton should have the orange color, because It inherit the light theme and override the accentColor.
this is a common problem in Flutter, but you can solve it for now by doing the following:
theme: ThemeData.light().copyWith(
floatingActionButtonTheme:
ThemeData.light().floatingActionButtonTheme.copyWith(
backgroundColor: Colors.orange,
),
),
if you used any other button you should do the same and overwrite it's Theme,
you can read more about the problem here Updating the Material Buttons and their Themes
and buttonColor not honored when using ThemeData.light().copyWith()
look,
I don't think that u can inherit the accent color using the ThemeData.copyWith(),but if u are sure to use ThemeData.copyWith() to change your floatingActionButton Color then u can do this in the following way,
theme:ThemeData.dark().copyWith(
textTheme:ThemeData.dark().textTheme.copyWith(
title :TextStyle( --your color and text configuratons here like color,font etc)
button: TextStyle(--do--),
...and so on....
)
)
configurations u want in your default text title will go inside the TextStyle of above title property and same for button
Now u can achieve this inside your FAB by using this,
color: Theme.of(context).textTheme.button.color,
by doing this u can get the color u set for the buttons inside the ThemeData.
If u force on getting the default accent color then u have to use
theme:ThemeData(
primaryColor: -----
accentColor : -----
)
this will allow u to use Default accent Color for FAB

How to change color of the bubble (under cursor) on EditText in Flutter

How can I change the color of the bubble that appears upon text selection in a Text or TextFormField or .. in Flutter?
Here is the same question but for native code.
According to this flutter documentation, textSelectionHandleColor is deprecated. You should use selectionHandleColor instead inside TextSelectionThemeData widget like the code below.
theme: ThemeData(
textSelectionTheme: TextSelectionThemeData(
cursorColor: Colors.red,
selectionColor: Colors.green,
selectionHandleColor: Colors.black,
),
)
You may use the textSelectionHandleColor property.
Theme(
data: Theme.of(context).copyWith(
textSelectionHandleColor: Colors.green,
),
child: TextField(),
);
In case of iOS TextField, i've found no other solution than adding the snippet below to the top level MaterialApp like this:
MaterialApp => theme: ThemeData( snippet )
snippet:
cupertinoOverrideTheme: CupertinoThemeData( primaryColor: Color(0xff554270), ),
i couldn't apply this snippet by wrapping the TextField with Theme(data: Theme.of(context).copyWith( ... did not work.. dunno why ]: (maybe this one would be my fault in somewhere but adding it to the app lv definitely worked tho)
Hope this answer help future iOS wanderers [: