Comments (1)
If the differences are only the default size, color, and animation, I think we can introduce a private _SwitchConfig
and do adaptation inside CupertinoSwitch
, just like what we did in material Switch. IMHO, creating 2 different widgets might be not necessary:) But I'm open to other suggestions if there are any other concerns!
mixin _SwitchConfig {
double get trackHeight;
double get trackWidth;
double get thumbRadius;
double get ThumbExtension; // This is 7 for iOS switch, 1 for macOS switch
}
class _SwitchConfigIOS with _SwitchConfig {
...
@override
double get ThumbExtension => 7.0;
}
class _SwitchConfigMacOS with _SwitchConfig {
...
@override
double get ThumbExtension => 1.0;
}
Based on different platforms, we can provide different values using switch statement when we build the Switch widget,
final _SwitchConfig config = switch (platform) {
TargetPlatform.android || TargetPlatform.fuchsia || TargetPlatform.iOS => _SwitchConfigIOS(context),
TargetPlatform.linux || TargetPlatform.windows || TargetPlatform.macOS => _SwitchConfigMacOS(context),
}
Or we can only return _SwitchConfigMacOS()
when the platform is macOS, and _SwitchConfigIOS()
for other platforms.
from flutter.
Related Issues (20)
- [iOS] substantial overhead from Webview itself? HOT 1
- Snackbar on wide screens does not comply with material 3
- mac-7 lost external connection phone device. HOT 1
- mac-29 lost external connection phone device. HOT 1
- linux-46 lost external connection phone device. HOT 1
- mac-6 lost external connection phone device. HOT 1
- mac-3 lost external connection phone device. HOT 1
- Flutter web is not rendering if not focused in a browser or webview
- GoRouter: unable to push page
- Linux GridView scroll with trackpad is sometimes reversed.
- Get ready for `@docImport`s
- Revisit disabled `OffscreenCanvas` support for Safari
- Add callback when a PlatformView is added to native view hierarchy
- [material/text_field.dart][web] Focusing on TextField disables interaction.
- [in_app_purchase] Purchase Stream returns expired purchases with PurchaseStatus.restored on IOS
- CupertinoTextField selection vertically misaligned
- Triage process self-test
- Text selection persists in field after hot restart
- [Flutter GPU] Discovery: Is Flutter GPU's rasterization workflow safe? HOT 2
- Flutter_module
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.