【发布时间】:2022-01-16 13:45:09
【问题描述】:
我在多个地方都有类似的东西(忽略实际示例)。当我对这些公式进行更改时,我需要在多个文件中进行更改。
SizedBox(
width: parentPortHidden ? 0.01 : DevicePreferences.getViewPortWidth(context, Constants.defaultDeviceWidth) - 0.01,
height: DevicePreferences.getDeviceHeight(context, Constants.getActualDeviceHeight) -
DevicePreferences.getDeviceHeight(context, Constants.appBarRelativeHeight, Constants.appBarMinAbsHeight),
child: CustomScrollView(
宽度和高度的值是用相同的公式计算的(这些不是常数)
也许这个问题和 this one 在 Flutter 中相当于 #define 的问题相同,但我不确定是否有其他解决方案,因为 #define 没有...
如果没有代码解决方案,最好使用什么“系统”来确保在需要更改这些公式的任何地方都进行更改?
【问题讨论】:
标签: flutter