Comments (3)
Sadly, as you noticed, it can't be manually adjusted, the script at dev/tools/gen_defaults/bin/gen_defaults.dart should be modified to be smart enough to omit such kind of redundancy.
A better result for this segment of code could be:
@override ButtonStyle? get style {
return ButtonStyle(
textStyle: MaterialStatePropertyAll<TextStyle?>(Theme.of(context).textTheme.labelLarge),
backgroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
// if (states.contains(MaterialState.disabled)) {
// return null;
// }
if (states.contains(MaterialState.selected)) {
return _colors.secondaryContainer;
}
return null;
}),
foregroundColor: MaterialStateProperty.resolveWith((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return _colors.onSurface.withOpacity(0.38);
}
if (states.contains(MaterialState.selected)) {
// if (states.contains(MaterialState.pressed)) {
// return _colors.onSecondaryContainer;
// }
// if (states.contains(MaterialState.hovered)) {
// return _colors.onSecondaryContainer;
// }
// if (states.contains(MaterialState.focused)) {
// return _colors.onSecondaryContainer;
// }
return _colors.onSecondaryContainer;
} else {
// if (states.contains(MaterialState.pressed)) {
// return _colors.onSurface;
// }
// if (states.contains(MaterialState.hovered)) {
// return _colors.onSurface;
// }
// if (states.contains(MaterialState.focused)) {
// return _colors.onSurface;
// }
return _colors.onSurface;
}
}),
from flutter.
Hi @YukiAttano
As @FusoraTech mentioned, this is generated from gen_defaults.
While the values might look similar, the tokens used to generate these values are quite different. This ensures regardless of the token value, we're generating colors specified in the specs. This is important if the token value database is updated the generated code will produce correct colors based on overlay states.
flutter/dev/tools/gen_defaults/lib/segmented_button_template.dart
Lines 83 to 106 in f94b1e1
I believe this is working as design. please refer to the gen_defaults for more details on the tokens and their values.
from flutter.
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 flutter doctor -v
and a minimal reproduction of the issue.
from flutter.
Related Issues (20)
- [camera_android_camerax] Camera preview is rotated on the supported Impeller version HOT 3
- [local_auth] Get supported biometric authentication types for the device even if the method is not enrolled HOT 1
- Differences in key value between debug and release versions of an app HOT 2
- [Android] PlatformView tap coordinates mapping incorrectly when in TabBarView(KeepAlive)-NestedScrollView-WebViewWidget HOT 2
- Setting avoid_print: error in our analysis_options.yaml file will only generate an error. It won't prevent app running. I need app not run. I don't know this possible or not if possible give me solution. HOT 2
- Push the solution of 'Pixel align subpass textures' to stable HOT 2
- [Flutter 3.22] EXC_BAD_ACCESS flutter::DisplayListBuilder::Restore HOT 1
- GoRouter+PopScope didn't work. HOT 1
- iOS App crashs rendering an SVG icon since flutter 3.22.0 HOT 3
- Kotlin Gradule plugin upgrade instruction is out of date HOT 2
- [tool_crash] _CastError: (#0 OhosModule.fromOhosProject (package:flutter_tools/src/ohos/application_package.dart:214:59)) HOT 1
- [tool_crash] FileSystemException: Cannot delete file, OS Error: Permission denied, errno = 13 HOT 1
- [tool_crash] ExistingDartDevelopmentServiceException HOT 1
- Running flutter in iOS17, native print logs cannot be displayed in VSCode,only in XCode. But iOS 16 can show both
- How to deploy a flutter app using flavor with xcode cloud?
- RangeSlider : bad rounded value on 55 HOT 2
- Cherry picks to the engine require formatting HOT 4
- [Impeller] Different blur effect when using BorderRadius.only HOT 1
- mac-10 lost external connection phone device. HOT 1
- mac-7 and mac-24 lost external connection phone device. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter.