Skip to content

Commit

Permalink
refactor: Fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
witwash committed Nov 15, 2024
1 parent 7485bfb commit 4dace5d
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 32 deletions.
12 changes: 7 additions & 5 deletions kiosk_mode/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ class _HomeState extends State<_Home> {

void _handleStart(bool didStart) {
if (!didStart && Platform.isIOS) {
_showSnackBar(
'Single App mode is supported only for devices that are supervised'
' using Mobile Device Management (MDM) and the app itself must'
' be enabled for this mode by MDM.',
);
_showSnackBar(_unsupportedMessage);
}
}

Expand Down Expand Up @@ -97,3 +93,9 @@ class _HomeState extends State<_Home> {
},
);
}

const _unsupportedMessage = '''
Single App mode is supported only for devices that are supervised
using Mobile Device Management (MDM) and the app itself must
be enabled for this mode by MDM.
''';
2 changes: 2 additions & 0 deletions optimus/lib/src/chat/bubble.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ class _Date extends StatelessWidget {
direction: Axis.horizontal,
spacing: OptimusStackSpacing.spacing100,
children: [
// ignore: avoid-flexible-outside-flex, it is wrapped in Flex latter
Expanded(child: horizontalLine),
Text(date, style: tokens.bodySmallStrong),
// ignore: avoid-flexible-outside-flex, it is wrapped in Flex latter
Expanded(child: horizontalLine),
],
);
Expand Down
1 change: 1 addition & 0 deletions optimus/lib/src/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class OptimusChat extends StatelessWidget {
child: OptimusStack(
spacing: OptimusStackSpacing.spacing200,
children: [
// ignore: avoid-flexible-outside-flex, it is wrapped in Flex later
Expanded(
child: ListView.builder(
itemCount: _messages.length,
Expand Down
4 changes: 2 additions & 2 deletions optimus/lib/src/dialogs/dialog_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class DialogContent extends StatelessWidget {
final title = this.title;
final content = this.content;

return Container(
margin: margin,
return Padding(
padding: margin ?? EdgeInsets.zero,
child: Padding(
padding: EdgeInsets.all(spacing ?? tokens.spacing0),
child: ConstrainedBox(
Expand Down
2 changes: 1 addition & 1 deletion optimus/lib/src/dropdown/dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class _DropdownContentState<T> extends State<_DropdownContent<T>>
child: _buildList(isOnTop, listMaxHeight),
),
)
: widget.emptyResultPlaceholder ?? const SizedBox.shrink();
: (widget.emptyResultPlaceholder ?? const SizedBox.shrink());
final children = [
Material(color: Colors.transparent, child: content),
if (widget.embeddedSearch case final embeddedSearch?)
Expand Down
2 changes: 1 addition & 1 deletion optimus/lib/src/expansion/expansion_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class _OptimusExpansionTileState extends State<OptimusExpansionTile>
child: listTile,
),
ClipRect(
child: Align(heightFactor: _heightFactor.value, child: child),
child: Center(heightFactor: _heightFactor.value, child: child),
),
],
);
Expand Down
1 change: 1 addition & 0 deletions optimus/lib/src/form/input_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ class _OptimusInputFieldState extends State<OptimusInputField>
placeholder:
_placeholder, // TODO(witwash): rework when https://github.com/flutter/flutter/issues/138794 is fixed
children: [
// ignore: avoid-flexible-outside-flex, it is wrapped in Row later
Expanded(
child: CupertinoTextField(
key: widget.inputKey,
Expand Down
1 change: 1 addition & 0 deletions optimus/lib/src/form/multiselect_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class _OptimusMultiSelectInputFieldState extends State<MultiSelectInputField>
fieldBoxKey: widget.fieldBoxKey,
size: widget.size,
children: [
// ignore: avoid-flexible-outside-flex, it is wrapped in Row later
Flexible(
child: Focus(
focusNode: _effectiveFocusNode,
Expand Down
5 changes: 2 additions & 3 deletions optimus/lib/src/loader/spinner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ class _OptimusSpinnerState extends State<OptimusSpinner>
}

@override
Widget build(BuildContext context) => SizedBox(
width: widget.size.getSize(tokens),
height: widget.size.getSize(tokens),
Widget build(BuildContext context) => SizedBox.square(
dimension: widget.size.getSize(tokens),
child: AnimatedBuilder(
animation: _controller,
builder: (context, child) => Stack(
Expand Down
4 changes: 2 additions & 2 deletions optimus/lib/src/logo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class OptimusMewsLogo extends StatelessWidget {
Widget build(BuildContext context) {
final tokens = context.tokens;

return Container(
margin: _getMargin(tokens),
return Padding(
padding: _getMargin(tokens),
child: switch (logoVariant) {
OptimusMewsLogoVariant.logomark => _NonSquaredIcon(
OptimusIcons.mews_logo,
Expand Down
5 changes: 2 additions & 3 deletions optimus/lib/src/pictogram/pictogram.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ class OptimusPictogram extends StatelessWidget {
final OptimusPictogramSize size;

@override
Widget build(BuildContext context) => SizedBox(
width: size.getSize(context.tokens),
height: size.getSize(context.tokens),
Widget build(BuildContext context) => SizedBox.square(
dimension: size.getSize(context.tokens),
child: SvgPicture.asset(
variant.path(context.theme.brightness),
package: 'optimus',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,8 @@ class _DisabledIndicatorItem extends StatelessWidget {
final tokens = context.tokens;
final size = tokens.sizing300;

return SizedBox(
height: size,
width: size,
return SizedBox.square(
dimension: size,
child: Center(
child: Container(
constraints: BoxConstraints(
Expand Down
2 changes: 1 addition & 1 deletion optimus/lib/src/selection_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class _VerticalCard extends StatelessWidget {
top: context.tokens.spacing100,
child: selector,
),
Container(
Padding(
padding: EdgeInsets.symmetric(
horizontal: context.tokens.spacing200,
vertical: context.tokens.spacing400,
Expand Down
4 changes: 2 additions & 2 deletions optimus/lib/src/theme/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class OptimusTheme extends StatelessWidget {
final bool isDark = themeMode == ThemeMode.dark ||
(themeMode == ThemeMode.system && brightness == Brightness.dark);
final theme = isDark
? darkTheme ?? _defaultDarkTheme
: lightTheme ?? _defaultLightTheme;
? (darkTheme ?? _defaultDarkTheme)
: (lightTheme ?? _defaultLightTheme);

return _OptimusTheme(
theme: theme,
Expand Down
5 changes: 2 additions & 3 deletions optimus/lib/src/toggle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ class _Knob extends StatelessWidget {
final tokens = context.tokens;
final knobSize = tokens.sizing200;

return SizedBox(
width: knobSize,
height: knobSize,
return SizedBox.square(
dimension: knobSize,
child: DecoratedBox(
decoration: ShapeDecoration(
color: tokens.backgroundStaticFlat,
Expand Down
5 changes: 4 additions & 1 deletion optimus/lib/src/tooltip/tooltip_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class _OptimusTooltipWrapperState extends State<OptimusTooltipWrapper> {
tooltipPosition: widget.tooltipPosition,
content: widget.text,
),
child: Container(key: _anchorKey, child: widget.child),
child: KeyedSubtree(
key: _anchorKey,
child: widget.child,
),
);
}
4 changes: 2 additions & 2 deletions optimus_icons/utils/gen_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ void main(List<String> arguments) {
)
..writeln('const optimusIcons = <IconDetails>[');

for (int i = 0; i < icons.length; i++) {
final Map<String, dynamic> glyphs = icons[i] as Map<String, dynamic>;
for (final icon in icons) {
final Map<String, dynamic> glyphs = icon as Map<String, dynamic>;
final glyphName = convertGlyphName(glyphs['css'].toString());
buffer.writeln(
" IconDetails($fontFamilyName.$glyphName, '$glyphName'),",
Expand Down
5 changes: 2 additions & 3 deletions optimus_widgetbook/lib/components/layout/spacing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ Widget _buildSpacing(OptimusTokens tokens, double spacing, String label) =>
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
child: Row(
children: [
SizedBox(
width: spacing,
height: spacing,
SizedBox.square(
dimension: spacing,
child: Container(color: Colors.black),
),
Padding(
Expand Down

0 comments on commit 4dace5d

Please sign in to comment.