Skip to content

Improvement for constants #52600

@LefebvreIlyas

Description

@LefebvreIlyas

Hello everyone,

/// The epsilon of tolerable double precision error.
///
/// This is used in various places in the framework to allow for floating point
/// precision loss in calculations. Differences below this threshold are safe to
/// disregard.
const double precisionErrorTolerance = 1e-10;
  • In the file material/constants.dart that references the minimum dimension of any interactive region according to Material guidelines. But other constants are scattered throughout the framework, wouldn't it be better to gather them all in this file even if it means a huge breaking change? So that developers can easily find and use them.

Here are some constants:

See floating_action_button_location.dart

// TODO(hmuller): should be device dependent.
/// The margin that a [FloatingActionButton] should leave between it and the
/// edge of the screen.
///
/// [FloatingActionButtonLocation.endFloat] uses this to set the appropriate margin
/// between the [FloatingActionButton] and the end of the screen.
const double kFloatingActionButtonMargin = 16.0;

In the floating_action_button.dart file the dimensions of the floatingActionButtons are written hard in private variables of type BoxConstraints, wouldn't it be better to extract this also in the file material/constants.dart?

const BoxConstraints _kSizeConstraints = BoxConstraints.tightFor(
  width: 56.0,
  height: 56.0,
);

const BoxConstraints _kMiniSizeConstraints = BoxConstraints.tightFor(
  width: 40.0,
  height: 40.0,
);

const BoxConstraints _kExtendedSizeConstraints = BoxConstraints(
  minHeight: 48.0,
  maxHeight: 48.0,
);

In addition, the kRealaseMode constant page does not exist.

Does it make sense to create a pull request for this right now?

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: proposalA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions