-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Support to Flutter 3.24.0 (#440)
* chore: Support to Flutter 3.24.0 * Update action.yml * Update widget_tester.dart * ignore undefined_hidden_name * box * box * box * fix todoList * fix golden tests * fix generation * add withNullability * update custom_lint * Update action.yml * retaking golden tests * fix pipeline * Update todo_list_page.dart
- Loading branch information
1 parent
0f81f15
commit 0d9bc96
Showing
15 changed files
with
98 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/mix_lint/lib/src/lints/avoid_variant_inside_context_variant.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ dependencies: | |
remix: | ||
path: ../ | ||
|
||
mix: ^1.4.5 | ||
mix: ^1.4.4 | ||
|
||
dev_dependencies: | ||
flutter_test: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import 'utils/extensions/local_file_comparator.dart'; | ||
|
||
/// Customise your threshold here | ||
/// For example, the error threshold here is 0.5% | ||
/// Golden tests will pass if the pixel difference is equal to or below 0.5% | ||
const _kGoldenTestsThreshold = 0.5 / 100; | ||
|
||
Future<void> testExecutable(FutureOr<void> Function() testMain) async { | ||
if (goldenFileComparator is LocalFileComparator) { | ||
final testUrl = (goldenFileComparator as LocalFileComparator).basedir; | ||
|
||
goldenFileComparator = LocalFileComparatorWithThreshold( | ||
// flutter_test's LocalFileComparator expects the test's URI to be passed | ||
// as an argument, but it only uses it to parse the baseDir in order to | ||
// obtain the directory where the golden tests will be placed. | ||
// As such, we use the default `testUrl`, which is only the `baseDir` and | ||
// append a generically named `test.dart` so that the `baseDir` is | ||
// properly extracted. | ||
Uri.parse('$testUrl/test.dart'), | ||
_kGoldenTestsThreshold, | ||
); | ||
} else { | ||
throw Exception( | ||
'Expected `goldenFileComparator` to be of type `LocalFileComparator`, ' | ||
'but it is of type `${goldenFileComparator.runtimeType}`', | ||
); | ||
} | ||
|
||
await testMain(); | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/remix/test/utils/extensions/local_file_comparator.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
/// Works just like [LocalFileComparator] but includes a [threshold] that, when | ||
/// exceeded, marks the test as a failure. | ||
class LocalFileComparatorWithThreshold extends LocalFileComparator { | ||
/// Threshold above which tests will be marked as failing. | ||
/// Ranges from 0 to 1, both inclusive. | ||
final double threshold; | ||
|
||
LocalFileComparatorWithThreshold(Uri testFile, this.threshold) | ||
: assert(threshold >= 0 && threshold <= 1), | ||
super(testFile); | ||
|
||
/// Copy of [LocalFileComparator]'s [compare] method, except for the fact that | ||
/// it checks if the [ComparisonResult.diffPercent] is not greater than | ||
/// [threshold] to decide whether this test is successful or a failure. | ||
@override | ||
Future<bool> compare(Uint8List imageBytes, Uri golden) async { | ||
final result = await GoldenFileComparator.compareLists( | ||
imageBytes, | ||
await getGoldenBytes(golden), | ||
); | ||
|
||
if (!result.passed && result.diffPercent <= threshold) { | ||
debugPrint( | ||
'A difference of ${result.diffPercent * 100}% was found, but it is ' | ||
'acceptable since it is not greater than the threshold of ' | ||
'${threshold * 100}%', | ||
); | ||
|
||
return true; | ||
} | ||
|
||
if (!result.passed) { | ||
final error = await generateFailureOutput(result, golden, basedir); | ||
throw FlutterError(error); | ||
} | ||
return result.passed; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters