comfortablePlatformDensity property

VisualDensity comfortablePlatformDensity

Returns a VisualDensity that is adaptive to comfortable instead of to the default compact, based on active defaultTargetPlatform.

For desktop platforms, this returns VisualDensity.comfortable, and for other platforms, it returns the default VisualDensity. This is a variant of the VisualDensity.adaptivePlatformDensity that returns VisualDensity.compact for the desktop platforms. If this seems too dense and you prefer comfortable on desktop and still like the even less dense default on on devices, then use this platform dependent VisualDensity function as visualDensity for your theme.

Implementation

static VisualDensity get comfortablePlatformDensity {
  switch (defaultTargetPlatform) {
    case TargetPlatform.android:
    case TargetPlatform.iOS:
    case TargetPlatform.fuchsia:
      break;
    case TargetPlatform.linux:
    case TargetPlatform.macOS:
    case TargetPlatform.windows:
      return VisualDensity.comfortable;
  }
  return VisualDensity.standard;
}