New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot change splash effect of ToggleButtons #119447
Comments
Hello @kaboc. I recommend you use import 'package:flutter/material.dart';
void main() {
runApp(const App());
}
class App extends StatefulWidget {
const App({super.key});
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> {
var _index = 0;
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
segmentedButtonTheme: const SegmentedButtonThemeData(
style: ButtonStyle(
splashFactory: InkSparkle.splashFactory,
),
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
splashFactory: InkSparkle.splashFactory,
),
),
),
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TextButton(
onPressed: () {},
child: const Text('TextButton'),
),
const SizedBox(height: 8.0),
SegmentedButton<int>(
selected: {_index},
onSelectionChanged: (index) => setState(
() => _index = index.first,
),
segments: [
for (var i = 0; i < 2; i++)
ButtonSegment(
value: i,
label: Text('$i'),
),
],
),
],
),
),
),
);
}
} Due to the above reasons, I am closing the issue. Thank you |
@exaby73
Does it mean widgets for Material 2 will be deprecated and then removed in favour of Material 3? It doesn't seem very nice that we all have to move on to Material 3 and make a compromise with reduced features like no border colour setting for a selected button as I mentioned above. I'm kind of tired of being affected by changes in Material Design every time it happens. Please clarify at least whether we can keep using Meterial 2 widgets. |
I can see that a border is not being applied. You ca raise an issue for it :) Ultimately, M2 will get deprecated in the coming months and years. This is inline with Material Design Specifications and best practices |
Okay..., thanks you for clarification. https://m3.material.io/components/segmented-buttons/overview#97f408eb-1e19-493f-919f-027b1ae9da00 It appears that selection is represented with a tick icon, not the border colour. I think it is the specification of the segmented button. It is very likely a new issue will be closed quickly even if I raise it, so I'd rather not do it. Thank you anyway. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
I file this as a bug rather than a feature request as it seems like lack of a feature.
It is possible to change the appearance of the splash effect in various widgets (ElevatedButton, InkWell, etc), but even if I apply a different effect type to most widgets,
ToggleButtons
remains unchanged and therefore looks inconsistent.InkRipple.splashFactory
is always used.flutter/packages/flutter/lib/src/material/toggle_buttons.dart
Line 767 in e8c0e46
Steps to Reproduce
flutter run
on the code sample.TextButton
.Expected results:
The sparkle effect configured in
TextButtonThemeData
is used in bothTextButton
andToggleButtons
.Actual results:
The effect is only applied to the
TextButton
althoughToggleButton
usesTextButton
internally.Code sample
ToggleButtonsThemeData
has thesplashColor
argument, but does not havestyle
norsplashFactory
, andToggleButton
itself does not have relevant arguments either.The text was updated successfully, but these errors were encountered: