+
Skip to content

Remove scaleByFontFactor method and usages #9304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class _ExtensionIFrameController extends DisposableController
buildTextSpans: (_) => [
TextSpan(
text: showBannerMessageEvent.message,
style: TextStyle(fontSize: defaultFontSize),
style: const TextStyle(fontSize: defaultFontSize),
),
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class DisableExtensionDialog extends StatelessWidget {
text: 'DevTools Extensions ',
style: theme.boldTextStyle,
),
WidgetSpan(
const WidgetSpan(
child: Icon(Icons.extension_rounded, size: defaultIconSize),
),
const TextSpan(text: ' menu.'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ class ExtensionSettingsDialog extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
// This dialog needs a fixed height because it contains a scrollable list.
final dialogHeight = anyTestMode
? scaleByFontFactor(1000.0)
: scaleByFontFactor(300.0);
final dialogHeight = anyTestMode ? 1000.0 : 300.0;
return DevToolsDialog(
title: const DialogTitleText('DevTools Extensions'),
content: SizedBox(
Expand Down
12 changes: 5 additions & 7 deletions packages/devtools_app/lib/src/framework/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class _HomeScreenBodyState extends State<HomeScreenBody> with AutoDisposeMixin {
class ConnectionSection extends StatelessWidget {
const ConnectionSection({super.key, required this.connected});

static const _primaryMinScreenWidthForTextBeforeScaling = 480.0;
static const _secondaryMinScreenWidthForTextBeforeScaling = 600.0;
static const _primaryMinScreenWidthForText = 480.0;
static const _secondaryMinScreenWidthForText = 600.0;

final bool connected;

Expand All @@ -95,14 +95,12 @@ class ConnectionSection extends StatelessWidget {
actions: [
ViewVmFlagsButton(
gaScreen: gac.home,
minScreenWidthForTextBeforeScaling:
_secondaryMinScreenWidthForTextBeforeScaling,
minScreenWidthForText: _secondaryMinScreenWidthForText,
),
const SizedBox(width: defaultSpacing),
ConnectToNewAppButton(
gaScreen: gac.home,
minScreenWidthForTextBeforeScaling:
_primaryMinScreenWidthForTextBeforeScaling,
minScreenWidthForText: _primaryMinScreenWidthForText,
routerDelegate: DevToolsRouterDelegate.of(context),
onPressed: () =>
Navigator.of(context, rootNavigator: true).pop('dialog'),
Expand Down Expand Up @@ -202,7 +200,7 @@ class _ConnectInputState extends State<ConnectInput> with BlockingActionMixin {
children: [
SizedBox(
height: defaultTextFieldHeight,
width: scaleByFontFactor(350.0),
width: 350.0,
child: DevToolsClearableTextField(
labelText: 'URL',
onSubmitted: actionInProgress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import '../shared/managers/notifications.dart';
import '../shared/primitives/utils.dart';
import '../shared/ui/common_widgets.dart';

double get _notificationHeight => scaleByFontFactor(175.0);
const _notificationHeight = 175.0;
final _notificationWidth = _notificationHeight * goldenRatio;

/// Manager for notifications in the app.
Expand Down Expand Up @@ -151,7 +151,7 @@ class _NotificationOverlay extends StatelessWidget {
child: Padding(
// Position the notifications in the lower right of the app window, and
// high enough up that we don't obscure the status line.
padding: EdgeInsets.only(
padding: const EdgeInsets.only(
right: defaultSpacing,
bottom: statusLineHeight + defaultSpacing,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ class _ReduceMemoryButtonState extends State<_ReduceMemoryButton> {
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: denseSpacing),
child: inProgress
? SizedBox(
? const SizedBox(
height: actionsIconSize,
width: actionsIconSize,
child: const CircularProgressIndicator(),
child: CircularProgressIndicator(),
)
: ValueListenableBuilder(
valueListenable: result,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DevToolsAppBar extends StatelessWidget {
if (screens.isNotEmpty && actionsWithSpacer.isNotEmpty) {
actionsWithSpacer.insert(
0,
VerticalLineSpacer(height: defaultToolbarHeight),
const VerticalLineSpacer(height: defaultToolbarHeight),
);
}

Expand Down Expand Up @@ -219,7 +219,7 @@ class TabOverflowButton extends StatelessWidget {

@visibleForTesting
class SelectedTabWrapper extends StatelessWidget {
SelectedTabWrapper({super.key, required this.child, double? width})
const SelectedTabWrapper({super.key, required this.child, double? width})
: width = width ?? buttonMinWidth;

final Widget child;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ class DevToolsScaffoldState extends State<DevToolsScaffold>
child: Scaffold(
appBar: showAppBar
? PreferredSize(
preferredSize: Size.fromHeight(defaultToolbarHeight),
preferredSize: const Size.fromHeight(
defaultToolbarHeight,
),
// Place the AppBar inside of a Hero widget to keep it the same across
// route transitions.
child: Hero(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class SettingsDialog extends StatelessWidget {
class _VerboseLoggingSetting extends StatelessWidget {
const _VerboseLoggingSetting();

static const _minScreenWidthForTextBeforeScaling = 500.0;
static const _minScreenWidthForText = 500.0;

@override
Widget build(BuildContext context) {
Expand All @@ -130,8 +130,7 @@ class _VerboseLoggingSetting extends StatelessWidget {
icon: Icons.copy_outlined,
gaScreen: gac.settingsDialog,
gaSelection: gac.copyLogs,
minScreenWidthForTextBeforeScaling:
_minScreenWidthForTextBeforeScaling,
minScreenWidthForText: _minScreenWidthForText,
onPressed: () async => await copyToClipboard(
LogStorage.root.toString(),
successMessage: 'Successfully copied logs',
Expand All @@ -142,8 +141,7 @@ class _VerboseLoggingSetting extends StatelessWidget {
label: 'Clear logs',
gaScreen: gac.settingsDialog,
gaSelection: gac.clearLogs,
minScreenWidthForTextBeforeScaling:
_minScreenWidthForTextBeforeScaling,
minScreenWidthForText: _minScreenWidthForText,
onPressed: LogStorage.root.clear,
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class StatusLine extends StatelessWidget {
}
},
child: screenWidth <= MediaSize.xxs
? DevToolsTooltip(
? const DevToolsTooltip(
message: noConnectionMsg,
child: Icon(Icons.warning_amber_rounded, size: actionsIconSize),
)
Expand Down
8 changes: 0 additions & 8 deletions packages/devtools_app/lib/src/framework/theme_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ class EditorThemeManager extends DisposableController
}
}

if (newTheme.fontSize != null &&
newTheme.fontSize!.toDouble() != currentTheme.fontSize) {
updateQueryParameter(
IdeThemeQueryParams.fontSizeKey,
newTheme.fontSize!.toDouble().toString(),
);
}

setGlobal(IdeTheme, getIdeTheme());

// We are toggling to the opposite theme and then back to force the IDE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.

import 'package:devtools_app_shared/ui.dart';
import 'package:flutter/material.dart';

import '../../shared/charts/treemap.dart';
Expand Down Expand Up @@ -100,11 +99,7 @@ class _NameColumn extends TreeColumnData<TreemapNode> {

class _SizeColumn extends ColumnData<TreemapNode> {
_SizeColumn()
: super(
'Size',
alignment: ColumnAlignment.right,
fixedWidthPx: scaleByFontFactor(100.0),
);
: super('Size', alignment: ColumnAlignment.right, fixedWidthPx: 100.0);

@override
Comparable getValue(TreemapNode dataObject) => dataObject.byteSize;
Expand All @@ -127,7 +122,7 @@ class _SizePercentageColumn extends ColumnData<TreemapNode> {
: super(
'% of Total Size',
alignment: ColumnAlignment.right,
fixedWidthPx: scaleByFontFactor(100.0),
fixedWidthPx: 100.0,
);

final int totalSize;
Expand Down Expand Up @@ -194,11 +189,7 @@ class AppSizeDiffTable extends StatelessWidget {
// other columns.
class _DiffColumn extends ColumnData<TreemapNode> {
_DiffColumn()
: super(
'Change',
alignment: ColumnAlignment.right,
fixedWidthPx: scaleByFontFactor(100.0),
);
: super('Change', alignment: ColumnAlignment.right, fixedWidthPx: 100.0);

// Ensure sort by absolute size.
@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import 'common.dart';
import 'debugger_controller.dart';
import 'debugger_model.dart';

double get executableLineRadius => scaleByFontFactor(1.5);
double get breakpointRadius => scaleByFontFactor(6.0);
const executableLineRadius = 1.5;
const breakpointRadius = 6.0;

class Breakpoints extends StatelessWidget {
const Breakpoints({super.key});
Expand Down
24 changes: 12 additions & 12 deletions packages/devtools_app/lib/src/screens/debugger/codeview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CodeView extends StatefulWidget {
'debuggerCodeViewVerticalScrollbarKey',
);

static double get rowHeight => scaleByFontFactor(16.0);
static const rowHeight = 16.0;

final CodeViewController codeViewController;
final DebuggerController? debuggerController;
Expand Down Expand Up @@ -872,7 +872,7 @@ class Gutter extends StatelessWidget {
itemCount: lineCount + profileInformationHeaderOffset,
itemBuilder: (context, index) {
if (showProfileInformation && index == 0) {
return SizedBox(height: CodeView.rowHeight);
return const SizedBox(height: CodeView.rowHeight);
}
final lineNum =
lineOffset - profileInformationHeaderOffset + index + 1;
Expand Down Expand Up @@ -929,8 +929,8 @@ class GutterItem extends StatelessWidget {
final breakpointColor = theme.colorScheme.primary;
final subtleColor = theme.unselectedWidgetColor;

final bpBoxSize = breakpointRadius * 2;
final executionPointIndent = scaleByFontFactor(10.0);
const bpBoxSize = breakpointRadius * 2;
const executionPointIndent = 10.0;
Color? color;
TextStyle? coverageTextStyleOverride;
final hasCoverage = coverageHit;
Expand Down Expand Up @@ -975,7 +975,7 @@ class GutterItem extends StatelessWidget {
style: coverageTextStyleOverride,
),
Container(
padding: EdgeInsets.only(left: executionPointIndent),
padding: const EdgeInsets.only(left: executionPointIndent),
alignment: Alignment.centerLeft,
child: AnimatedOpacity(
duration: defaultDuration,
Expand Down Expand Up @@ -1075,7 +1075,7 @@ class _LinesState extends State<Lines> with AutoDisposeMixin {
itemCount: widget.lines.length + profileInformationHeaderOffset,
itemBuilder: (context, index) {
if (widget.showProfileInformation && index == 0) {
return SizedBox(height: CodeView.rowHeight);
return const SizedBox(height: CodeView.rowHeight);
}
final dataIndex = index - profileInformationHeaderOffset;
final lineNum = dataIndex + 1;
Expand Down Expand Up @@ -1143,7 +1143,7 @@ class LineItem extends StatelessWidget {
this.activeSearchMatch,
});

static double get _hoverWidth => scaleByFontFactor(400.0);
static const _hoverWidth = 400.0;

final TextSpan lineContents;
final StackFrameAndSourcePosition? pausedFrame;
Expand Down Expand Up @@ -1416,7 +1416,7 @@ class ScriptPopupMenu extends StatelessWidget {
.buildExtraDebuggerScriptPopupMenuOptions())
extensionMenuOption.build(),
],
child: Icon(Icons.more_vert, size: actionsIconSize),
child: const Icon(Icons.more_vert, size: actionsIconSize),
);
}
}
Expand All @@ -1442,11 +1442,11 @@ class ScriptHistoryPopupMenu extends StatelessWidget {
tooltip: 'Select recent script',
enabled: enabled,
onSelected: onSelected,
offset: Offset(
offset: const Offset(
actionsIconSize + denseSpacing,
buttonMinWidth + denseSpacing,
),
child: Icon(Icons.history, size: actionsIconSize),
child: const Icon(Icons.history, size: actionsIconSize),
);
}
}
Expand Down Expand Up @@ -1585,9 +1585,9 @@ class GoToLineDialog extends StatelessWidget {
);
}
},
decoration: InputDecoration(
decoration: const InputDecoration(
labelText: 'Line Number',
contentPadding: EdgeInsets.all(scaleByFontFactor(5.0)),
contentPadding: EdgeInsets.all(5.0),
),
keyboardType: TextInputType.number,
inputFormatters: <TextInputFormatter>[
Expand Down
15 changes: 5 additions & 10 deletions packages/devtools_app/lib/src/screens/debugger/controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ import 'debugger_controller.dart';
class DebuggingControls extends StatefulWidget {
const DebuggingControls({super.key});

static const minWidthBeforeScaling = 1750.0;
static const minWidth = 1750.0;

// The icon size for the material_symbol icons needs to be increased to
// account for padding included in the icon assets.
static final materialIconSize = scaleByFontFactor(
defaultIconSizeBeforeScaling + 3.0,
);
static const materialIconSize = defaultIconSize + 3.0;

@override
State<DebuggingControls> createState() => _DebuggingControlsState();
Expand Down Expand Up @@ -142,8 +140,7 @@ class _DebuggingControlsState extends State<DebuggingControls>
onPressed: canStep ? () => unawaited(controller.stepOut()) : null,
),
],
minScreenWidthForTextBeforeScaling:
DebuggingControls.minWidthBeforeScaling,
minScreenWidthForText: DebuggingControls.minWidth,
);
}

Expand All @@ -159,8 +156,7 @@ class _DebuggingControlsState extends State<DebuggingControls>
gaSelection: visible
? gac.DebuggerEvents.hideFileExplorer.name
: gac.DebuggerEvents.showFileExplorer.name,
minScreenWidthForTextBeforeScaling:
DebuggingControls.minWidthBeforeScaling,
minScreenWidthForText: DebuggingControls.minWidth,
);
},
);
Expand Down Expand Up @@ -251,8 +247,7 @@ class BreakOnExceptionsControl extends StatelessWidget {
@override
Widget build(BuildContext context) {
final isInSmallMode =
MediaQuery.of(context).size.width <
DebuggingControls.minWidthBeforeScaling;
MediaQuery.of(context).size.width < DebuggingControls.minWidth;
return ValueListenableBuilder<String?>(
valueListenable: controller.exceptionPauseMode,
builder: (BuildContext context, modeId, _) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ class _FloatingDebuggerControlsState extends State<FloatingDebuggerControls>
message: 'Resume',
child: TextButton(
onPressed: controller.resume,
child: DevToolsIcon(
child: const DevToolsIcon(
iconAsset: 'icons/material_symbols/resume.png',
color: Colors.green,
size: DebuggingControls.materialIconSize,
Expand All @@ -596,7 +596,7 @@ class _FloatingDebuggerControlsState extends State<FloatingDebuggerControls>
message: 'Step over',
child: TextButton(
onPressed: controller.stepOver,
child: DevToolsIcon(
child: const DevToolsIcon(
iconAsset: 'icons/material_symbols/step_over.png',
color: Colors.black,
size: DebuggingControls.materialIconSize,
Expand Down
Loading
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载