Skip to content

Commit

Permalink
chore: Ran lint command (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias authored Aug 31, 2024
1 parent 849dd55 commit 7cd122c
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 54 deletions.
27 changes: 14 additions & 13 deletions packages/mix/lib/src/modifiers/scroll_view_widget_modifier.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:mix/mix.dart';
import '../../mix.dart';
import 'package:mix_annotations/mix_annotations.dart';

part 'scroll_view_widget_modifier.g.dart';
Expand Down Expand Up @@ -44,6 +44,15 @@ final class ScrollViewModifierSpec

final class ScrollViewModifierSpecUtility<T extends Attribute>
extends MixUtility<T, ScrollViewModifierSpecAttribute> {
/// Make the scroll view reverse or not.
late final reverse = BoolUtility((reverse) => call(reverse: reverse));

/// Set the padding of the scroll view.
late final padding = SpacingUtility((padding) => call(padding: padding));

/// Set the clip behavior of the scroll view.
late final clipBehavior = ClipUtility((clip) => call(clipBehavior: clip));

ScrollViewModifierSpecUtility(super.builder);

/// Set the scroll direction of the scroll view.
Expand All @@ -55,26 +64,18 @@ final class ScrollViewModifierSpecUtility<T extends Attribute>
/// Set the scroll direction of the scroll view to vertical.
T vertical() => call(scrollDirection: Axis.vertical);

/// Make the scroll view reverse or not.
late final reverse = BoolUtility((reverse) => call(reverse: reverse));

/// Set the padding of the scroll view.
late final padding = SpacingUtility((padding) => call(padding: padding));

/// Set the physics of the scroll view.
T physics(ScrollPhysics physics) => call(physics: physics);

/// Disable the scroll physics of the scroll view.
T neverScrollableScrollPhysics() => physics(NeverScrollableScrollPhysics());
T neverScrollableScrollPhysics() =>
physics(const NeverScrollableScrollPhysics());

/// Set the iOS-style scroll physics of the scroll view.
T bouncingScrollPhysics() => physics(BouncingScrollPhysics());
T bouncingScrollPhysics() => physics(const BouncingScrollPhysics());

/// Set the Android-style scroll physics of the scroll view.
T clampingScrollPhysics() => physics(ClampingScrollPhysics());

/// Set the clip behavior of the scroll view.
late final clipBehavior = ClipUtility((clip) => call(clipBehavior: clip));
T clampingScrollPhysics() => physics(const ClampingScrollPhysics());

T call({
Axis? scrollDirection,
Expand Down
2 changes: 1 addition & 1 deletion packages/mix/lib/src/modifiers/widget_modifiers_util.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:mix/src/modifiers/mouse_cursor_modifier.dart';
import 'mouse_cursor_modifier.dart';

import '../core/attribute.dart';
import '../core/modifier.dart';
Expand Down
17 changes: 10 additions & 7 deletions packages/mix/lib/src/theme/mix/mix_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ class MixThemeData {
);
}

/// Combine all [themes] into a single [MixThemeData] root.
static MixThemeData combine(Iterable<MixThemeData> themes) {
if (themes.isEmpty) return const MixThemeData.empty();

return themes.fold(
const MixThemeData.empty(),
(previous, theme) => previous.merge(theme),
);
}

MixThemeData copyWith({
Map<BreakpointToken, Breakpoint>? breakpoints,
Map<ColorToken, Color>? colors,
Expand Down Expand Up @@ -132,13 +142,6 @@ class MixThemeData {
);
}

/// Combine all [themes] into a single [MixThemeData] root.
static MixThemeData combine(Iterable<MixThemeData> themes) {
if (themes.isEmpty) return const MixThemeData.empty();
return themes.fold(
const MixThemeData.empty(), (previous, theme) => previous.merge(theme));
}

@override
operator ==(Object other) {
if (identical(this, other)) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:mix/mix.dart';
void main() {
testWidgets('uses custom mouseCursor when provided',
(WidgetTester tester) async {
final cursor = SystemMouseCursors.resizeUpRight;
const cursor = SystemMouseCursors.resizeUpRight;
await tester.pumpWidget(
Box(
style: Style(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mix/mix.dart';
import 'package:mix/src/modifiers/scroll_view_widget_modifier.dart';

import '../../helpers/testing_utils.dart';

Expand All @@ -11,10 +10,10 @@ void main() {
'Build method creates SingleChildScrollView with correct parameters',
(tester) async {
const padding = EdgeInsets.all(8.0);
final axis = Axis.horizontal;
final reverse = true;
final clip = Clip.antiAlias;
final physics = const AlwaysScrollableScrollPhysics();
const axis = Axis.horizontal;
const reverse = true;
const clip = Clip.antiAlias;
const physics = AlwaysScrollableScrollPhysics();

final modifier = ScrollViewModifierSpec(
scrollDirection: axis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void main() {
});

testWidgets('is disposing the controller correcly', (widgetTester) async {
await widgetTester.pumpWidget(_DisposalPressable());
await widgetTester.pumpWidget(const _DisposalPressable());
});

testWidgets(
Expand Down Expand Up @@ -179,7 +179,7 @@ void main() {
$box.color.blue(),
),
),
child: Box(),
child: const Box(),
),
),
);
Expand Down Expand Up @@ -703,7 +703,7 @@ Future<void> pumpTestCase({
}

class _DisposalPressable extends StatefulWidget {
const _DisposalPressable({Key? key}) : super(key: key);
const _DisposalPressable();

@override
_DisposalPressableState createState() => _DisposalPressableState();
Expand All @@ -728,7 +728,7 @@ class _DisposalPressableState extends State<_DisposalPressable> {
Widget build(BuildContext context) {
return Pressable(
controller: _controller,
child: Box(),
child: const Box(),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void main() {
(WidgetTester tester) async {
final context = await tester.pumpAndGetContext(Container());

final variant = OnPlatformVariant(TargetPlatform.macOS);
const variant = OnPlatformVariant(TargetPlatform.macOS);

expect(variant.when(context), isTrue);
},
Expand All @@ -80,7 +80,7 @@ void main() {
(WidgetTester tester) async {
final context = await tester.pumpAndGetContext(Container());

final variant = OnPlatformVariant(TargetPlatform.windows);
const variant = OnPlatformVariant(TargetPlatform.windows);

expect(variant.when(context), isTrue);
},
Expand All @@ -92,7 +92,7 @@ void main() {
(WidgetTester tester) async {
final context = await tester.pumpAndGetContext(Container());

final variant = OnPlatformVariant(TargetPlatform.linux);
const variant = OnPlatformVariant(TargetPlatform.linux);

expect(variant.when(context), isTrue);
},
Expand All @@ -107,7 +107,7 @@ void main() {
MixHelpers.isWebOverride = true;
final context = await tester.pumpAndGetContext(Container());

final variant = OnWebVariant();
const variant = OnWebVariant();

expect(variant.when(context), isTrue);
MixHelpers.isWebOverride = null;
Expand Down
24 changes: 12 additions & 12 deletions packages/mix_annotations/test/annotations_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ void main() {
group('MixableSpec', () {
group('MixableDto', () {
test('should create instance with default values', () {
final dto = MixableDto();
const dto = MixableDto();
expect(dto.mergeLists, isTrue);
expect(dto.generateValueExtension, isTrue);
expect(dto.generateUtility, isTrue);
});

test('should create instance with provided values', () {
final dto = MixableDto(
const dto = MixableDto(
mergeLists: false,
generateValueExtension: false,
generateUtility: false);
Expand All @@ -24,14 +24,14 @@ void main() {

group('MixableProperty', () {
test('should create instance with default values', () {
final property = MixableProperty();
const property = MixableProperty();
expect(property.dto, isNull);
expect(property.utilities, isNull);
});

test('should create instance with provided values', () {
final dto = MixableFieldDto(type: String);
final utilities = [MixableUtility(alias: 'util', type: int)];
const dto = MixableFieldDto(type: String);
final utilities = [const MixableUtility(alias: 'util', type: int)];
final property = MixableProperty(dto: dto, utilities: utilities);
expect(property.dto, equals(dto));
expect(property.utilities, equals(utilities));
Expand All @@ -40,27 +40,27 @@ void main() {

group('MixableFieldDto', () {
test('should create instance with default values', () {
final dto = MixableFieldDto();
const dto = MixableFieldDto();
expect(dto.type, isNull);
});

test('should create instance with provided values', () {
final dto = MixableFieldDto(type: int);
const dto = MixableFieldDto(type: int);
expect(dto.type, equals(int));
});

test('typeAsString should return string representation of type', () {
final dto1 = MixableFieldDto(type: 'String');
const dto1 = MixableFieldDto(type: 'String');
expect(dto1.typeAsString, equals('String'));

final dto2 = MixableFieldDto(type: int);
const dto2 = MixableFieldDto(type: int);
expect(dto2.typeAsString, equals('int'));
});
});

group('MixableUtility', () {
test('should create instance with default values', () {
final utility = MixableUtility();
const utility = MixableUtility();
expect(utility.alias, isNull);
expect(utility.type, isNull);
expect(utility.properties, isEmpty);
Expand All @@ -76,10 +76,10 @@ void main() {
});

test('typeAsString should return string representation of type', () {
final utility1 = MixableUtility(type: 'String');
const utility1 = MixableUtility(type: 'String');
expect(utility1.typeAsString, equals('String'));

final utility2 = MixableUtility(type: int);
const utility2 = MixableUtility(type: int);
expect(utility2.typeAsString, equals('int'));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ Future<void> main() async {

testAnnotatedElements<MixableSpec>(
readerForSpecCase,
MixableSpecGenerator(),
const MixableSpecGenerator(),
);

testAnnotatedElements<MixableDto>(
readerForDtoCase,
MixableDtoGenerator(),
const MixableDtoGenerator(),
);
}
10 changes: 5 additions & 5 deletions packages/mix_lint/lib/mix_lint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class _MixLint extends PluginBase {

@override
List<LintRule> getLintRules(CustomLintConfigs configs) => [
AttributesOrdering(),
AvoidDefiningTokensOrVariantsWithinStyle(),
AvoidDefiningTokensWithinThemeData(),
AvoidVariantInsideContextVariant(),
AvoidEmptyVariants(),
const AttributesOrdering(),
const AvoidDefiningTokensOrVariantsWithinStyle(),
const AvoidDefiningTokensWithinThemeData(),
const AvoidVariantInsideContextVariant(),
const AvoidEmptyVariants(),
MaxNumberOfAttributesPerStyle.fromConfig(configs),
];
}

0 comments on commit 7cd122c

Please sign in to comment.