mirror of
https://github.com/flutter/flutter
synced 2024-10-04 15:29:52 +00:00
Enable no_leading_underscores_for_local_identifiers (#96422)
This commit is contained in:
parent
53ca7f684a
commit
5684b9f69e
|
@ -136,7 +136,7 @@ linter:
|
|||
- no_default_cases
|
||||
- no_duplicate_case_values
|
||||
- no_leading_underscores_for_library_prefixes
|
||||
# - no_leading_underscores_for_local_identifiers # not yet tested
|
||||
- no_leading_underscores_for_local_identifiers
|
||||
- no_logic_in_create_state
|
||||
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
|
||||
- non_constant_identifier_names
|
||||
|
|
|
@ -120,9 +120,9 @@ class ResampleFlagVariant extends TestVariant<TestScenario> {
|
|||
}
|
||||
|
||||
Future<void> main() async {
|
||||
final WidgetsBinding _binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
assert(_binding is IntegrationTestWidgetsFlutterBinding);
|
||||
final IntegrationTestWidgetsFlutterBinding binding = _binding as IntegrationTestWidgetsFlutterBinding;
|
||||
final WidgetsBinding widgetsBinding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
assert(widgetsBinding is IntegrationTestWidgetsFlutterBinding);
|
||||
final IntegrationTestWidgetsFlutterBinding binding = widgetsBinding as IntegrationTestWidgetsFlutterBinding;
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive;
|
||||
binding.reportData ??= <String, dynamic>{};
|
||||
final ResampleFlagVariant variant = ResampleFlagVariant(binding);
|
||||
|
|
|
@ -38,9 +38,9 @@ void macroPerfTestMultiPageE2E(
|
|||
ControlCallback? body,
|
||||
ControlCallback? setup,
|
||||
}) {
|
||||
final WidgetsBinding _binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
assert(_binding is IntegrationTestWidgetsFlutterBinding);
|
||||
final IntegrationTestWidgetsFlutterBinding binding = _binding as IntegrationTestWidgetsFlutterBinding;
|
||||
final WidgetsBinding widgetsBinding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
||||
assert(widgetsBinding is IntegrationTestWidgetsFlutterBinding);
|
||||
final IntegrationTestWidgetsFlutterBinding binding = widgetsBinding as IntegrationTestWidgetsFlutterBinding;
|
||||
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmarkLive;
|
||||
|
||||
testWidgets(testName, (WidgetTester tester) async {
|
||||
|
|
|
@ -23,47 +23,47 @@ void main() {
|
|||
);
|
||||
}
|
||||
|
||||
final List<Matrix4> _affineTransforms = <Matrix4>[
|
||||
final List<Matrix4> affineTransforms = <Matrix4>[
|
||||
Matrix4.identity()..scale(1.2, 1.3, 1.0)..rotateZ(0.1),
|
||||
Matrix4.identity()..translate(12.0, 13.0, 10.0),
|
||||
Matrix4.identity()..scale(1.2, 1.3, 1.0)..translate(12.0, 13.0, 10.0),
|
||||
];
|
||||
final List<Matrix4> _perspectiveTransforms = <Matrix4>[
|
||||
final List<Matrix4> perspectiveTransforms = <Matrix4>[
|
||||
_makePerspective(10.0, math.pi / 8.0, 0.3),
|
||||
_makePerspective( 8.0, math.pi / 8.0, 0.2),
|
||||
_makePerspective( 1.0, math.pi / 4.0, 0.1)..rotateX(0.1),
|
||||
];
|
||||
final List<Rect> _rectangles = <Rect>[
|
||||
final List<Rect> rectangles = <Rect>[
|
||||
const Rect.fromLTRB(1.1, 1.2, 1.5, 1.8),
|
||||
const Rect.fromLTRB(1.1, 1.2, 0.0, 1.0),
|
||||
const Rect.fromLTRB(1.1, 1.2, 1.3, 1.0),
|
||||
const Rect.fromLTRB(-1.1, -1.2, 0.0, 1.0),
|
||||
const Rect.fromLTRB(-1.1, -1.2, -1.5, -1.8),
|
||||
];
|
||||
final List<Offset> _offsets = <Offset>[
|
||||
final List<Offset> offsets = <Offset>[
|
||||
const Offset(1.1, 1.2),
|
||||
const Offset(1.5, 1.8),
|
||||
Offset.zero,
|
||||
const Offset(-1.1, -1.2),
|
||||
const Offset(-1.5, -1.8),
|
||||
];
|
||||
final int nAffine = _affineTransforms.length;
|
||||
final int nPerspective = _perspectiveTransforms.length;
|
||||
final int nRectangles = _rectangles.length;
|
||||
final int nOffsets = _offsets.length;
|
||||
final int nAffine = affineTransforms.length;
|
||||
final int nPerspective = perspectiveTransforms.length;
|
||||
final int nRectangles = rectangles.length;
|
||||
final int nOffsets = offsets.length;
|
||||
|
||||
// Warm up lap
|
||||
for (int i = 0; i < _kNumWarmUp; i += 1) {
|
||||
final Matrix4 transform = _perspectiveTransforms[i % nPerspective];
|
||||
final Rect rect = _rectangles[(i ~/ nPerspective) % nRectangles];
|
||||
final Offset offset = _offsets[(i ~/ nPerspective) % nOffsets];
|
||||
final Matrix4 transform = perspectiveTransforms[i % nPerspective];
|
||||
final Rect rect = rectangles[(i ~/ nPerspective) % nRectangles];
|
||||
final Offset offset = offsets[(i ~/ nPerspective) % nOffsets];
|
||||
MatrixUtils.transformRect(transform, rect);
|
||||
MatrixUtils.transformPoint(transform, offset);
|
||||
}
|
||||
for (int i = 0; i < _kNumWarmUp; i += 1) {
|
||||
final Matrix4 transform = _affineTransforms[i % nAffine];
|
||||
final Rect rect = _rectangles[(i ~/ nAffine) % nRectangles];
|
||||
final Offset offset = _offsets[(i ~/ nAffine) % nOffsets];
|
||||
final Matrix4 transform = affineTransforms[i % nAffine];
|
||||
final Rect rect = rectangles[(i ~/ nAffine) % nRectangles];
|
||||
final Offset offset = offsets[(i ~/ nAffine) % nOffsets];
|
||||
MatrixUtils.transformRect(transform, rect);
|
||||
MatrixUtils.transformPoint(transform, offset);
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ void main() {
|
|||
final Stopwatch watch = Stopwatch();
|
||||
watch.start();
|
||||
for (int i = 0; i < _kNumIterations; i += 1) {
|
||||
final Matrix4 transform = _perspectiveTransforms[i % nPerspective];
|
||||
final Rect rect = _rectangles[(i ~/ nPerspective) % nRectangles];
|
||||
final Matrix4 transform = perspectiveTransforms[i % nPerspective];
|
||||
final Rect rect = rectangles[(i ~/ nPerspective) % nRectangles];
|
||||
MatrixUtils.transformRect(transform, rect);
|
||||
}
|
||||
watch.stop();
|
||||
|
@ -81,8 +81,8 @@ void main() {
|
|||
watch.reset();
|
||||
watch.start();
|
||||
for (int i = 0; i < _kNumIterations; i += 1) {
|
||||
final Matrix4 transform = _affineTransforms[i % nAffine];
|
||||
final Rect rect = _rectangles[(i ~/ nAffine) % nRectangles];
|
||||
final Matrix4 transform = affineTransforms[i % nAffine];
|
||||
final Rect rect = rectangles[(i ~/ nAffine) % nRectangles];
|
||||
MatrixUtils.transformRect(transform, rect);
|
||||
}
|
||||
watch.stop();
|
||||
|
@ -91,8 +91,8 @@ void main() {
|
|||
watch.reset();
|
||||
watch.start();
|
||||
for (int i = 0; i < _kNumIterations; i += 1) {
|
||||
final Matrix4 transform = _perspectiveTransforms[i % nPerspective];
|
||||
final Offset offset = _offsets[(i ~/ nPerspective) % nOffsets];
|
||||
final Matrix4 transform = perspectiveTransforms[i % nPerspective];
|
||||
final Offset offset = offsets[(i ~/ nPerspective) % nOffsets];
|
||||
MatrixUtils.transformPoint(transform, offset);
|
||||
}
|
||||
watch.stop();
|
||||
|
@ -101,8 +101,8 @@ void main() {
|
|||
watch.reset();
|
||||
watch.start();
|
||||
for (int i = 0; i < _kNumIterations; i += 1) {
|
||||
final Matrix4 transform = _affineTransforms[i % nAffine];
|
||||
final Offset offset = _offsets[(i ~/ nAffine) % nOffsets];
|
||||
final Matrix4 transform = affineTransforms[i % nAffine];
|
||||
final Offset offset = offsets[(i ~/ nAffine) % nOffsets];
|
||||
MatrixUtils.transformPoint(transform, offset);
|
||||
}
|
||||
watch.stop();
|
||||
|
|
|
@ -351,7 +351,7 @@ class BlinkTraceSummary {
|
|||
averageBeginFrameTime: _computeAverageDuration(frames.map((BlinkFrame frame) => frame.beginFrame).whereType<BlinkTraceEvent>().toList()),
|
||||
averageUpdateLifecyclePhasesTime: _computeAverageDuration(frames.map((BlinkFrame frame) => frame.updateAllLifecyclePhases).whereType<BlinkTraceEvent>().toList()),
|
||||
);
|
||||
} catch (_, __) {
|
||||
} catch (_) {
|
||||
final io.File traceFile = io.File('./chrome-trace.json');
|
||||
io.stderr.writeln('Failed to interpret the Chrome trace contents. The trace was saved in ${traceFile.path}');
|
||||
traceFile.writeAsStringSync(const JsonEncoder.withIndent(' ').convert(traceJson));
|
||||
|
|
|
@ -177,12 +177,12 @@ class GalleryTransitionTest {
|
|||
}
|
||||
|
||||
int _countMissedTransitions(Map<String, List<int>> transitions) {
|
||||
const int _kTransitionBudget = 100000; // µs
|
||||
const int kTransitionBudget = 100000; // µs
|
||||
int count = 0;
|
||||
transitions.forEach((String demoName, List<int> durations) {
|
||||
final int longestDuration = durations.reduce(math.max);
|
||||
if (longestDuration > _kTransitionBudget) {
|
||||
print('$demoName missed transition time budget ($longestDuration µs > $_kTransitionBudget µs)');
|
||||
if (longestDuration > kTransitionBudget) {
|
||||
print('$demoName missed transition time budget ($longestDuration µs > $kTransitionBudget µs)');
|
||||
count++;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ import 'package:http/testing.dart';
|
|||
import 'common.dart';
|
||||
|
||||
void main() {
|
||||
late ProcessResult _processResult;
|
||||
late ProcessResult processResult;
|
||||
ProcessResult runSyncStub(String executable, List<String> args,
|
||||
{Map<String, String>? environment,
|
||||
bool includeParentEnvironment = true,
|
||||
|
@ -24,7 +24,7 @@ void main() {
|
|||
Encoding? stderrEncoding,
|
||||
Encoding? stdoutEncoding,
|
||||
String? workingDirectory}) =>
|
||||
_processResult;
|
||||
processResult;
|
||||
|
||||
// Expected test values.
|
||||
const String commitSha = 'a4952838bf288a81d8ea11edfd4b4cd649fa94cc';
|
||||
|
@ -45,7 +45,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('returns expected commit sha', () {
|
||||
_processResult = ProcessResult(1, 0, commitSha, '');
|
||||
processResult = ProcessResult(1, 0, commitSha, '');
|
||||
cocoon = Cocoon(
|
||||
serviceAccountTokenPath: serviceAccountTokenPath,
|
||||
fs: fs,
|
||||
|
@ -57,7 +57,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('throws exception on git cli errors', () {
|
||||
_processResult = ProcessResult(1, 1, '', '');
|
||||
processResult = ProcessResult(1, 1, '', '');
|
||||
cocoon = Cocoon(
|
||||
serviceAccountTokenPath: serviceAccountTokenPath,
|
||||
fs: fs,
|
||||
|
@ -69,7 +69,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('writes expected update task json', () async {
|
||||
_processResult = ProcessResult(1, 0, commitSha, '');
|
||||
processResult = ProcessResult(1, 0, commitSha, '');
|
||||
final TaskResult result = TaskResult.fromJson(<String, dynamic>{
|
||||
'success': true,
|
||||
'data': <String, dynamic>{
|
||||
|
@ -105,7 +105,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('uploads metrics sends expected post body', () async {
|
||||
_processResult = ProcessResult(1, 0, commitSha, '');
|
||||
processResult = ProcessResult(1, 0, commitSha, '');
|
||||
const String uploadMetricsRequestWithSpaces =
|
||||
'{"CommitBranch":"master","CommitSha":"a4952838bf288a81d8ea11edfd4b4cd649fa94cc","BuilderName":"builder a b c","NewStatus":"Succeeded","ResultData":{},"BenchmarkScoreKeys":[],"TestFlaky":false}';
|
||||
final MockClient client = MockClient((Request request) async {
|
||||
|
@ -136,7 +136,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('uploads expected update task payload from results file', () async {
|
||||
_processResult = ProcessResult(1, 0, commitSha, '');
|
||||
processResult = ProcessResult(1, 0, commitSha, '');
|
||||
cocoon = Cocoon(
|
||||
fs: fs,
|
||||
httpClient: mockClient,
|
||||
|
@ -168,7 +168,7 @@ void main() {
|
|||
}
|
||||
});
|
||||
|
||||
_processResult = ProcessResult(1, 0, commitSha, '');
|
||||
processResult = ProcessResult(1, 0, commitSha, '');
|
||||
cocoon = Cocoon(
|
||||
fs: fs,
|
||||
httpClient: mockClient,
|
||||
|
@ -202,7 +202,7 @@ void main() {
|
|||
}
|
||||
});
|
||||
|
||||
_processResult = ProcessResult(1, 0, commitSha, '');
|
||||
processResult = ProcessResult(1, 0, commitSha, '');
|
||||
cocoon = Cocoon(
|
||||
fs: fs,
|
||||
httpClient: mockClient,
|
||||
|
@ -237,7 +237,7 @@ void main() {
|
|||
}
|
||||
});
|
||||
|
||||
_processResult = ProcessResult(1, 0, commitSha, '');
|
||||
processResult = ProcessResult(1, 0, commitSha, '');
|
||||
cocoon = Cocoon(
|
||||
fs: fs,
|
||||
httpClient: mockClient,
|
||||
|
@ -270,7 +270,7 @@ void main() {
|
|||
}
|
||||
});
|
||||
|
||||
_processResult = ProcessResult(1, 0, commitSha, '');
|
||||
processResult = ProcessResult(1, 0, commitSha, '');
|
||||
cocoon = Cocoon(
|
||||
fs: fs,
|
||||
httpClient: mockClient,
|
||||
|
|
|
@ -30,8 +30,8 @@ class MyStatelessWidget extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const int _rowCount = 48;
|
||||
const int _columnCount = 6;
|
||||
const int rowCount = 48;
|
||||
const int columnCount = 6;
|
||||
|
||||
return InteractiveViewer(
|
||||
alignPanAxis: true,
|
||||
|
@ -39,14 +39,14 @@ class MyStatelessWidget extends StatelessWidget {
|
|||
scaleEnabled: false,
|
||||
child: Table(
|
||||
columnWidths: <int, TableColumnWidth>{
|
||||
for (int column = 0; column < _columnCount; column += 1)
|
||||
for (int column = 0; column < columnCount; column += 1)
|
||||
column: const FixedColumnWidth(200.0),
|
||||
},
|
||||
children: <TableRow>[
|
||||
for (int row = 0; row < _rowCount; row += 1)
|
||||
for (int row = 0; row < rowCount; row += 1)
|
||||
TableRow(
|
||||
children: <Widget>[
|
||||
for (int column = 0; column < _columnCount; column += 1)
|
||||
for (int column = 0; column < columnCount; column += 1)
|
||||
Container(
|
||||
height: 26,
|
||||
color: row % 2 + column % 2 == 1
|
||||
|
|
|
@ -27,9 +27,9 @@ class MyStatelessWidget extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<String> _tabs = <String>['Tab 1', 'Tab 2'];
|
||||
final List<String> tabs = <String>['Tab 1', 'Tab 2'];
|
||||
return DefaultTabController(
|
||||
length: _tabs.length, // This is the number of tabs.
|
||||
length: tabs.length, // This is the number of tabs.
|
||||
child: Scaffold(
|
||||
body: NestedScrollView(
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
|
@ -61,7 +61,7 @@ class MyStatelessWidget extends StatelessWidget {
|
|||
forceElevated: innerBoxIsScrolled,
|
||||
bottom: TabBar(
|
||||
// These are the widgets to put in each tab in the tab bar.
|
||||
tabs: _tabs.map((String name) => Tab(text: name)).toList(),
|
||||
tabs: tabs.map((String name) => Tab(text: name)).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -69,7 +69,7 @@ class MyStatelessWidget extends StatelessWidget {
|
|||
},
|
||||
body: TabBarView(
|
||||
// These are the contents of the tab views, below the tabs.
|
||||
children: _tabs.map((String name) {
|
||||
children: tabs.map((String name) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
|
|
|
@ -25,19 +25,20 @@ class MyApp extends StatelessWidget {
|
|||
class MyStatelessWidget extends StatelessWidget {
|
||||
const MyStatelessWidget({Key? key}) : super(key: key);
|
||||
|
||||
static const List<String> _tabs = <String>['Months', 'Days'];
|
||||
static const List<String> _months = <String>[
|
||||
'January',
|
||||
'February',
|
||||
'March',
|
||||
];
|
||||
static const List<String> _days = <String>[
|
||||
'Sunday',
|
||||
'Monday',
|
||||
'Tuesday',
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const List<String> _tabs = <String>['Months', 'Days'];
|
||||
const List<String> _months = <String>[
|
||||
'January',
|
||||
'February',
|
||||
'March',
|
||||
];
|
||||
const List<String> _days = <String>[
|
||||
'Sunday',
|
||||
'Monday',
|
||||
'Tuesday',
|
||||
];
|
||||
return DefaultTabController(
|
||||
length: _tabs.length,
|
||||
child: Scaffold(
|
||||
|
|
|
@ -898,9 +898,9 @@ class _RepeatingSimulation extends Simulation {
|
|||
|
||||
final double totalTimeInSeconds = timeInSeconds + _initialT;
|
||||
final double t = (totalTimeInSeconds / _periodInSeconds) % 1.0;
|
||||
final bool _isPlayingReverse = (totalTimeInSeconds ~/ _periodInSeconds).isOdd;
|
||||
final bool isPlayingReverse = (totalTimeInSeconds ~/ _periodInSeconds).isOdd;
|
||||
|
||||
if (reverse && _isPlayingReverse) {
|
||||
if (reverse && isPlayingReverse) {
|
||||
directionSetter(_AnimationDirection.reverse);
|
||||
return ui.lerpDouble(max, min, t)!;
|
||||
} else {
|
||||
|
|
|
@ -1003,9 +1003,9 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
|
|||
}
|
||||
}
|
||||
|
||||
Element? _debugContext;
|
||||
Element? debugContext;
|
||||
assert(() {
|
||||
_debugContext = context as Element;
|
||||
debugContext = context as Element;
|
||||
return true;
|
||||
}());
|
||||
return CupertinoDynamicColor._(
|
||||
|
@ -1018,7 +1018,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
|
|||
darkElevatedColor,
|
||||
highContrastElevatedColor,
|
||||
darkHighContrastElevatedColor,
|
||||
_debugContext,
|
||||
debugContext,
|
||||
_debugLabel,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -91,10 +91,10 @@ class CupertinoPageScaffold extends StatefulWidget {
|
|||
class _CupertinoPageScaffoldState extends State<CupertinoPageScaffold> {
|
||||
|
||||
void _handleStatusBarTap() {
|
||||
final ScrollController? _primaryScrollController = PrimaryScrollController.of(context);
|
||||
final ScrollController? primaryScrollController = PrimaryScrollController.of(context);
|
||||
// Only act on the scroll controller if it has any attached scroll positions.
|
||||
if (_primaryScrollController != null && _primaryScrollController.hasClients) {
|
||||
_primaryScrollController.animateTo(
|
||||
if (primaryScrollController != null && primaryScrollController.hasClients) {
|
||||
primaryScrollController.animateTo(
|
||||
0.0,
|
||||
// Eyeballed from iOS.
|
||||
duration: const Duration(milliseconds: 500),
|
||||
|
|
|
@ -360,8 +360,8 @@ class _SegmentedControlState<T extends Object> extends State<CupertinoSegmentedC
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final List<Widget> _gestureChildren = <Widget>[];
|
||||
final List<Color> _backgroundColors = <Color>[];
|
||||
final List<Widget> gestureChildren = <Widget>[];
|
||||
final List<Color> backgroundColors = <Color>[];
|
||||
int index = 0;
|
||||
int? selectedIndex;
|
||||
int? pressedIndex;
|
||||
|
@ -403,17 +403,17 @@ class _SegmentedControlState<T extends Object> extends State<CupertinoSegmentedC
|
|||
),
|
||||
);
|
||||
|
||||
_backgroundColors.add(getBackgroundColor(index, currentKey)!);
|
||||
_gestureChildren.add(child);
|
||||
backgroundColors.add(getBackgroundColor(index, currentKey)!);
|
||||
gestureChildren.add(child);
|
||||
index += 1;
|
||||
}
|
||||
|
||||
final Widget box = _SegmentedControlRenderWidget<T>(
|
||||
selectedIndex: selectedIndex,
|
||||
pressedIndex: pressedIndex,
|
||||
backgroundColors: _backgroundColors,
|
||||
backgroundColors: backgroundColors,
|
||||
borderColor: _borderColor!,
|
||||
children: _gestureChildren,
|
||||
children: gestureChildren,
|
||||
);
|
||||
|
||||
return Padding(
|
||||
|
|
|
@ -28,19 +28,19 @@ class BitField<T extends dynamic> implements bitfield.BitField<T> {
|
|||
|
||||
@override
|
||||
bool operator [](T index) {
|
||||
final int _index = index.index as int;
|
||||
assert(_index < _length);
|
||||
return (_bits & 1 << _index) > 0;
|
||||
final int intIndex = index.index as int;
|
||||
assert(intIndex < _length);
|
||||
return (_bits & 1 << intIndex) > 0;
|
||||
}
|
||||
|
||||
@override
|
||||
void operator []=(T index, bool value) {
|
||||
final int _index = index.index as int;
|
||||
assert(_index < _length);
|
||||
final int intIndex = index.index as int;
|
||||
assert(intIndex < _length);
|
||||
if (value)
|
||||
_bits = _bits | (1 << _index);
|
||||
_bits = _bits | (1 << intIndex);
|
||||
else
|
||||
_bits = _bits & ~(1 << _index);
|
||||
_bits = _bits & ~(1 << intIndex);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -232,8 +232,8 @@ class ChangeNotifier implements Listenable {
|
|||
void removeListener(VoidCallback listener) {
|
||||
assert(_debugAssertNotDisposed());
|
||||
for (int i = 0; i < _count; i++) {
|
||||
final VoidCallback? _listener = _listeners[i];
|
||||
if (_listener == listener) {
|
||||
final VoidCallback? listenerAtIndex = _listeners[i];
|
||||
if (listenerAtIndex == listener) {
|
||||
if (_notificationCallStackDepth > 0) {
|
||||
// We don't resize the list during notifyListeners iterations
|
||||
// but we set to null, the listeners we want to remove. We will
|
||||
|
|
|
@ -1855,7 +1855,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid
|
|||
/// gets closer to 2 the label padding is linearly interpolated from 8px to 4px.
|
||||
/// Once the widget has a text scaling of 2 or higher than the label padding
|
||||
/// remains 4px.
|
||||
final EdgeInsetsGeometry _defaultLabelPadding = EdgeInsets.lerp(
|
||||
final EdgeInsetsGeometry defaultLabelPadding = EdgeInsets.lerp(
|
||||
const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
(MediaQuery.of(context).textScaleFactor - 1.0).clamp(0.0, 1.0),
|
||||
|
@ -1905,7 +1905,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid
|
|||
final EdgeInsetsGeometry labelPadding = widget.labelPadding
|
||||
?? chipTheme.labelPadding
|
||||
?? theme.chipTheme.labelPadding
|
||||
?? _defaultLabelPadding;
|
||||
?? defaultLabelPadding;
|
||||
|
||||
final TextStyle effectiveLabelStyle = labelStyle.merge(widget.labelStyle);
|
||||
final Color? resolvedLabelColor = MaterialStateProperty.resolveAs<Color?>(effectiveLabelStyle.color, materialStates);
|
||||
|
|
|
@ -1197,11 +1197,11 @@ class ListTile extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
const EdgeInsets _defaultContentPadding = EdgeInsets.symmetric(horizontal: 16.0);
|
||||
const EdgeInsets defaultContentPadding = EdgeInsets.symmetric(horizontal: 16.0);
|
||||
final TextDirection textDirection = Directionality.of(context);
|
||||
final EdgeInsets resolvedContentPadding = contentPadding?.resolve(textDirection)
|
||||
?? tileTheme.contentPadding?.resolve(textDirection)
|
||||
?? _defaultContentPadding;
|
||||
?? defaultContentPadding;
|
||||
|
||||
final MouseCursor resolvedMouseCursor = MaterialStateProperty.resolveAs<MouseCursor>(
|
||||
mouseCursor ?? MaterialStateMouseCursor.clickable,
|
||||
|
|
|
@ -117,21 +117,21 @@ mixin MaterialStateMixin<T extends StatefulWidget> on State<T> {
|
|||
|
||||
/// Mutator to mark a [MaterialState] value as either active or inactive.
|
||||
@protected
|
||||
void setMaterialState(MaterialState _state, bool isSet) {
|
||||
return isSet ? addMaterialState(_state) : removeMaterialState(_state);
|
||||
void setMaterialState(MaterialState state, bool isSet) {
|
||||
return isSet ? addMaterialState(state) : removeMaterialState(state);
|
||||
}
|
||||
|
||||
/// Mutator to mark a [MaterialState] value as active.
|
||||
@protected
|
||||
void addMaterialState(MaterialState _state) {
|
||||
if (materialStates.add(_state))
|
||||
void addMaterialState(MaterialState state) {
|
||||
if (materialStates.add(state))
|
||||
setState((){});
|
||||
}
|
||||
|
||||
/// Mutator to mark a [MaterialState] value as inactive.
|
||||
@protected
|
||||
void removeMaterialState(MaterialState _state) {
|
||||
if (materialStates.remove(_state))
|
||||
void removeMaterialState(MaterialState state) {
|
||||
if (materialStates.remove(state))
|
||||
setState((){});
|
||||
}
|
||||
|
||||
|
|
|
@ -561,20 +561,20 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
|
|||
// the default shapes and text styles are aligned to the Material
|
||||
// Guidelines.
|
||||
|
||||
const double _defaultTrackHeight = 4;
|
||||
const RangeSliderTrackShape _defaultTrackShape = RoundedRectRangeSliderTrackShape();
|
||||
const RangeSliderTickMarkShape _defaultTickMarkShape = RoundRangeSliderTickMarkShape();
|
||||
const SliderComponentShape _defaultOverlayShape = RoundSliderOverlayShape();
|
||||
const RangeSliderThumbShape _defaultThumbShape = RoundRangeSliderThumbShape();
|
||||
const RangeSliderValueIndicatorShape _defaultValueIndicatorShape = RectangularRangeSliderValueIndicatorShape();
|
||||
const ShowValueIndicator _defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete;
|
||||
const double _defaultMinThumbSeparation = 8;
|
||||
const double defaultTrackHeight = 4;
|
||||
const RangeSliderTrackShape defaultTrackShape = RoundedRectRangeSliderTrackShape();
|
||||
const RangeSliderTickMarkShape defaultTickMarkShape = RoundRangeSliderTickMarkShape();
|
||||
const SliderComponentShape defaultOverlayShape = RoundSliderOverlayShape();
|
||||
const RangeSliderThumbShape defaultThumbShape = RoundRangeSliderThumbShape();
|
||||
const RangeSliderValueIndicatorShape defaultValueIndicatorShape = RectangularRangeSliderValueIndicatorShape();
|
||||
const ShowValueIndicator defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete;
|
||||
const double defaultMinThumbSeparation = 8;
|
||||
|
||||
// The value indicator's color is not the same as the thumb and active track
|
||||
// (which can be defined by activeColor) if the
|
||||
// RectangularSliderValueIndicatorShape is used. In all other cases, the
|
||||
// value indicator is assumed to be the same as the active color.
|
||||
final RangeSliderValueIndicatorShape valueIndicatorShape = sliderTheme.rangeValueIndicatorShape ?? _defaultValueIndicatorShape;
|
||||
final RangeSliderValueIndicatorShape valueIndicatorShape = sliderTheme.rangeValueIndicatorShape ?? defaultValueIndicatorShape;
|
||||
final Color valueIndicatorColor;
|
||||
if (valueIndicatorShape is RectangularRangeSliderValueIndicatorShape) {
|
||||
valueIndicatorColor = sliderTheme.valueIndicatorColor ?? Color.alphaBlend(theme.colorScheme.onSurface.withOpacity(0.60), theme.colorScheme.surface.withOpacity(0.90));
|
||||
|
@ -583,7 +583,7 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
|
|||
}
|
||||
|
||||
sliderTheme = sliderTheme.copyWith(
|
||||
trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight,
|
||||
trackHeight: sliderTheme.trackHeight ?? defaultTrackHeight,
|
||||
activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary,
|
||||
inactiveTrackColor: widget.inactiveColor ?? sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24),
|
||||
disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.32),
|
||||
|
@ -597,16 +597,16 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
|
|||
disabledThumbColor: sliderTheme.disabledThumbColor ?? Color.alphaBlend(theme.colorScheme.onSurface.withOpacity(.38), theme.colorScheme.surface),
|
||||
overlayColor: widget.activeColor?.withOpacity(0.12) ?? sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12),
|
||||
valueIndicatorColor: valueIndicatorColor,
|
||||
rangeTrackShape: sliderTheme.rangeTrackShape ?? _defaultTrackShape,
|
||||
rangeTickMarkShape: sliderTheme.rangeTickMarkShape ?? _defaultTickMarkShape,
|
||||
rangeThumbShape: sliderTheme.rangeThumbShape ?? _defaultThumbShape,
|
||||
overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape,
|
||||
rangeTrackShape: sliderTheme.rangeTrackShape ?? defaultTrackShape,
|
||||
rangeTickMarkShape: sliderTheme.rangeTickMarkShape ?? defaultTickMarkShape,
|
||||
rangeThumbShape: sliderTheme.rangeThumbShape ?? defaultThumbShape,
|
||||
overlayShape: sliderTheme.overlayShape ?? defaultOverlayShape,
|
||||
rangeValueIndicatorShape: valueIndicatorShape,
|
||||
showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator,
|
||||
showValueIndicator: sliderTheme.showValueIndicator ?? defaultShowValueIndicator,
|
||||
valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.bodyText1!.copyWith(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
),
|
||||
minThumbSeparation: sliderTheme.minThumbSeparation ?? _defaultMinThumbSeparation,
|
||||
minThumbSeparation: sliderTheme.minThumbSeparation ?? defaultMinThumbSeparation,
|
||||
thumbSelector: sliderTheme.thumbSelector ?? _defaultRangeThumbSelector,
|
||||
);
|
||||
|
||||
|
|
|
@ -2253,22 +2253,22 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||
// will not be added to the Scaffold's appbar and the bottom sheet will not
|
||||
// support drag or swipe to dismiss.
|
||||
final AnimationController animationController = BottomSheet.createAnimationController(this)..value = 1.0;
|
||||
LocalHistoryEntry? _persistentSheetHistoryEntry;
|
||||
LocalHistoryEntry? persistentSheetHistoryEntry;
|
||||
bool _persistentBottomSheetExtentChanged(DraggableScrollableNotification notification) {
|
||||
if (notification.extent > notification.initialExtent) {
|
||||
if (_persistentSheetHistoryEntry == null) {
|
||||
_persistentSheetHistoryEntry = LocalHistoryEntry(onRemove: () {
|
||||
if (persistentSheetHistoryEntry == null) {
|
||||
persistentSheetHistoryEntry = LocalHistoryEntry(onRemove: () {
|
||||
if (notification.extent > notification.initialExtent) {
|
||||
DraggableScrollableActuator.reset(notification.context);
|
||||
}
|
||||
showBodyScrim(false, 0.0);
|
||||
_floatingActionButtonVisibilityValue = 1.0;
|
||||
_persistentSheetHistoryEntry = null;
|
||||
persistentSheetHistoryEntry = null;
|
||||
});
|
||||
ModalRoute.of(context)!.addLocalHistoryEntry(_persistentSheetHistoryEntry!);
|
||||
ModalRoute.of(context)!.addLocalHistoryEntry(persistentSheetHistoryEntry!);
|
||||
}
|
||||
} else if (_persistentSheetHistoryEntry != null) {
|
||||
ModalRoute.of(context)!.removeLocalHistoryEntry(_persistentSheetHistoryEntry!);
|
||||
} else if (persistentSheetHistoryEntry != null) {
|
||||
ModalRoute.of(context)!.removeLocalHistoryEntry(persistentSheetHistoryEntry!);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2557,9 +2557,9 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||
// top. We implement this by looking up the primary scroll controller and
|
||||
// scrolling it to the top when tapped.
|
||||
void _handleStatusBarTap() {
|
||||
final ScrollController? _primaryScrollController = PrimaryScrollController.of(context);
|
||||
if (_primaryScrollController != null && _primaryScrollController.hasClients) {
|
||||
_primaryScrollController.animateTo(
|
||||
final ScrollController? primaryScrollController = PrimaryScrollController.of(context);
|
||||
if (primaryScrollController != null && primaryScrollController.hasClients) {
|
||||
primaryScrollController.animateTo(
|
||||
0.0,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.linear, // TODO(ianh): Use a more appropriate curve.
|
||||
|
@ -2635,14 +2635,14 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||
void didChangeDependencies() {
|
||||
// Using maybeOf is valid here since both the Scaffold and ScaffoldMessenger
|
||||
// are currently available for managing SnackBars.
|
||||
final ScaffoldMessengerState? _currentScaffoldMessenger = ScaffoldMessenger.maybeOf(context);
|
||||
final ScaffoldMessengerState? currentScaffoldMessenger = ScaffoldMessenger.maybeOf(context);
|
||||
// If our ScaffoldMessenger has changed, unregister with the old one first.
|
||||
if (_scaffoldMessenger != null &&
|
||||
(_currentScaffoldMessenger == null || _scaffoldMessenger != _currentScaffoldMessenger)) {
|
||||
(currentScaffoldMessenger == null || _scaffoldMessenger != currentScaffoldMessenger)) {
|
||||
_scaffoldMessenger?._unregister(this);
|
||||
}
|
||||
// Register with the current ScaffoldMessenger, if there is one.
|
||||
_scaffoldMessenger = _currentScaffoldMessenger;
|
||||
_scaffoldMessenger = currentScaffoldMessenger;
|
||||
_scaffoldMessenger?._register(this);
|
||||
|
||||
// TODO(Piinks): Remove old SnackBar API after migrating ScaffoldMessenger
|
||||
|
@ -3064,7 +3064,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||
);
|
||||
|
||||
// extendBody locked when keyboard is open
|
||||
final bool _extendBody = minInsets.bottom <= 0 && widget.extendBody;
|
||||
final bool extendBody = minInsets.bottom <= 0 && widget.extendBody;
|
||||
|
||||
return _ScaffoldScope(
|
||||
hasDrawer: hasDrawer,
|
||||
|
@ -3075,7 +3075,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
|
|||
child: AnimatedBuilder(animation: _floatingActionButtonMoveController, builder: (BuildContext context, Widget? child) {
|
||||
return CustomMultiChildLayout(
|
||||
delegate: _ScaffoldLayout(
|
||||
extendBody: _extendBody,
|
||||
extendBody: extendBody,
|
||||
extendBodyBehindAppBar: widget.extendBodyBehindAppBar,
|
||||
minInsets: minInsets,
|
||||
minViewPadding: minViewPadding,
|
||||
|
|
|
@ -659,19 +659,19 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
|
|||
// the default shapes and text styles are aligned to the Material
|
||||
// Guidelines.
|
||||
|
||||
const double _defaultTrackHeight = 4;
|
||||
const SliderTrackShape _defaultTrackShape = RoundedRectSliderTrackShape();
|
||||
const SliderTickMarkShape _defaultTickMarkShape = RoundSliderTickMarkShape();
|
||||
const SliderComponentShape _defaultOverlayShape = RoundSliderOverlayShape();
|
||||
const SliderComponentShape _defaultThumbShape = RoundSliderThumbShape();
|
||||
const SliderComponentShape _defaultValueIndicatorShape = RectangularSliderValueIndicatorShape();
|
||||
const ShowValueIndicator _defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete;
|
||||
const double defaultTrackHeight = 4;
|
||||
const SliderTrackShape defaultTrackShape = RoundedRectSliderTrackShape();
|
||||
const SliderTickMarkShape defaultTickMarkShape = RoundSliderTickMarkShape();
|
||||
const SliderComponentShape defaultOverlayShape = RoundSliderOverlayShape();
|
||||
const SliderComponentShape defaultThumbShape = RoundSliderThumbShape();
|
||||
const SliderComponentShape defaultValueIndicatorShape = RectangularSliderValueIndicatorShape();
|
||||
const ShowValueIndicator defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete;
|
||||
|
||||
// The value indicator's color is not the same as the thumb and active track
|
||||
// (which can be defined by activeColor) if the
|
||||
// RectangularSliderValueIndicatorShape is used. In all other cases, the
|
||||
// value indicator is assumed to be the same as the active color.
|
||||
final SliderComponentShape valueIndicatorShape = sliderTheme.valueIndicatorShape ?? _defaultValueIndicatorShape;
|
||||
final SliderComponentShape valueIndicatorShape = sliderTheme.valueIndicatorShape ?? defaultValueIndicatorShape;
|
||||
final Color valueIndicatorColor;
|
||||
if (valueIndicatorShape is RectangularSliderValueIndicatorShape) {
|
||||
valueIndicatorColor = sliderTheme.valueIndicatorColor ?? Color.alphaBlend(theme.colorScheme.onSurface.withOpacity(0.60), theme.colorScheme.surface.withOpacity(0.90));
|
||||
|
@ -680,7 +680,7 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
|
|||
}
|
||||
|
||||
sliderTheme = sliderTheme.copyWith(
|
||||
trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight,
|
||||
trackHeight: sliderTheme.trackHeight ?? defaultTrackHeight,
|
||||
activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary,
|
||||
inactiveTrackColor: widget.inactiveColor ?? sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24),
|
||||
disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.32),
|
||||
|
@ -693,12 +693,12 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
|
|||
disabledThumbColor: sliderTheme.disabledThumbColor ?? Color.alphaBlend(theme.colorScheme.onSurface.withOpacity(.38), theme.colorScheme.surface),
|
||||
overlayColor: widget.activeColor?.withOpacity(0.12) ?? sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12),
|
||||
valueIndicatorColor: valueIndicatorColor,
|
||||
trackShape: sliderTheme.trackShape ?? _defaultTrackShape,
|
||||
tickMarkShape: sliderTheme.tickMarkShape ?? _defaultTickMarkShape,
|
||||
thumbShape: sliderTheme.thumbShape ?? _defaultThumbShape,
|
||||
overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape,
|
||||
trackShape: sliderTheme.trackShape ?? defaultTrackShape,
|
||||
tickMarkShape: sliderTheme.tickMarkShape ?? defaultTickMarkShape,
|
||||
thumbShape: sliderTheme.thumbShape ?? defaultThumbShape,
|
||||
overlayShape: sliderTheme.overlayShape ?? defaultOverlayShape,
|
||||
valueIndicatorShape: valueIndicatorShape,
|
||||
showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator,
|
||||
showValueIndicator: sliderTheme.showValueIndicator ?? defaultShowValueIndicator,
|
||||
valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.bodyText1!.copyWith(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
),
|
||||
|
|
|
@ -413,10 +413,10 @@ class ThemeData with Diagnosticable {
|
|||
assert(colorSchemeSeed == null || colorScheme == null);
|
||||
assert(colorSchemeSeed == null || primarySwatch == null);
|
||||
assert(colorSchemeSeed == null || primaryColor == null);
|
||||
final Brightness _brightness = brightness ?? colorScheme?.brightness ?? Brightness.light;
|
||||
final bool isDark = _brightness == Brightness.dark;
|
||||
final Brightness effectiveBrightness = brightness ?? colorScheme?.brightness ?? Brightness.light;
|
||||
final bool isDark = effectiveBrightness == Brightness.dark;
|
||||
if (colorSchemeSeed != null) {
|
||||
colorScheme = ColorScheme.fromSeed(seedColor: colorSchemeSeed, brightness: _brightness);
|
||||
colorScheme = ColorScheme.fromSeed(seedColor: colorSchemeSeed, brightness: effectiveBrightness);
|
||||
|
||||
// For surfaces that use primary color in light themes and surface color in dark
|
||||
final Color primarySurfaceColor = isDark ? colorScheme.surface : colorScheme.primary;
|
||||
|
@ -441,10 +441,10 @@ class ThemeData with Diagnosticable {
|
|||
applyElevationOverlayColor ??= false;
|
||||
primarySwatch ??= Colors.blue;
|
||||
primaryColor ??= isDark ? Colors.grey[900]! : primarySwatch;
|
||||
final Brightness _primaryColorBrightness = estimateBrightnessForColor(primaryColor);
|
||||
final Brightness estimatedPrimaryColorBrightness = estimateBrightnessForColor(primaryColor);
|
||||
primaryColorLight ??= isDark ? Colors.grey[500]! : primarySwatch[100]!;
|
||||
primaryColorDark ??= isDark ? Colors.black : primarySwatch[700]!;
|
||||
final bool primaryIsDark = _primaryColorBrightness == Brightness.dark;
|
||||
final bool primaryIsDark = estimatedPrimaryColorBrightness == Brightness.dark;
|
||||
toggleableActiveColor ??= isDark ? Colors.tealAccent[200]! : (accentColor ?? primarySwatch[600]!);
|
||||
accentColor ??= isDark ? Colors.tealAccent[200]! : primarySwatch[500]!;
|
||||
accentColorBrightness ??= estimateBrightnessForColor(accentColor);
|
||||
|
@ -466,7 +466,7 @@ class ThemeData with Diagnosticable {
|
|||
cardColor: cardColor,
|
||||
backgroundColor: backgroundColor,
|
||||
errorColor: errorColor,
|
||||
brightness: _brightness,
|
||||
brightness: effectiveBrightness,
|
||||
);
|
||||
selectedRowColor ??= Colors.grey[100]!;
|
||||
unselectedWidgetColor ??= isDark ? Colors.white70 : Colors.black54;
|
||||
|
@ -551,7 +551,7 @@ class ThemeData with Diagnosticable {
|
|||
accentIconTheme ??= accentIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black);
|
||||
buttonColor ??= isDark ? primarySwatch[600]! : Colors.grey[300]!;
|
||||
fixTextFieldOutlineLabel ??= true;
|
||||
primaryColorBrightness = _primaryColorBrightness;
|
||||
primaryColorBrightness = estimatedPrimaryColorBrightness;
|
||||
|
||||
return ThemeData.raw(
|
||||
// GENERAL CONFIGURATION
|
||||
|
|
|
@ -1203,7 +1203,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
|
|||
];
|
||||
|
||||
List<_TappableLabel> _buildMinutes(TextTheme textTheme, Color color) {
|
||||
const List<TimeOfDay> _minuteMarkerValues = <TimeOfDay>[
|
||||
const List<TimeOfDay> minuteMarkerValues = <TimeOfDay>[
|
||||
TimeOfDay(hour: 0, minute: 0),
|
||||
TimeOfDay(hour: 0, minute: 5),
|
||||
TimeOfDay(hour: 0, minute: 10),
|
||||
|
@ -1219,7 +1219,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
|
|||
];
|
||||
|
||||
return <_TappableLabel>[
|
||||
for (final TimeOfDay timeOfDay in _minuteMarkerValues)
|
||||
for (final TimeOfDay timeOfDay in minuteMarkerValues)
|
||||
_buildTappableLabel(
|
||||
textTheme,
|
||||
color,
|
||||
|
|
|
@ -1981,14 +1981,14 @@ abstract class RenderBox extends RenderObject {
|
|||
Size get size {
|
||||
assert(hasSize, 'RenderBox was not laid out: ${toString()}');
|
||||
assert(() {
|
||||
final Size? _size = this._size;
|
||||
if (_size is _DebugSize) {
|
||||
assert(_size._owner == this);
|
||||
final Size? size = _size;
|
||||
if (size is _DebugSize) {
|
||||
assert(size._owner == this);
|
||||
if (RenderObject.debugActiveLayout != null &&
|
||||
!RenderObject.debugActiveLayout!.debugDoingThisLayoutWithCallback) {
|
||||
assert(
|
||||
debugDoingThisResize || debugDoingThisLayout || _computingThisDryLayout ||
|
||||
(RenderObject.debugActiveLayout == parent && _size._canBeUsedByParent),
|
||||
(RenderObject.debugActiveLayout == parent && size._canBeUsedByParent),
|
||||
'RenderBox.size accessed beyond the scope of resize, layout, or '
|
||||
'permitted parent access. RenderBox can always access its own size, '
|
||||
'otherwise, the only object that is allowed to read RenderBox.size '
|
||||
|
@ -1997,7 +1997,7 @@ abstract class RenderBox extends RenderObject {
|
|||
"that child's layout().",
|
||||
);
|
||||
}
|
||||
assert(_size == this._size);
|
||||
assert(size == _size);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
|
|
|
@ -3300,8 +3300,8 @@ mixin ContainerRenderObjectMixin<ChildType extends RenderObject, ParentDataType
|
|||
// insert at the start (_firstChild)
|
||||
childParentData.nextSibling = _firstChild;
|
||||
if (_firstChild != null) {
|
||||
final ParentDataType _firstChildParentData = _firstChild!.parentData! as ParentDataType;
|
||||
_firstChildParentData.previousSibling = child;
|
||||
final ParentDataType firstChildParentData = _firstChild!.parentData! as ParentDataType;
|
||||
firstChildParentData.previousSibling = child;
|
||||
}
|
||||
_firstChild = child;
|
||||
_lastChild ??= child;
|
||||
|
|
|
@ -172,9 +172,9 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
|
|||
|
||||
// This is run in another isolate created by _addLicenses above.
|
||||
static List<LicenseEntry> _parseLicenses(String rawLicenses) {
|
||||
final String _licenseSeparator = '\n${'-' * 80}\n';
|
||||
final String licenseSeparator = '\n${'-' * 80}\n';
|
||||
final List<LicenseEntry> result = <LicenseEntry>[];
|
||||
final List<String> licenses = rawLicenses.split(_licenseSeparator);
|
||||
final List<String> licenses = rawLicenses.split(licenseSeparator);
|
||||
for (final String license in licenses) {
|
||||
final int split = license.indexOf('\n\n');
|
||||
if (split >= 0) {
|
||||
|
|
|
@ -83,9 +83,9 @@ class LogicalKeyboardKey extends KeyboardKey {
|
|||
const int valueMaskWidth = 32;
|
||||
|
||||
// Equivalent to assert(divisorForValueMask == (1 << valueMaskWidth)).
|
||||
const int _firstDivisorWidth = 28;
|
||||
const int firstDivisorWidth = 28;
|
||||
assert(divisorForValueMask ==
|
||||
(1 << _firstDivisorWidth) * (1 << (valueMaskWidth - _firstDivisorWidth)));
|
||||
(1 << firstDivisorWidth) * (1 << (valueMaskWidth - firstDivisorWidth)));
|
||||
|
||||
// JS only supports up to 2^53 - 1, therefore non-value bits can only
|
||||
// contain (maxSafeIntegerWidth - valueMaskWidth) bits.
|
||||
|
|
|
@ -428,7 +428,7 @@ class NestedScrollViewState extends State<NestedScrollView> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ScrollPhysics _scrollPhysics = widget.physics?.applyTo(const ClampingScrollPhysics())
|
||||
final ScrollPhysics scrollPhysics = widget.physics?.applyTo(const ClampingScrollPhysics())
|
||||
?? widget.scrollBehavior?.getScrollPhysics(context).applyTo(const ClampingScrollPhysics())
|
||||
?? const ClampingScrollPhysics();
|
||||
|
||||
|
@ -441,7 +441,7 @@ class NestedScrollViewState extends State<NestedScrollView> {
|
|||
dragStartBehavior: widget.dragStartBehavior,
|
||||
scrollDirection: widget.scrollDirection,
|
||||
reverse: widget.reverse,
|
||||
physics: _scrollPhysics,
|
||||
physics: scrollPhysics,
|
||||
scrollBehavior: widget.scrollBehavior ?? ScrollConfiguration.of(context).copyWith(scrollbars: false),
|
||||
controller: _coordinator!._outerController,
|
||||
slivers: widget._buildSlivers(
|
||||
|
|
|
@ -135,10 +135,10 @@ class _RestorablePrimitiveValueN<T extends Object?> extends RestorableValue<T> {
|
|||
// _RestorablePrimitiveValue and its subclasses are non-nullable.
|
||||
// See [_RestorablePrimitiveValueN] for the nullable version of this class.
|
||||
class _RestorablePrimitiveValue<T extends Object> extends _RestorablePrimitiveValueN<T> {
|
||||
_RestorablePrimitiveValue(T _defaultValue)
|
||||
: assert(_defaultValue != null),
|
||||
assert(debugIsSerializableForRestoration(_defaultValue)),
|
||||
super(_defaultValue);
|
||||
_RestorablePrimitiveValue(T defaultValue)
|
||||
: assert(defaultValue != null),
|
||||
assert(debugIsSerializableForRestoration(defaultValue)),
|
||||
super(defaultValue);
|
||||
|
||||
@override
|
||||
set value(T value) {
|
||||
|
|
|
@ -9,17 +9,16 @@ import '../rendering/mock_canvas.dart';
|
|||
|
||||
void main() {
|
||||
// Constants taken from _ContextMenuActionState.
|
||||
const CupertinoDynamicColor _kBackgroundColor = CupertinoDynamicColor.withBrightness(
|
||||
const CupertinoDynamicColor kBackgroundColor = CupertinoDynamicColor.withBrightness(
|
||||
color: Color(0xFFEEEEEE),
|
||||
darkColor: Color(0xFF212122),
|
||||
);
|
||||
// static const Color _kBackgroundColorPressed = Color(0xFFDDDDDD);
|
||||
const CupertinoDynamicColor _kBackgroundColorPressed = CupertinoDynamicColor.withBrightness(
|
||||
const CupertinoDynamicColor kBackgroundColorPressed = CupertinoDynamicColor.withBrightness(
|
||||
color: Color(0xFFDDDDDD),
|
||||
darkColor: Color(0xFF3F3F40),
|
||||
);
|
||||
const Color _kDestructiveActionColor = CupertinoColors.destructiveRed;
|
||||
const FontWeight _kDefaultActionWeight = FontWeight.w600;
|
||||
const Color kDestructiveActionColor = CupertinoColors.destructiveRed;
|
||||
const FontWeight kDefaultActionWeight = FontWeight.w600;
|
||||
|
||||
Widget _getApp({
|
||||
VoidCallback? onPressed,
|
||||
|
@ -82,28 +81,28 @@ void main() {
|
|||
|
||||
testWidgets('turns grey when pressed and held', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_getApp());
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColor.color));
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColor.color));
|
||||
|
||||
final Offset actionCenterLight = tester.getCenter(find.byType(CupertinoContextMenuAction));
|
||||
final TestGesture gestureLight = await tester.startGesture(actionCenterLight);
|
||||
await tester.pump();
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColorPressed.color));
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColorPressed.color));
|
||||
|
||||
await gestureLight.up();
|
||||
await tester.pump();
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColor.color));
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColor.color));
|
||||
|
||||
await tester.pumpWidget(_getApp(brightness: Brightness.dark));
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColor.darkColor));
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColor.darkColor));
|
||||
|
||||
final Offset actionCenterDark = tester.getCenter(find.byType(CupertinoContextMenuAction));
|
||||
final TestGesture gestureDark = await tester.startGesture(actionCenterDark);
|
||||
await tester.pump();
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColorPressed.darkColor));
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColorPressed.darkColor));
|
||||
|
||||
await gestureDark.up();
|
||||
await tester.pump();
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: _kBackgroundColor.darkColor));
|
||||
expect(find.byType(CupertinoContextMenuAction), paints..rect(color: kBackgroundColor.darkColor));
|
||||
});
|
||||
|
||||
testWidgets('icon and textStyle colors are correct out of the box', (WidgetTester tester) async {
|
||||
|
@ -114,13 +113,13 @@ void main() {
|
|||
|
||||
testWidgets('icon and textStyle colors are correct for destructive actions', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_getApp(isDestructiveAction: true));
|
||||
expect(_getTextStyle(tester).color, _kDestructiveActionColor);
|
||||
expect(_getIcon(tester).color, _kDestructiveActionColor);
|
||||
expect(_getTextStyle(tester).color, kDestructiveActionColor);
|
||||
expect(_getIcon(tester).color, kDestructiveActionColor);
|
||||
});
|
||||
|
||||
testWidgets('textStyle is correct for defaultAction', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_getApp(isDefaultAction: true));
|
||||
expect(_getTextStyle(tester).fontWeight, _kDefaultActionWeight);
|
||||
expect(_getTextStyle(tester).fontWeight, kDefaultActionWeight);
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
|
|||
void main() {
|
||||
final TestWidgetsFlutterBinding binding =
|
||||
TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
|
||||
const double _kOpenScale = 1.1;
|
||||
const double kOpenScale = 1.1;
|
||||
Widget _getChild() {
|
||||
return Container(
|
||||
width: 300.0,
|
||||
|
@ -120,7 +120,7 @@ void main() {
|
|||
await tester.pump(const Duration(milliseconds: 500));
|
||||
decoyChildRect = tester.getRect(_findDecoyChild(child));
|
||||
expect(childRect, isNot(equals(decoyChildRect)));
|
||||
expect(decoyChildRect.width, childRect.width * _kOpenScale);
|
||||
expect(decoyChildRect.width, childRect.width * kOpenScale);
|
||||
|
||||
// Then the CupertinoContextMenu opens.
|
||||
await tester.pumpAndSettle();
|
||||
|
@ -185,7 +185,7 @@ void main() {
|
|||
await tester.pump(const Duration(milliseconds: 500));
|
||||
decoyChildRect = tester.getRect(_findDecoyChild(child));
|
||||
expect(childRect, isNot(equals(decoyChildRect)));
|
||||
expect(decoyChildRect.width, childRect.width * _kOpenScale);
|
||||
expect(decoyChildRect.width, childRect.width * kOpenScale);
|
||||
|
||||
// Then the CupertinoContextMenu opens.
|
||||
await tester.pumpAndSettle();
|
||||
|
|
|
@ -1543,7 +1543,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup transparent barrier color is transparent', (WidgetTester tester) async {
|
||||
const Color _kTransparentColor = Color(0x00000000);
|
||||
const Color kTransparentColor = Color(0x00000000);
|
||||
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
|
@ -1553,7 +1553,7 @@ void main() {
|
|||
await showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => const SizedBox(),
|
||||
barrierColor: _kTransparentColor,
|
||||
barrierColor: kTransparentColor,
|
||||
);
|
||||
},
|
||||
child: const Text('tap'),
|
||||
|
|
|
@ -17,10 +17,10 @@ const CupertinoDynamicColor _kScrollbarColor = CupertinoDynamicColor.withBrightn
|
|||
);
|
||||
|
||||
void main() {
|
||||
const Duration _kScrollbarTimeToFade = Duration(milliseconds: 1200);
|
||||
const Duration _kScrollbarFadeDuration = Duration(milliseconds: 250);
|
||||
const Duration _kScrollbarResizeDuration = Duration(milliseconds: 100);
|
||||
const Duration _kLongPressDuration = Duration(milliseconds: 100);
|
||||
const Duration kScrollbarTimeToFade = Duration(milliseconds: 1200);
|
||||
const Duration kScrollbarFadeDuration = Duration(milliseconds: 250);
|
||||
const Duration kScrollbarResizeDuration = Duration(milliseconds: 100);
|
||||
const Duration kLongPressDuration = Duration(milliseconds: 100);
|
||||
|
||||
testWidgets('Scrollbar never goes away until finger lift', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
|
@ -51,8 +51,8 @@ void main() {
|
|||
));
|
||||
|
||||
await gesture.up();
|
||||
await tester.pump(_kScrollbarTimeToFade);
|
||||
await tester.pump(_kScrollbarFadeDuration * 0.5);
|
||||
await tester.pump(kScrollbarTimeToFade);
|
||||
await tester.pump(kScrollbarFadeDuration * 0.5);
|
||||
|
||||
// Opacity going down now.
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect(
|
||||
|
@ -143,9 +143,9 @@ void main() {
|
|||
// Long press on the scrollbar thumb and expect a vibration after it resizes.
|
||||
expect(hapticFeedbackCalls, 0);
|
||||
final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(796.0, 50.0));
|
||||
await tester.pump(_kLongPressDuration);
|
||||
await tester.pump(kLongPressDuration);
|
||||
expect(hapticFeedbackCalls, 0);
|
||||
await tester.pump(_kScrollbarResizeDuration);
|
||||
await tester.pump(kScrollbarResizeDuration);
|
||||
// Allow the haptic feedback some slack.
|
||||
await tester.pump(const Duration(milliseconds: 1));
|
||||
expect(hapticFeedbackCalls, 1);
|
||||
|
@ -165,8 +165,8 @@ void main() {
|
|||
));
|
||||
|
||||
// Let the thumb fade out so all timers have resolved.
|
||||
await tester.pump(_kScrollbarTimeToFade);
|
||||
await tester.pump(_kScrollbarFadeDuration);
|
||||
await tester.pump(kScrollbarTimeToFade);
|
||||
await tester.pump(kScrollbarFadeDuration);
|
||||
});
|
||||
|
||||
testWidgets('Scrollbar thumb can be dragged with long press - reverse', (WidgetTester tester) async {
|
||||
|
@ -217,9 +217,9 @@ void main() {
|
|||
// Long press on the scrollbar thumb and expect a vibration after it resizes.
|
||||
expect(hapticFeedbackCalls, 0);
|
||||
final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(796.0, 550.0));
|
||||
await tester.pump(_kLongPressDuration);
|
||||
await tester.pump(kLongPressDuration);
|
||||
expect(hapticFeedbackCalls, 0);
|
||||
await tester.pump(_kScrollbarResizeDuration);
|
||||
await tester.pump(kScrollbarResizeDuration);
|
||||
// Allow the haptic feedback some slack.
|
||||
await tester.pump(const Duration(milliseconds: 1));
|
||||
expect(hapticFeedbackCalls, 1);
|
||||
|
@ -239,8 +239,8 @@ void main() {
|
|||
));
|
||||
|
||||
// Let the thumb fade out so all timers have resolved.
|
||||
await tester.pump(_kScrollbarTimeToFade);
|
||||
await tester.pump(_kScrollbarFadeDuration);
|
||||
await tester.pump(kScrollbarTimeToFade);
|
||||
await tester.pump(kScrollbarFadeDuration);
|
||||
});
|
||||
|
||||
testWidgets('Scrollbar changes thickness and radius when dragged', (WidgetTester tester) async {
|
||||
|
@ -294,7 +294,7 @@ void main() {
|
|||
|
||||
// Long press on the scrollbar thumb and expect it to grow
|
||||
final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(780.0, 50.0));
|
||||
await tester.pump(_kLongPressDuration);
|
||||
await tester.pump(kLongPressDuration);
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect(
|
||||
rrect: RRect.fromRectAndRadius(
|
||||
Rect.fromLTWH(
|
||||
|
@ -306,7 +306,7 @@ void main() {
|
|||
const Radius.circular(radius),
|
||||
),
|
||||
));
|
||||
await tester.pump(_kScrollbarResizeDuration ~/ 2);
|
||||
await tester.pump(kScrollbarResizeDuration ~/ 2);
|
||||
const double midpointThickness = (thickness + thicknessWhileDragging) / 2;
|
||||
const double midpointRadius = (radius + radiusWhileDragging) / 2;
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect(
|
||||
|
@ -320,7 +320,7 @@ void main() {
|
|||
const Radius.circular(midpointRadius),
|
||||
),
|
||||
));
|
||||
await tester.pump(_kScrollbarResizeDuration ~/ 2);
|
||||
await tester.pump(kScrollbarResizeDuration ~/ 2);
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect(
|
||||
rrect: RRect.fromRectAndRadius(
|
||||
Rect.fromLTWH(
|
||||
|
@ -336,8 +336,8 @@ void main() {
|
|||
// Let the thumb fade out so all timers have resolved.
|
||||
await dragScrollbarGesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump(_kScrollbarTimeToFade);
|
||||
await tester.pump(_kScrollbarFadeDuration);
|
||||
await tester.pump(kScrollbarTimeToFade);
|
||||
await tester.pump(kScrollbarFadeDuration);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
|
@ -674,7 +674,7 @@ void main() {
|
|||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
|
||||
// Wait for the timer delay to expire.
|
||||
await tester.pump(const Duration(milliseconds: 600)); // _kScrollbarTimeToFade
|
||||
await tester.pump(const Duration(milliseconds: 600)); // kScrollbarTimeToFade
|
||||
await tester.pumpAndSettle();
|
||||
// Scrollbar thumb is showing after scroll finishes and timer ends.
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
|
@ -784,9 +784,9 @@ void main() {
|
|||
// Long press on the scrollbar thumb and expect a vibration after it resizes.
|
||||
expect(hapticFeedbackCalls, 0);
|
||||
final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(50.0, 596.0));
|
||||
await tester.pump(_kLongPressDuration);
|
||||
await tester.pump(kLongPressDuration);
|
||||
expect(hapticFeedbackCalls, 0);
|
||||
await tester.pump(_kScrollbarResizeDuration);
|
||||
await tester.pump(kScrollbarResizeDuration);
|
||||
// Allow the haptic feedback some slack.
|
||||
await tester.pump(const Duration(milliseconds: 1));
|
||||
expect(hapticFeedbackCalls, 1);
|
||||
|
@ -806,8 +806,8 @@ void main() {
|
|||
));
|
||||
|
||||
// Let the thumb fade out so all timers have resolved.
|
||||
await tester.pump(_kScrollbarTimeToFade);
|
||||
await tester.pump(_kScrollbarFadeDuration);
|
||||
await tester.pump(kScrollbarTimeToFade);
|
||||
await tester.pump(kScrollbarFadeDuration);
|
||||
});
|
||||
|
||||
testWidgets('Scrollbar thumb can be dragged with long press - horizontal axis, reverse', (WidgetTester tester) async {
|
||||
|
@ -858,9 +858,9 @@ void main() {
|
|||
// Long press on the scrollbar thumb and expect a vibration after it resizes.
|
||||
expect(hapticFeedbackCalls, 0);
|
||||
final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(750.0, 596.0));
|
||||
await tester.pump(_kLongPressDuration);
|
||||
await tester.pump(kLongPressDuration);
|
||||
expect(hapticFeedbackCalls, 0);
|
||||
await tester.pump(_kScrollbarResizeDuration);
|
||||
await tester.pump(kScrollbarResizeDuration);
|
||||
// Allow the haptic feedback some slack.
|
||||
await tester.pump(const Duration(milliseconds: 1));
|
||||
expect(hapticFeedbackCalls, 1);
|
||||
|
@ -880,8 +880,8 @@ void main() {
|
|||
));
|
||||
|
||||
// Let the thumb fade out so all timers have resolved.
|
||||
await tester.pump(_kScrollbarTimeToFade);
|
||||
await tester.pump(_kScrollbarFadeDuration);
|
||||
await tester.pump(kScrollbarTimeToFade);
|
||||
await tester.pump(kScrollbarFadeDuration);
|
||||
});
|
||||
|
||||
testWidgets('Tapping the track area pages the Scroll View', (WidgetTester tester) async {
|
||||
|
@ -1015,8 +1015,8 @@ void main() {
|
|||
),
|
||||
);
|
||||
final TestGesture dragScrollbarGesture = await tester.startGesture(const Offset(796.0, 50.0));
|
||||
await tester.pump(_kLongPressDuration);
|
||||
await tester.pump(_kScrollbarResizeDuration);
|
||||
await tester.pump(kLongPressDuration);
|
||||
await tester.pump(kScrollbarResizeDuration);
|
||||
|
||||
// Drag the thumb down to scroll down.
|
||||
await dragScrollbarGesture.moveBy(const Offset(0.0, scrollAmount));
|
||||
|
|
|
@ -136,14 +136,14 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('onFieldSubmit callbacks are called', (WidgetTester tester) async {
|
||||
bool _called = false;
|
||||
bool called = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
child: CupertinoTextFormFieldRow(
|
||||
onFieldSubmitted: (String value) {
|
||||
_called = true;
|
||||
called = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -153,18 +153,18 @@ void main() {
|
|||
await tester.showKeyboard(find.byType(CupertinoTextField));
|
||||
await tester.testTextInput.receiveAction(TextInputAction.done);
|
||||
await tester.pump();
|
||||
expect(_called, true);
|
||||
expect(called, true);
|
||||
});
|
||||
|
||||
testWidgets('onChanged callbacks are called', (WidgetTester tester) async {
|
||||
late String _value;
|
||||
late String value;
|
||||
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
child: CupertinoTextFormFieldRow(
|
||||
onChanged: (String value) {
|
||||
_value = value;
|
||||
onChanged: (String v) {
|
||||
value = v;
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -173,11 +173,11 @@ void main() {
|
|||
|
||||
await tester.enterText(find.byType(CupertinoTextField), 'Soup');
|
||||
await tester.pump();
|
||||
expect(_value, 'Soup');
|
||||
expect(value, 'Soup');
|
||||
});
|
||||
|
||||
testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async {
|
||||
int _validateCalled = 0;
|
||||
int validateCalled = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
|
@ -185,7 +185,7 @@ void main() {
|
|||
child: CupertinoTextFormFieldRow(
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (String? value) {
|
||||
_validateCalled++;
|
||||
validateCalled++;
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
@ -193,14 +193,14 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
expect(_validateCalled, 1);
|
||||
expect(validateCalled, 1);
|
||||
await tester.enterText(find.byType(CupertinoTextField), 'a');
|
||||
await tester.pump();
|
||||
expect(_validateCalled, 2);
|
||||
expect(validateCalled, 2);
|
||||
});
|
||||
|
||||
testWidgets('validate is called if widget is enabled', (WidgetTester tester) async {
|
||||
int _validateCalled = 0;
|
||||
int validateCalled = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
|
@ -209,7 +209,7 @@ void main() {
|
|||
enabled: true,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (String? value) {
|
||||
_validateCalled += 1;
|
||||
validateCalled += 1;
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
@ -217,10 +217,10 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
expect(_validateCalled, 1);
|
||||
expect(validateCalled, 1);
|
||||
await tester.enterText(find.byType(CupertinoTextField), 'a');
|
||||
await tester.pump();
|
||||
expect(_validateCalled, 2);
|
||||
expect(validateCalled, 2);
|
||||
});
|
||||
|
||||
testWidgets('readonly text form field will hide cursor by default', (WidgetTester tester) async {
|
||||
|
@ -329,7 +329,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('onChanged callbacks value and FormFieldState.value are sync', (WidgetTester tester) async {
|
||||
bool _called = false;
|
||||
bool called = false;
|
||||
|
||||
late FormFieldState<String> state;
|
||||
|
||||
|
@ -338,7 +338,7 @@ void main() {
|
|||
home: Center(
|
||||
child: CupertinoTextFormFieldRow(
|
||||
onChanged: (String value) {
|
||||
_called = true;
|
||||
called = true;
|
||||
expect(value, state.value);
|
||||
},
|
||||
),
|
||||
|
@ -351,7 +351,7 @@ void main() {
|
|||
|
||||
await tester.enterText(find.byType(CupertinoTextField), 'Soup');
|
||||
|
||||
expect(_called, true);
|
||||
expect(called, true);
|
||||
});
|
||||
|
||||
testWidgets('autofillHints is passed to super', (WidgetTester tester) async {
|
||||
|
@ -371,7 +371,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async {
|
||||
int _validateCalled = 0;
|
||||
int validateCalled = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
|
@ -379,7 +379,7 @@ void main() {
|
|||
child: CupertinoTextFormFieldRow(
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
validator: (String? value) {
|
||||
_validateCalled++;
|
||||
validateCalled++;
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
@ -387,10 +387,10 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
expect(_validateCalled, 0);
|
||||
expect(validateCalled, 0);
|
||||
await tester.enterText(find.byType(CupertinoTextField), 'a');
|
||||
await tester.pump();
|
||||
expect(_validateCalled, 1);
|
||||
expect(validateCalled, 1);
|
||||
});
|
||||
|
||||
testWidgets('AutovalidateMode.always mode shows error from the start', (WidgetTester tester) async {
|
||||
|
|
|
@ -1519,7 +1519,7 @@ void main() {
|
|||
testWidgets('BottomNavigationBar change backgroundColor test', (WidgetTester tester) async {
|
||||
// Regression test for: https://github.com/flutter/flutter/issues/19653
|
||||
|
||||
Color _backgroundColor = Colors.red;
|
||||
Color backgroundColor = Colors.red;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
@ -1531,7 +1531,7 @@ void main() {
|
|||
child: const Text('green'),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_backgroundColor = Colors.green;
|
||||
backgroundColor = Colors.green;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
@ -1541,12 +1541,12 @@ void main() {
|
|||
items: <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
label: 'Page 1',
|
||||
backgroundColor: _backgroundColor,
|
||||
backgroundColor: backgroundColor,
|
||||
icon: const Icon(Icons.dashboard),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
label: 'Page 2',
|
||||
backgroundColor: _backgroundColor,
|
||||
backgroundColor: backgroundColor,
|
||||
icon: const Icon(Icons.menu),
|
||||
),
|
||||
],
|
||||
|
@ -1566,18 +1566,18 @@ void main() {
|
|||
}),
|
||||
);
|
||||
|
||||
expect(_backgroundColor, Colors.red);
|
||||
expect(backgroundColor, Colors.red);
|
||||
expect(tester.widget<Material>(backgroundMaterial).color, Colors.red);
|
||||
await tester.tap(find.text('green'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_backgroundColor, Colors.green);
|
||||
expect(backgroundColor, Colors.green);
|
||||
expect(tester.widget<Material>(backgroundMaterial).color, Colors.green);
|
||||
});
|
||||
|
||||
group('BottomNavigationBar shifting backgroundColor with transition', () {
|
||||
// Regression test for: https://github.com/flutter/flutter/issues/22226
|
||||
Widget runTest() {
|
||||
int _currentIndex = 0;
|
||||
int currentIndex = 0;
|
||||
return MaterialApp(
|
||||
home: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
|
@ -1585,10 +1585,10 @@ void main() {
|
|||
bottomNavigationBar: RepaintBoundary(
|
||||
child: BottomNavigationBar(
|
||||
type: BottomNavigationBarType.shifting,
|
||||
currentIndex: _currentIndex,
|
||||
currentIndex: currentIndex,
|
||||
onTap: (int index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
currentIndex = index;
|
||||
});
|
||||
},
|
||||
items: const <BottomNavigationBarItem>[
|
||||
|
|
|
@ -153,8 +153,8 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('CheckboxListTile tristate test', (WidgetTester tester) async {
|
||||
bool? _value = false;
|
||||
bool _tristate = false;
|
||||
bool? value = false;
|
||||
bool tristate = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
|
@ -163,11 +163,11 @@ void main() {
|
|||
return wrap(
|
||||
child: CheckboxListTile(
|
||||
title: const Text('Title'),
|
||||
tristate: _tristate,
|
||||
value: _value,
|
||||
onChanged: (bool? value) {
|
||||
tristate: tristate,
|
||||
value: value,
|
||||
onChanged: (bool? v) {
|
||||
setState(() {
|
||||
_value = value;
|
||||
value = v;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
@ -182,23 +182,23 @@ void main() {
|
|||
// Tap the checkbox when tristate is disabled.
|
||||
await tester.tap(find.byType(Checkbox));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_value, true);
|
||||
expect(value, true);
|
||||
|
||||
await tester.tap(find.byType(Checkbox));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_value, false);
|
||||
expect(value, false);
|
||||
|
||||
// Tap the listTile when tristate is disabled.
|
||||
await tester.tap(find.byType(ListTile));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_value, true);
|
||||
expect(value, true);
|
||||
|
||||
await tester.tap(find.byType(ListTile));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_value, false);
|
||||
expect(value, false);
|
||||
|
||||
// Enable tristate
|
||||
_tristate = true;
|
||||
tristate = true;
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(tester.widget<Checkbox>(find.byType(Checkbox)).value, false);
|
||||
|
@ -206,28 +206,28 @@ void main() {
|
|||
// Tap the checkbox when tristate is enabled.
|
||||
await tester.tap(find.byType(Checkbox));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_value, true);
|
||||
expect(value, true);
|
||||
|
||||
await tester.tap(find.byType(Checkbox));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_value, null);
|
||||
expect(value, null);
|
||||
|
||||
await tester.tap(find.byType(Checkbox));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_value, false);
|
||||
expect(value, false);
|
||||
|
||||
// Tap the listTile when tristate is enabled.
|
||||
await tester.tap(find.byType(ListTile));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_value, true);
|
||||
expect(value, true);
|
||||
|
||||
await tester.tap(find.byType(ListTile));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_value, null);
|
||||
expect(value, null);
|
||||
|
||||
await tester.tap(find.byType(ListTile));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_value, false);
|
||||
expect(value, false);
|
||||
});
|
||||
|
||||
testWidgets('CheckboxListTile respects shape', (WidgetTester tester) async {
|
||||
|
|
|
@ -1081,7 +1081,7 @@ void main() {
|
|||
}
|
||||
const double splashRadius = 24.0;
|
||||
TestGesture gesture;
|
||||
bool? _value = false;
|
||||
bool? value = false;
|
||||
|
||||
Widget buildTristateCheckbox() {
|
||||
return MaterialApp(
|
||||
|
@ -1089,11 +1089,11 @@ void main() {
|
|||
body: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return Checkbox(
|
||||
value: _value,
|
||||
value: value,
|
||||
tristate: true,
|
||||
onChanged: (bool? value) {
|
||||
onChanged: (bool? v) {
|
||||
setState(() {
|
||||
_value = value;
|
||||
value = v;
|
||||
});
|
||||
},
|
||||
overlayColor: MaterialStateProperty.resolveWith(getOverlayColor),
|
||||
|
@ -1110,7 +1110,7 @@ void main() {
|
|||
gesture = await tester.press(find.byType(Checkbox));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(_value, false);
|
||||
expect(value, false);
|
||||
expect(
|
||||
Material.of(tester.element(find.byType(Checkbox))),
|
||||
paints
|
||||
|
@ -1126,7 +1126,7 @@ void main() {
|
|||
gesture = await tester.press(find.byType(Checkbox));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(_value, true);
|
||||
expect(value, true);
|
||||
expect(
|
||||
Material.of(tester.element(find.byType(Checkbox))),
|
||||
paints
|
||||
|
@ -1142,7 +1142,7 @@ void main() {
|
|||
gesture = await tester.press(find.byType(Checkbox));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(_value, null);
|
||||
expect(value, null);
|
||||
expect(
|
||||
Material.of(tester.element(find.byType(Checkbox))),
|
||||
paints
|
||||
|
@ -1158,7 +1158,7 @@ void main() {
|
|||
gesture = await tester.press(find.byType(Checkbox));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(_value, false);
|
||||
expect(value, false);
|
||||
expect(
|
||||
Material.of(tester.element(find.byType(Checkbox))),
|
||||
paints
|
||||
|
|
|
@ -725,10 +725,10 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('DataTable custom horizontal padding - checkbox', (WidgetTester tester) async {
|
||||
const double _defaultHorizontalMargin = 24.0;
|
||||
const double _defaultColumnSpacing = 56.0;
|
||||
const double _customHorizontalMargin = 10.0;
|
||||
const double _customColumnSpacing = 15.0;
|
||||
const double defaultHorizontalMargin = 24.0;
|
||||
const double defaultColumnSpacing = 56.0;
|
||||
const double customHorizontalMargin = 10.0;
|
||||
const double customColumnSpacing = 15.0;
|
||||
Finder cellContent;
|
||||
Finder checkbox;
|
||||
Finder padding;
|
||||
|
@ -793,11 +793,11 @@ void main() {
|
|||
padding = find.ancestor(of: checkbox, matching: find.byType(Padding));
|
||||
expect(
|
||||
tester.getRect(checkbox).left - tester.getRect(padding).left,
|
||||
_defaultHorizontalMargin,
|
||||
defaultHorizontalMargin,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(checkbox).right,
|
||||
_defaultHorizontalMargin / 2,
|
||||
defaultHorizontalMargin / 2,
|
||||
);
|
||||
|
||||
// default first column padding
|
||||
|
@ -805,11 +805,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultHorizontalMargin / 2,
|
||||
defaultHorizontalMargin / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// default middle column padding
|
||||
|
@ -817,11 +817,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '159');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// default last column padding
|
||||
|
@ -829,11 +829,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '6.0');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultHorizontalMargin,
|
||||
defaultHorizontalMargin,
|
||||
);
|
||||
|
||||
Widget buildCustomTable({
|
||||
|
@ -893,8 +893,8 @@ void main() {
|
|||
// CUSTOM VALUES
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Material(child: buildCustomTable(
|
||||
horizontalMargin: _customHorizontalMargin,
|
||||
columnSpacing: _customColumnSpacing,
|
||||
horizontalMargin: customHorizontalMargin,
|
||||
columnSpacing: customColumnSpacing,
|
||||
)),
|
||||
));
|
||||
|
||||
|
@ -903,11 +903,11 @@ void main() {
|
|||
padding = find.ancestor(of: checkbox, matching: find.byType(Padding));
|
||||
expect(
|
||||
tester.getRect(checkbox).left - tester.getRect(padding).left,
|
||||
_customHorizontalMargin,
|
||||
customHorizontalMargin,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(checkbox).right,
|
||||
_customHorizontalMargin / 2,
|
||||
customHorizontalMargin / 2,
|
||||
);
|
||||
|
||||
// custom first column padding
|
||||
|
@ -915,11 +915,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customHorizontalMargin / 2,
|
||||
customHorizontalMargin / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// custom middle column padding
|
||||
|
@ -927,11 +927,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '159');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// custom last column padding
|
||||
|
@ -939,19 +939,19 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '6.0');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customHorizontalMargin,
|
||||
customHorizontalMargin,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('DataTable custom horizontal padding - no checkbox', (WidgetTester tester) async {
|
||||
const double _defaultHorizontalMargin = 24.0;
|
||||
const double _defaultColumnSpacing = 56.0;
|
||||
const double _customHorizontalMargin = 10.0;
|
||||
const double _customColumnSpacing = 15.0;
|
||||
const double defaultHorizontalMargin = 24.0;
|
||||
const double defaultColumnSpacing = 56.0;
|
||||
const double customHorizontalMargin = 10.0;
|
||||
const double customColumnSpacing = 15.0;
|
||||
Finder cellContent;
|
||||
Finder padding;
|
||||
|
||||
|
@ -1013,11 +1013,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultHorizontalMargin,
|
||||
defaultHorizontalMargin,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// default middle column padding
|
||||
|
@ -1025,11 +1025,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '159');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// default last column padding
|
||||
|
@ -1037,11 +1037,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '6.0');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultHorizontalMargin,
|
||||
defaultHorizontalMargin,
|
||||
);
|
||||
|
||||
Widget buildCustomTable({
|
||||
|
@ -1099,8 +1099,8 @@ void main() {
|
|||
// CUSTOM VALUES
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Material(child: buildCustomTable(
|
||||
horizontalMargin: _customHorizontalMargin,
|
||||
columnSpacing: _customColumnSpacing,
|
||||
horizontalMargin: customHorizontalMargin,
|
||||
columnSpacing: customColumnSpacing,
|
||||
)),
|
||||
));
|
||||
|
||||
|
@ -1109,11 +1109,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customHorizontalMargin,
|
||||
customHorizontalMargin,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// custom middle column padding
|
||||
|
@ -1121,11 +1121,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '159');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// custom last column padding
|
||||
|
@ -1133,11 +1133,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '6.0');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customHorizontalMargin,
|
||||
customHorizontalMargin,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -1356,10 +1356,10 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('DataRow renders default selected row colors', (WidgetTester tester) async {
|
||||
final ThemeData _themeData = ThemeData.light();
|
||||
final ThemeData themeData = ThemeData.light();
|
||||
Widget buildTable({bool selected = false}) {
|
||||
return MaterialApp(
|
||||
theme: _themeData,
|
||||
theme: themeData,
|
||||
home: Material(
|
||||
child: DataTable(
|
||||
columns: const <DataColumn>[
|
||||
|
@ -1393,7 +1393,7 @@ void main() {
|
|||
await tester.pumpWidget(buildTable(selected: true));
|
||||
expect(
|
||||
lastTableRowBoxDecoration().color,
|
||||
_themeData.colorScheme.primary.withOpacity(0.08),
|
||||
themeData.colorScheme.primary.withOpacity(0.08),
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -1401,7 +1401,7 @@ void main() {
|
|||
const Color fillColor = Color(0xFF00FF00);
|
||||
const Color checkColor = Color(0xFF0000FF);
|
||||
|
||||
final ThemeData _themeData = ThemeData(
|
||||
final ThemeData themeData = ThemeData(
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.all(fillColor),
|
||||
checkColor: MaterialStateProperty.all(checkColor),
|
||||
|
@ -1409,7 +1409,7 @@ void main() {
|
|||
);
|
||||
Widget buildTable() {
|
||||
return MaterialApp(
|
||||
theme: _themeData,
|
||||
theme: themeData,
|
||||
home: Material(
|
||||
child: DataTable(
|
||||
columns: const <DataColumn>[
|
||||
|
@ -1658,8 +1658,8 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('checkboxHorizontalMargin properly applied', (WidgetTester tester) async {
|
||||
const double _customCheckboxHorizontalMargin = 15.0;
|
||||
const double _customHorizontalMargin = 10.0;
|
||||
const double customCheckboxHorizontalMargin = 15.0;
|
||||
const double customHorizontalMargin = 10.0;
|
||||
Finder cellContent;
|
||||
Finder checkbox;
|
||||
Finder padding;
|
||||
|
@ -1720,8 +1720,8 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Material(child: buildCustomTable(
|
||||
checkboxHorizontalMargin: _customCheckboxHorizontalMargin,
|
||||
horizontalMargin: _customHorizontalMargin,
|
||||
checkboxHorizontalMargin: customCheckboxHorizontalMargin,
|
||||
horizontalMargin: customHorizontalMargin,
|
||||
)),
|
||||
));
|
||||
|
||||
|
@ -1730,11 +1730,11 @@ void main() {
|
|||
padding = find.ancestor(of: checkbox, matching: find.byType(Padding));
|
||||
expect(
|
||||
tester.getRect(checkbox).left - tester.getRect(padding).left,
|
||||
_customCheckboxHorizontalMargin,
|
||||
customCheckboxHorizontalMargin,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(checkbox).right,
|
||||
_customCheckboxHorizontalMargin,
|
||||
customCheckboxHorizontalMargin,
|
||||
);
|
||||
|
||||
// First column padding.
|
||||
|
@ -1742,7 +1742,7 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, 'Frozen yogurt'); // DataTable wraps its DataCells in an Align widget.
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customHorizontalMargin,
|
||||
customHorizontalMargin,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -220,8 +220,8 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('debugCheckHasScaffoldMessenger control test', (WidgetTester tester) async {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldMessengerState> _scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldMessengerState> scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
|
||||
final SnackBar snackBar = SnackBar(
|
||||
content: const Text('Snack'),
|
||||
action: SnackBarAction(label: 'Test', onPressed: () {}),
|
||||
|
@ -231,11 +231,11 @@ void main() {
|
|||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: ScaffoldMessenger(
|
||||
key: _scaffoldMessengerKey,
|
||||
key: scaffoldMessengerKey,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
key: scaffoldKey,
|
||||
body: Container(),
|
||||
);
|
||||
},
|
||||
|
@ -249,7 +249,7 @@ void main() {
|
|||
exceptions.add(details.exception);
|
||||
};
|
||||
// ScaffoldMessenger shows SnackBar.
|
||||
_scaffoldMessengerKey.currentState!.showSnackBar(snackBar);
|
||||
scaffoldMessengerKey.currentState!.showSnackBar(snackBar);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Pump widget to rebuild without ScaffoldMessenger
|
||||
|
@ -258,7 +258,7 @@ void main() {
|
|||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: Scaffold(
|
||||
key: _scaffoldKey,
|
||||
key: scaffoldKey,
|
||||
body: Container(),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1551,13 +1551,13 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('Dismissible.confirmDismiss defers to an AlertDialog', (WidgetTester tester) async {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final List<int> dismissedItems = <int>[];
|
||||
|
||||
// Dismiss is confirmed IFF confirmDismiss() returns true.
|
||||
Future<bool?> confirmDismiss (DismissDirection dismissDirection) async {
|
||||
return showDialog<bool>(
|
||||
context: _scaffoldKey.currentContext!,
|
||||
context: scaffoldKey.currentContext!,
|
||||
barrierDismissible: true, // showDialog() returns null if tapped outside the dialog
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
|
@ -1602,7 +1602,7 @@ void main() {
|
|||
home: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
key: scaffoldKey,
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: ListView(
|
||||
|
|
|
@ -446,7 +446,7 @@ void main() {
|
|||
|
||||
testWidgets('DropdownButtonFormField with autovalidation test', (WidgetTester tester) async {
|
||||
String? value = 'one';
|
||||
int _validateCalled = 0;
|
||||
int validateCalled = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
StatefulBuilder(
|
||||
|
@ -471,7 +471,7 @@ void main() {
|
|||
});
|
||||
},
|
||||
validator: (String? currentValue) {
|
||||
_validateCalled++;
|
||||
validateCalled++;
|
||||
return currentValue == null ? 'Must select value' : null;
|
||||
},
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
|
@ -482,13 +482,13 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
expect(_validateCalled, 1);
|
||||
expect(validateCalled, 1);
|
||||
expect(value, equals('one'));
|
||||
await tester.tap(find.text('one'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('three').last);
|
||||
await tester.pump();
|
||||
expect(_validateCalled, 2);
|
||||
expect(validateCalled, 2);
|
||||
await tester.pumpAndSettle();
|
||||
expect(value, equals('three'));
|
||||
});
|
||||
|
@ -1050,7 +1050,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async {
|
||||
int _validateCalled = 0;
|
||||
int validateCalled = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
@ -1066,7 +1066,7 @@ void main() {
|
|||
}).toList(),
|
||||
onChanged: onChanged,
|
||||
validator: (String? value) {
|
||||
_validateCalled++;
|
||||
validateCalled++;
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
@ -1075,7 +1075,7 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
expect(_validateCalled, 1);
|
||||
expect(validateCalled, 1);
|
||||
});
|
||||
|
||||
testWidgets('DropdownButtonFormField - Custom button alignment', (WidgetTester tester) async {
|
||||
|
|
|
@ -42,9 +42,9 @@ class _SimpleExpansionPanelListTestWidgetState extends State<SimpleExpansionPane
|
|||
Widget build(BuildContext context) {
|
||||
return ExpansionPanelList(
|
||||
expandedHeaderPadding: widget.expandedHeaderPadding ?? SimpleExpansionPanelListTestWidget.defaultExpandedHeaderPadding(),
|
||||
expansionCallback: (int _index, bool _isExpanded) {
|
||||
expansionCallback: (int index, bool isExpanded) {
|
||||
setState(() {
|
||||
extendedState[_index] = !extendedState[_index];
|
||||
extendedState[index] = !extendedState[index];
|
||||
});
|
||||
},
|
||||
dividerColor: widget.dividerColor,
|
||||
|
@ -113,16 +113,16 @@ class ExpansionPanelListSemanticsTestState extends State<ExpansionPanelListSeman
|
|||
|
||||
void main() {
|
||||
testWidgets('ExpansionPanelList test', (WidgetTester tester) async {
|
||||
late int index;
|
||||
late bool isExpanded;
|
||||
late int capturedIndex;
|
||||
late bool capturedIsExpanded;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: ExpansionPanelList(
|
||||
expansionCallback: (int _index, bool _isExpanded) {
|
||||
index = _index;
|
||||
isExpanded = _isExpanded;
|
||||
expansionCallback: (int index, bool isExpanded) {
|
||||
capturedIndex = index;
|
||||
capturedIsExpanded = isExpanded;
|
||||
},
|
||||
children: <ExpansionPanel>[
|
||||
ExpansionPanel(
|
||||
|
@ -143,8 +143,8 @@ void main() {
|
|||
final double oldHeight = box.size.height;
|
||||
expect(find.byType(ExpandIcon), findsOneWidget);
|
||||
await tester.tap(find.byType(ExpandIcon));
|
||||
expect(index, 0);
|
||||
expect(isExpanded, isFalse);
|
||||
expect(capturedIndex, 0);
|
||||
expect(capturedIsExpanded, isFalse);
|
||||
box = tester.renderObject(find.byType(ExpansionPanelList));
|
||||
expect(box.size.height, equals(oldHeight));
|
||||
|
||||
|
@ -153,9 +153,9 @@ void main() {
|
|||
MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: ExpansionPanelList(
|
||||
expansionCallback: (int _index, bool _isExpanded) {
|
||||
index = _index;
|
||||
isExpanded = _isExpanded;
|
||||
expansionCallback: (int index, bool isExpanded) {
|
||||
capturedIndex = index;
|
||||
capturedIsExpanded = isExpanded;
|
||||
},
|
||||
children: <ExpansionPanel>[
|
||||
ExpansionPanel(
|
||||
|
@ -359,7 +359,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('Radio mode has max of one panel open at a time', (WidgetTester tester) async {
|
||||
final List<ExpansionPanel> _demoItemsRadio = <ExpansionPanelRadio>[
|
||||
final List<ExpansionPanel> demoItemsRadio = <ExpansionPanelRadio>[
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'B' : 'A');
|
||||
|
@ -383,14 +383,14 @@ void main() {
|
|||
),
|
||||
];
|
||||
|
||||
final ExpansionPanelList _expansionListRadio = ExpansionPanelList.radio(
|
||||
children: _demoItemsRadio,
|
||||
final ExpansionPanelList expansionListRadio = ExpansionPanelList.radio(
|
||||
children: demoItemsRadio,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: _expansionListRadio,
|
||||
child: expansionListRadio,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -444,7 +444,7 @@ void main() {
|
|||
|
||||
expect(box.size.height, greaterThanOrEqualTo(oldHeight));
|
||||
|
||||
_demoItemsRadio.removeAt(0);
|
||||
demoItemsRadio.removeAt(0);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
|
@ -455,7 +455,7 @@ void main() {
|
|||
expect(find.text('F'), findsNothing);
|
||||
|
||||
|
||||
final List<ExpansionPanel> _demoItems = <ExpansionPanel>[
|
||||
final List<ExpansionPanel> demoItems = <ExpansionPanel>[
|
||||
ExpansionPanel(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'B' : 'A');
|
||||
|
@ -476,14 +476,14 @@ void main() {
|
|||
),
|
||||
];
|
||||
|
||||
final ExpansionPanelList _expansionList = ExpansionPanelList(
|
||||
children: _demoItems,
|
||||
final ExpansionPanelList expansionList = ExpansionPanelList(
|
||||
children: demoItems,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: _expansionList,
|
||||
child: expansionList,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -498,7 +498,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('Radio mode calls expansionCallback once if other panels closed', (WidgetTester tester) async {
|
||||
final List<ExpansionPanel> _demoItemsRadio = <ExpansionPanelRadio>[
|
||||
final List<ExpansionPanel> demoItemsRadio = <ExpansionPanelRadio>[
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'B' : 'A');
|
||||
|
@ -523,20 +523,20 @@ void main() {
|
|||
];
|
||||
|
||||
final List<Map<String, dynamic>> callbackHistory = <Map<String, dynamic>>[];
|
||||
final ExpansionPanelList _expansionListRadio = ExpansionPanelList.radio(
|
||||
expansionCallback: (int _index, bool _isExpanded) {
|
||||
final ExpansionPanelList expansionListRadio = ExpansionPanelList.radio(
|
||||
expansionCallback: (int index, bool isExpanded) {
|
||||
callbackHistory.add(<String, dynamic>{
|
||||
'index': _index,
|
||||
'isExpanded': _isExpanded,
|
||||
'index': index,
|
||||
'isExpanded': isExpanded,
|
||||
});
|
||||
},
|
||||
children: _demoItemsRadio,
|
||||
children: demoItemsRadio,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: _expansionListRadio,
|
||||
child: expansionListRadio,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -569,7 +569,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('Radio mode calls expansionCallback twice if other panel open prior', (WidgetTester tester) async {
|
||||
final List<ExpansionPanel> _demoItemsRadio = <ExpansionPanelRadio>[
|
||||
final List<ExpansionPanel> demoItemsRadio = <ExpansionPanelRadio>[
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'B' : 'A');
|
||||
|
@ -596,20 +596,20 @@ void main() {
|
|||
final List<Map<String, dynamic>> callbackHistory = <Map<String, dynamic>>[];
|
||||
Map<String, dynamic> callbackResults;
|
||||
|
||||
final ExpansionPanelList _expansionListRadio = ExpansionPanelList.radio(
|
||||
expansionCallback: (int _index, bool _isExpanded) {
|
||||
final ExpansionPanelList expansionListRadio = ExpansionPanelList.radio(
|
||||
expansionCallback: (int index, bool isExpanded) {
|
||||
callbackHistory.add(<String, dynamic>{
|
||||
'index': _index,
|
||||
'isExpanded': _isExpanded,
|
||||
'index': index,
|
||||
'isExpanded': isExpanded,
|
||||
});
|
||||
},
|
||||
children: _demoItemsRadio,
|
||||
children: demoItemsRadio,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: _expansionListRadio,
|
||||
child: expansionListRadio,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -653,7 +653,7 @@ void main() {
|
|||
'and ExpansionPaneList.radio',
|
||||
(WidgetTester tester) async {
|
||||
bool isRadioList = false;
|
||||
final List<bool> _panelExpansionState = <bool>[
|
||||
final List<bool> panelExpansionState = <bool>[
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
|
@ -690,24 +690,24 @@ void main() {
|
|||
|
||||
ExpansionPanelList buildExpansionPanelList(StateSetter setState) {
|
||||
return ExpansionPanelList(
|
||||
expansionCallback: (int index, _) => setState(() { _panelExpansionState[index] = !_panelExpansionState[index]; }),
|
||||
expansionCallback: (int index, _) => setState(() { panelExpansionState[index] = !panelExpansionState[index]; }),
|
||||
children: <ExpansionPanel>[
|
||||
ExpansionPanel(
|
||||
isExpanded: _panelExpansionState[0],
|
||||
isExpanded: panelExpansionState[0],
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'B' : 'A');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
),
|
||||
ExpansionPanel(
|
||||
isExpanded: _panelExpansionState[1],
|
||||
isExpanded: panelExpansionState[1],
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'D' : 'C');
|
||||
},
|
||||
body: const SizedBox(height: 100.0),
|
||||
),
|
||||
ExpansionPanel(
|
||||
isExpanded: _panelExpansionState[2],
|
||||
isExpanded: panelExpansionState[2],
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'F' : 'E');
|
||||
},
|
||||
|
@ -907,7 +907,7 @@ void main() {
|
|||
const Key collapsedKey = Key('collapsed');
|
||||
const DefaultMaterialLocalizations localizations = DefaultMaterialLocalizations();
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
final List<ExpansionPanel> _demoItems = <ExpansionPanel>[
|
||||
final List<ExpansionPanel> demoItems = <ExpansionPanel>[
|
||||
ExpansionPanel(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return const Text('Expanded', key: expandedKey);
|
||||
|
@ -923,14 +923,14 @@ void main() {
|
|||
),
|
||||
];
|
||||
|
||||
final ExpansionPanelList _expansionList = ExpansionPanelList(
|
||||
children: _demoItems,
|
||||
final ExpansionPanelList expansionList = ExpansionPanelList(
|
||||
children: demoItems,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: _expansionList,
|
||||
child: expansionList,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -990,7 +990,7 @@ void main() {
|
|||
const Key expandedKey = Key('expanded');
|
||||
const Key collapsedKey = Key('collapsed');
|
||||
final SemanticsHandle handle = tester.ensureSemantics();
|
||||
final List<ExpansionPanel> _demoItems = <ExpansionPanel>[
|
||||
final List<ExpansionPanel> demoItems = <ExpansionPanel>[
|
||||
ExpansionPanel(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return const Text('Expanded', key: expandedKey);
|
||||
|
@ -1008,14 +1008,14 @@ void main() {
|
|||
),
|
||||
];
|
||||
|
||||
final ExpansionPanelList _expansionList = ExpansionPanelList(
|
||||
children: _demoItems,
|
||||
final ExpansionPanelList expansionList = ExpansionPanelList(
|
||||
children: demoItems,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: _expansionList,
|
||||
child: expansionList,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -1040,19 +1040,19 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('Ensure canTapOnHeader is false by default', (WidgetTester tester) async {
|
||||
final ExpansionPanel _expansionPanel = ExpansionPanel(
|
||||
final ExpansionPanel expansionPanel = ExpansionPanel(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) => const Text('Demo'),
|
||||
body: const SizedBox(height: 100.0),
|
||||
);
|
||||
|
||||
expect(_expansionPanel.canTapOnHeader, isFalse);
|
||||
expect(expansionPanel.canTapOnHeader, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('Toggle ExpansionPanelRadio when tapping header and canTapOnHeader is true', (WidgetTester tester) async {
|
||||
const Key firstPanelKey = Key('firstPanelKey');
|
||||
const Key secondPanelKey = Key('secondPanelKey');
|
||||
|
||||
final List<ExpansionPanel> _demoItemsRadio = <ExpansionPanelRadio>[
|
||||
final List<ExpansionPanel> demoItemsRadio = <ExpansionPanelRadio>[
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'B' : 'A', key: firstPanelKey);
|
||||
|
@ -1071,14 +1071,14 @@ void main() {
|
|||
),
|
||||
];
|
||||
|
||||
final ExpansionPanelList _expansionListRadio = ExpansionPanelList.radio(
|
||||
children: _demoItemsRadio,
|
||||
final ExpansionPanelList expansionListRadio = ExpansionPanelList.radio(
|
||||
children: demoItemsRadio,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: _expansionListRadio,
|
||||
child: expansionListRadio,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -1211,7 +1211,7 @@ void main() {
|
|||
const Key firstPanelKey = Key('firstPanelKey');
|
||||
const Key secondPanelKey = Key('secondPanelKey');
|
||||
|
||||
final List<ExpansionPanel> _demoItemsRadio = <ExpansionPanelRadio>[
|
||||
final List<ExpansionPanel> demoItemsRadio = <ExpansionPanelRadio>[
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
return Text(isExpanded ? 'B' : 'A', key: firstPanelKey);
|
||||
|
@ -1228,14 +1228,14 @@ void main() {
|
|||
),
|
||||
];
|
||||
|
||||
final ExpansionPanelList _expansionListRadio = ExpansionPanelList.radio(
|
||||
children: _demoItemsRadio,
|
||||
final ExpansionPanelList expansionListRadio = ExpansionPanelList.radio(
|
||||
children: demoItemsRadio,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: _expansionListRadio,
|
||||
child: expansionListRadio,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -1391,24 +1391,24 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('elevation is propagated properly to MergeableMaterial', (WidgetTester tester) async {
|
||||
const double _elevation = 8;
|
||||
const double elevation = 8;
|
||||
|
||||
// Test for ExpansionPanelList.
|
||||
await tester.pumpWidget(const MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: SimpleExpansionPanelListTestWidget(
|
||||
elevation: _elevation,
|
||||
elevation: elevation,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
expect(tester.widget<MergeableMaterial>(find.byType(MergeableMaterial)).elevation, _elevation);
|
||||
expect(tester.widget<MergeableMaterial>(find.byType(MergeableMaterial)).elevation, elevation);
|
||||
|
||||
// Test for ExpansionPanelList.radio.
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: ExpansionPanelList.radio(
|
||||
elevation: _elevation,
|
||||
elevation: elevation,
|
||||
children: <ExpansionPanelRadio>[
|
||||
ExpansionPanelRadio(
|
||||
headerBuilder: (BuildContext context, bool isExpanded) {
|
||||
|
@ -1429,7 +1429,7 @@ void main() {
|
|||
),
|
||||
));
|
||||
|
||||
expect(tester.widget<MergeableMaterial>(find.byType(MergeableMaterial)).elevation, _elevation);
|
||||
expect(tester.widget<MergeableMaterial>(find.byType(MergeableMaterial)).elevation, elevation);
|
||||
});
|
||||
|
||||
testWidgets('Using a value non defined value throws assertion error', (WidgetTester tester) async {
|
||||
|
@ -1459,7 +1459,7 @@ void main() {
|
|||
MaterialApp(
|
||||
home: SingleChildScrollView(
|
||||
child: ExpansionPanelList(
|
||||
expansionCallback: (int _index, bool _isExpanded) {},
|
||||
expansionCallback: (int index, bool isExpanded) {},
|
||||
children: <ExpansionPanel>[
|
||||
ExpansionPanel(
|
||||
backgroundColor: firstPanelColor,
|
||||
|
|
|
@ -42,10 +42,10 @@ class TestTextState extends State<TestText> {
|
|||
}
|
||||
|
||||
void main() {
|
||||
const Color _dividerColor = Color(0x1f333333);
|
||||
const Color _foregroundColor = Colors.blueAccent;
|
||||
const Color _unselectedWidgetColor = Colors.black54;
|
||||
const Color _headerColor = Colors.black45;
|
||||
const Color dividerColor = Color(0x1f333333);
|
||||
const Color foregroundColor = Colors.blueAccent;
|
||||
const Color unselectedWidgetColor = Colors.black54;
|
||||
const Color headerColor = Colors.black45;
|
||||
|
||||
testWidgets('ExpansionTile initial state', (WidgetTester tester) async {
|
||||
final Key topKey = UniqueKey();
|
||||
|
@ -57,7 +57,7 @@ void main() {
|
|||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
theme: ThemeData(
|
||||
dividerColor: _dividerColor,
|
||||
dividerColor: dividerColor,
|
||||
),
|
||||
home: Material(
|
||||
child: SingleChildScrollView(
|
||||
|
@ -111,8 +111,8 @@ void main() {
|
|||
|
||||
BoxDecoration expandedContainerDecoration = getContainer(expandedKey).decoration! as BoxDecoration;
|
||||
expect(expandedContainerDecoration.color, Colors.red);
|
||||
expect(expandedContainerDecoration.border!.top.color, _dividerColor);
|
||||
expect(expandedContainerDecoration.border!.bottom.color, _dividerColor);
|
||||
expect(expandedContainerDecoration.border!.top.color, dividerColor);
|
||||
expect(expandedContainerDecoration.border!.bottom.color, dividerColor);
|
||||
|
||||
BoxDecoration collapsedContainerDecoration = getContainer(collapsedKey).decoration! as BoxDecoration;
|
||||
expect(collapsedContainerDecoration.color, Colors.transparent);
|
||||
|
@ -149,8 +149,8 @@ void main() {
|
|||
// Collapsed should be expanded now.
|
||||
collapsedContainerDecoration = getContainer(collapsedKey).decoration! as BoxDecoration;
|
||||
expect(collapsedContainerDecoration.color, Colors.transparent);
|
||||
expect(collapsedContainerDecoration.border!.top.color, _dividerColor);
|
||||
expect(collapsedContainerDecoration.border!.bottom.color, _dividerColor);
|
||||
expect(collapsedContainerDecoration.border!.top.color, dividerColor);
|
||||
expect(collapsedContainerDecoration.border!.bottom.color, dividerColor);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets('ExpansionTile Theme dependencies', (WidgetTester tester) async {
|
||||
|
@ -162,9 +162,9 @@ void main() {
|
|||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSwatch().copyWith(primary: _foregroundColor),
|
||||
unselectedWidgetColor: _unselectedWidgetColor,
|
||||
textTheme: const TextTheme(subtitle1: TextStyle(color: _headerColor)),
|
||||
colorScheme: ColorScheme.fromSwatch().copyWith(primary: foregroundColor),
|
||||
unselectedWidgetColor: unselectedWidgetColor,
|
||||
textTheme: const TextTheme(subtitle1: TextStyle(color: headerColor)),
|
||||
),
|
||||
home: Material(
|
||||
child: SingleChildScrollView(
|
||||
|
@ -193,10 +193,10 @@ void main() {
|
|||
Color iconColor(Key key) => tester.state<TestIconState>(find.byKey(key)).iconTheme.color!;
|
||||
Color textColor(Key key) => tester.state<TestTextState>(find.byKey(key)).textStyle.color!;
|
||||
|
||||
expect(textColor(expandedTitleKey), _foregroundColor);
|
||||
expect(textColor(collapsedTitleKey), _headerColor);
|
||||
expect(iconColor(expandedIconKey), _foregroundColor);
|
||||
expect(iconColor(collapsedIconKey), _unselectedWidgetColor);
|
||||
expect(textColor(expandedTitleKey), foregroundColor);
|
||||
expect(textColor(collapsedTitleKey), headerColor);
|
||||
expect(iconColor(expandedIconKey), foregroundColor);
|
||||
expect(iconColor(collapsedIconKey), unselectedWidgetColor);
|
||||
|
||||
// Tap both tiles to change their state: collapse and extend respectively
|
||||
await tester.tap(find.text('Expanded'));
|
||||
|
@ -205,10 +205,10 @@ void main() {
|
|||
await tester.pump(const Duration(seconds: 1));
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
expect(textColor(expandedTitleKey), _headerColor);
|
||||
expect(textColor(collapsedTitleKey), _foregroundColor);
|
||||
expect(iconColor(expandedIconKey), _unselectedWidgetColor);
|
||||
expect(iconColor(collapsedIconKey), _foregroundColor);
|
||||
expect(textColor(expandedTitleKey), headerColor);
|
||||
expect(textColor(collapsedTitleKey), foregroundColor);
|
||||
expect(iconColor(expandedIconKey), unselectedWidgetColor);
|
||||
expect(iconColor(collapsedIconKey), foregroundColor);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets('ExpansionTile subtitle', (WidgetTester tester) async {
|
||||
|
@ -232,7 +232,7 @@ void main() {
|
|||
MaterialApp(
|
||||
theme: ThemeData(
|
||||
platform: TargetPlatform.iOS,
|
||||
dividerColor: _dividerColor,
|
||||
dividerColor: dividerColor,
|
||||
),
|
||||
home: Material(
|
||||
child: SingleChildScrollView(
|
||||
|
|
|
@ -341,14 +341,14 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('Navigation bar does not grow with text scale factor', (WidgetTester tester) async {
|
||||
const int _animationMilliseconds = 800;
|
||||
const int animationMilliseconds = 800;
|
||||
|
||||
Widget _widget({double textScaleFactor = 1}) {
|
||||
return _buildWidget(
|
||||
MediaQuery(
|
||||
data: MediaQueryData(textScaleFactor: textScaleFactor),
|
||||
child: NavigationBar(
|
||||
animationDuration: const Duration(milliseconds: _animationMilliseconds),
|
||||
animationDuration: const Duration(milliseconds: animationMilliseconds),
|
||||
destinations: const <NavigationDestination>[
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.ac_unit),
|
||||
|
|
|
@ -481,19 +481,19 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('PaginatedDataTable custom horizontal padding - checkbox', (WidgetTester tester) async {
|
||||
const double _defaultHorizontalMargin = 24.0;
|
||||
const double _defaultColumnSpacing = 56.0;
|
||||
const double _customHorizontalMargin = 10.0;
|
||||
const double _customColumnSpacing = 15.0;
|
||||
const double defaultHorizontalMargin = 24.0;
|
||||
const double defaultColumnSpacing = 56.0;
|
||||
const double customHorizontalMargin = 10.0;
|
||||
const double customColumnSpacing = 15.0;
|
||||
|
||||
const double _width = 400;
|
||||
const double _height = 400;
|
||||
const double width = 400;
|
||||
const double height = 400;
|
||||
|
||||
final Size originalSize = binding.renderView.size;
|
||||
|
||||
// Ensure the containing Card is small enough that we don't expand too
|
||||
// much, resulting in our custom margin being ignored.
|
||||
await binding.setSurfaceSize(const Size(_width, _height));
|
||||
await binding.setSurfaceSize(const Size(width, height));
|
||||
|
||||
final TestDataSource source = TestDataSource(allowSelection: true);
|
||||
Finder cellContent;
|
||||
|
@ -524,11 +524,11 @@ void main() {
|
|||
padding = find.ancestor(of: checkbox, matching: find.byType(Padding)).first;
|
||||
expect(
|
||||
tester.getRect(checkbox).left - tester.getRect(padding).left,
|
||||
_defaultHorizontalMargin,
|
||||
defaultHorizontalMargin,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(checkbox).right,
|
||||
_defaultHorizontalMargin / 2,
|
||||
defaultHorizontalMargin / 2,
|
||||
);
|
||||
|
||||
// default first column padding
|
||||
|
@ -536,11 +536,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, 'Frozen yogurt (0)'); // DataTable wraps its DataCells in an Align widget
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultHorizontalMargin / 2,
|
||||
defaultHorizontalMargin / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// default middle column padding
|
||||
|
@ -548,11 +548,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '159');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// default last column padding
|
||||
|
@ -560,11 +560,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '0').first;
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultHorizontalMargin,
|
||||
defaultHorizontalMargin,
|
||||
);
|
||||
|
||||
// CUSTOM VALUES
|
||||
|
@ -585,8 +585,8 @@ void main() {
|
|||
DataColumn(label: Text('Calories'), numeric: true),
|
||||
DataColumn(label: Text('Generation')),
|
||||
],
|
||||
horizontalMargin: _customHorizontalMargin,
|
||||
columnSpacing: _customColumnSpacing,
|
||||
horizontalMargin: customHorizontalMargin,
|
||||
columnSpacing: customColumnSpacing,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
@ -596,11 +596,11 @@ void main() {
|
|||
padding = find.ancestor(of: checkbox, matching: find.byType(Padding)).first;
|
||||
expect(
|
||||
tester.getRect(checkbox).left - tester.getRect(padding).left,
|
||||
_customHorizontalMargin,
|
||||
customHorizontalMargin,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(checkbox).right,
|
||||
_customHorizontalMargin / 2,
|
||||
customHorizontalMargin / 2,
|
||||
);
|
||||
|
||||
// custom first column padding
|
||||
|
@ -608,11 +608,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, 'Frozen yogurt (0)'); // DataTable wraps its DataCells in an Align widget
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customHorizontalMargin / 2,
|
||||
customHorizontalMargin / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// custom middle column padding
|
||||
|
@ -620,11 +620,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '159');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// custom last column padding
|
||||
|
@ -632,11 +632,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '0').first;
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customHorizontalMargin,
|
||||
customHorizontalMargin,
|
||||
);
|
||||
|
||||
// Reset the surface size.
|
||||
|
@ -644,10 +644,10 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('PaginatedDataTable custom horizontal padding - no checkbox', (WidgetTester tester) async {
|
||||
const double _defaultHorizontalMargin = 24.0;
|
||||
const double _defaultColumnSpacing = 56.0;
|
||||
const double _customHorizontalMargin = 10.0;
|
||||
const double _customColumnSpacing = 15.0;
|
||||
const double defaultHorizontalMargin = 24.0;
|
||||
const double defaultColumnSpacing = 56.0;
|
||||
const double customHorizontalMargin = 10.0;
|
||||
const double customColumnSpacing = 15.0;
|
||||
final TestDataSource source = TestDataSource();
|
||||
Finder cellContent;
|
||||
Finder padding;
|
||||
|
@ -675,11 +675,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, 'Frozen yogurt (0)'); // DataTable wraps its DataCells in an Align widget
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultHorizontalMargin,
|
||||
defaultHorizontalMargin,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// default middle column padding
|
||||
|
@ -687,11 +687,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '159');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// default last column padding
|
||||
|
@ -699,11 +699,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '0').first;
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_defaultColumnSpacing / 2,
|
||||
defaultColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_defaultHorizontalMargin,
|
||||
defaultHorizontalMargin,
|
||||
);
|
||||
|
||||
// CUSTOM VALUES
|
||||
|
@ -723,8 +723,8 @@ void main() {
|
|||
DataColumn(label: Text('Calories'), numeric: true),
|
||||
DataColumn(label: Text('Generation')),
|
||||
],
|
||||
horizontalMargin: _customHorizontalMargin,
|
||||
columnSpacing: _customColumnSpacing,
|
||||
horizontalMargin: customHorizontalMargin,
|
||||
columnSpacing: customColumnSpacing,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
@ -734,11 +734,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, 'Frozen yogurt (0)');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customHorizontalMargin,
|
||||
customHorizontalMargin,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// custom middle column padding
|
||||
|
@ -746,11 +746,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '159');
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
|
||||
// custom last column padding
|
||||
|
@ -758,11 +758,11 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, '0').first;
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customColumnSpacing / 2,
|
||||
customColumnSpacing / 2,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(cellContent).right,
|
||||
_customHorizontalMargin,
|
||||
customHorizontalMargin,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -772,14 +772,14 @@ void main() {
|
|||
// Note: 800 is wide enough to ensure that all of the columns fit in the
|
||||
// Card. The test makes sure that the DataTable is exactly as wide
|
||||
// as the Card, minus the Card's margin.
|
||||
const double _originalWidth = 800;
|
||||
const double _expandedWidth = 1600;
|
||||
const double _height = 400;
|
||||
const double originalWidth = 800;
|
||||
const double expandedWidth = 1600;
|
||||
const double height = 400;
|
||||
|
||||
// By default, the margin of a Card is 4 in all directions, so
|
||||
// the size of the DataTable (inside the Card) is horizontically
|
||||
// reduced by 4 * 2; the left and right margins.
|
||||
const double _cardMargin = 8;
|
||||
const double cardMargin = 8;
|
||||
|
||||
final Size originalSize = binding.renderView.size;
|
||||
|
||||
|
@ -801,7 +801,7 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
await binding.setSurfaceSize(const Size(_originalWidth, _height));
|
||||
await binding.setSurfaceSize(const Size(originalWidth, height));
|
||||
await tester.pumpWidget(buildWidget());
|
||||
|
||||
double cardWidth = tester.renderObject<RenderBox>(find.byType(Card).first).size.width;
|
||||
|
@ -809,10 +809,10 @@ void main() {
|
|||
// Widths should be equal before we resize...
|
||||
expect(
|
||||
tester.renderObject<RenderBox>(find.byType(DataTable).first).size.width,
|
||||
moreOrLessEquals(cardWidth - _cardMargin),
|
||||
moreOrLessEquals(cardWidth - cardMargin),
|
||||
);
|
||||
|
||||
await binding.setSurfaceSize(const Size(_expandedWidth, _height));
|
||||
await binding.setSurfaceSize(const Size(expandedWidth, height));
|
||||
await tester.pumpWidget(buildWidget());
|
||||
|
||||
cardWidth = tester.renderObject<RenderBox>(find.byType(Card).first).size.width;
|
||||
|
@ -820,11 +820,11 @@ void main() {
|
|||
// ... and should still be equal after the resize.
|
||||
expect(
|
||||
tester.renderObject<RenderBox>(find.byType(DataTable).first).size.width,
|
||||
moreOrLessEquals(cardWidth - _cardMargin),
|
||||
moreOrLessEquals(cardWidth - cardMargin),
|
||||
);
|
||||
|
||||
// Double check to ensure we actually resized the surface properly.
|
||||
expect(cardWidth, moreOrLessEquals(_expandedWidth));
|
||||
expect(cardWidth, moreOrLessEquals(expandedWidth));
|
||||
|
||||
// Reset the surface size.
|
||||
await binding.setSurfaceSize(originalSize);
|
||||
|
@ -885,17 +885,17 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('PaginatedDataTable custom checkboxHorizontalMargin properly applied', (WidgetTester tester) async {
|
||||
const double _customCheckboxHorizontalMargin = 15.0;
|
||||
const double _customHorizontalMargin = 10.0;
|
||||
const double customCheckboxHorizontalMargin = 15.0;
|
||||
const double customHorizontalMargin = 10.0;
|
||||
|
||||
const double _width = 400;
|
||||
const double _height = 400;
|
||||
const double width = 400;
|
||||
const double height = 400;
|
||||
|
||||
final Size originalSize = binding.renderView.size;
|
||||
|
||||
// Ensure the containing Card is small enough that we don't expand too
|
||||
// much, resulting in our custom margin being ignored.
|
||||
await binding.setSurfaceSize(const Size(_width, _height));
|
||||
await binding.setSurfaceSize(const Size(width, height));
|
||||
|
||||
final TestDataSource source = TestDataSource(allowSelection: true);
|
||||
Finder cellContent;
|
||||
|
@ -920,8 +920,8 @@ void main() {
|
|||
DataColumn(label: Text('Calories'), numeric: true),
|
||||
DataColumn(label: Text('Generation')),
|
||||
],
|
||||
horizontalMargin: _customHorizontalMargin,
|
||||
checkboxHorizontalMargin: _customCheckboxHorizontalMargin,
|
||||
horizontalMargin: customHorizontalMargin,
|
||||
checkboxHorizontalMargin: customCheckboxHorizontalMargin,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
@ -931,11 +931,11 @@ void main() {
|
|||
padding = find.ancestor(of: checkbox, matching: find.byType(Padding)).first;
|
||||
expect(
|
||||
tester.getRect(checkbox).left - tester.getRect(padding).left,
|
||||
_customCheckboxHorizontalMargin,
|
||||
customCheckboxHorizontalMargin,
|
||||
);
|
||||
expect(
|
||||
tester.getRect(padding).right - tester.getRect(checkbox).right,
|
||||
_customCheckboxHorizontalMargin,
|
||||
customCheckboxHorizontalMargin,
|
||||
);
|
||||
|
||||
// Custom first column padding.
|
||||
|
@ -943,7 +943,7 @@ void main() {
|
|||
cellContent = find.widgetWithText(Align, 'Frozen yogurt (0)'); // DataTable wraps its DataCells in an Align widget.
|
||||
expect(
|
||||
tester.getRect(cellContent).left - tester.getRect(padding).left,
|
||||
_customHorizontalMargin,
|
||||
customHorizontalMargin,
|
||||
);
|
||||
|
||||
// Reset the surface size.
|
||||
|
|
|
@ -2042,7 +2042,7 @@ void main() {
|
|||
|
||||
const double statusBarHeight = 24.0;
|
||||
final PopupMenuItem<int> firstItem = choices[0];
|
||||
int _selectedValue = choices[0].value!;
|
||||
int selectedValue = choices[0].value!;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
@ -2061,10 +2061,10 @@ void main() {
|
|||
PopupMenuButton<int>(
|
||||
onSelected: (int result) {
|
||||
setState(() {
|
||||
_selectedValue = result;
|
||||
selectedValue = result;
|
||||
});
|
||||
},
|
||||
initialValue: _selectedValue,
|
||||
initialValue: selectedValue,
|
||||
itemBuilder: (BuildContext context) {
|
||||
return choices;
|
||||
},
|
||||
|
|
|
@ -1318,8 +1318,8 @@ void main() {
|
|||
|
||||
testWidgets('Can switch to non-neighboring tab in nested TabBarView without crashing', (WidgetTester tester) async {
|
||||
// This is a regression test for https://github.com/flutter/flutter/issues/18756
|
||||
final TabController _mainTabController = TabController(length: 4, vsync: const TestVSync());
|
||||
final TabController _nestedTabController = TabController(length: 2, vsync: const TestVSync());
|
||||
final TabController mainTabController = TabController(length: 4, vsync: const TestVSync());
|
||||
final TabController nestedTabController = TabController(length: 2, vsync: const TestVSync());
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
@ -1327,7 +1327,7 @@ void main() {
|
|||
appBar: AppBar(
|
||||
title: const Text('Exception for Nested Tabs'),
|
||||
bottom: TabBar(
|
||||
controller: _mainTabController,
|
||||
controller: mainTabController,
|
||||
tabs: const <Widget>[
|
||||
Tab(icon: Icon(Icons.add), text: 'A'),
|
||||
Tab(icon: Icon(Icons.add), text: 'B'),
|
||||
|
@ -1337,10 +1337,10 @@ void main() {
|
|||
),
|
||||
),
|
||||
body: TabBarView(
|
||||
controller: _mainTabController,
|
||||
controller: mainTabController,
|
||||
children: <Widget>[
|
||||
Container(color: Colors.red),
|
||||
_NestedTabBarContainer(tabController: _nestedTabController),
|
||||
_NestedTabBarContainer(tabController: nestedTabController),
|
||||
Container(color: Colors.green),
|
||||
Container(color: Colors.indigo),
|
||||
],
|
||||
|
@ -1350,14 +1350,14 @@ void main() {
|
|||
);
|
||||
|
||||
// expect first tab to be selected
|
||||
expect(_mainTabController.index, 0);
|
||||
expect(mainTabController.index, 0);
|
||||
|
||||
// tap on third tab
|
||||
await tester.tap(find.text('C'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// expect third tab to be selected without exceptions
|
||||
expect(_mainTabController.index, 2);
|
||||
expect(mainTabController.index, 2);
|
||||
});
|
||||
|
||||
testWidgets('TabBarView can warp when child is kept alive and contains ink', (WidgetTester tester) async {
|
||||
|
@ -3568,19 +3568,19 @@ void main() {
|
|||
testWidgets('TabBar - updating to and from zero tabs', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/68962.
|
||||
final List<String> tabTitles = <String>[];
|
||||
TabController _tabController = TabController(length: tabTitles.length, vsync: const TestVSync());
|
||||
TabController tabController = TabController(length: tabTitles.length, vsync: const TestVSync());
|
||||
|
||||
void _onTabAdd(StateSetter setState) {
|
||||
setState(() {
|
||||
tabTitles.add('Tab ${tabTitles.length + 1}');
|
||||
_tabController = TabController(length: tabTitles.length, vsync: const TestVSync());
|
||||
tabController = TabController(length: tabTitles.length, vsync: const TestVSync());
|
||||
});
|
||||
}
|
||||
|
||||
void _onTabRemove(StateSetter setState) {
|
||||
setState(() {
|
||||
tabTitles.removeLast();
|
||||
_tabController = TabController(length: tabTitles.length, vsync: const TestVSync());
|
||||
tabController = TabController(length: tabTitles.length, vsync: const TestVSync());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3606,7 +3606,7 @@ void main() {
|
|||
preferredSize: const Size.fromHeight(40.0),
|
||||
child: Expanded(
|
||||
child: TabBar(
|
||||
controller: _tabController,
|
||||
controller: tabController,
|
||||
tabs: tabTitles
|
||||
.map((String title) => Tab(text: title))
|
||||
.toList(),
|
||||
|
|
|
@ -343,14 +343,14 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('onFieldSubmit callbacks are called', (WidgetTester tester) async {
|
||||
bool _called = false;
|
||||
bool called = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Material(
|
||||
child: Center(
|
||||
child: TextFormField(
|
||||
onFieldSubmitted: (String value) { _called = true; },
|
||||
onFieldSubmitted: (String value) { called = true; },
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -360,19 +360,19 @@ void main() {
|
|||
await tester.showKeyboard(find.byType(TextField));
|
||||
await tester.testTextInput.receiveAction(TextInputAction.done);
|
||||
await tester.pump();
|
||||
expect(_called, true);
|
||||
expect(called, true);
|
||||
});
|
||||
|
||||
testWidgets('onChanged callbacks are called', (WidgetTester tester) async {
|
||||
late String _value;
|
||||
late String value;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Material(
|
||||
child: Center(
|
||||
child: TextFormField(
|
||||
onChanged: (String value) {
|
||||
_value = value;
|
||||
onChanged: (String v) {
|
||||
value = v;
|
||||
},
|
||||
),
|
||||
),
|
||||
|
@ -382,11 +382,11 @@ void main() {
|
|||
|
||||
await tester.enterText(find.byType(TextField), 'Soup');
|
||||
await tester.pump();
|
||||
expect(_value, 'Soup');
|
||||
expect(value, 'Soup');
|
||||
});
|
||||
|
||||
testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async {
|
||||
int _validateCalled = 0;
|
||||
int validateCalled = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
@ -395,7 +395,7 @@ void main() {
|
|||
child: TextFormField(
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (String? value) {
|
||||
_validateCalled++;
|
||||
validateCalled++;
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
@ -404,14 +404,14 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
expect(_validateCalled, 1);
|
||||
expect(validateCalled, 1);
|
||||
await tester.enterText(find.byType(TextField), 'a');
|
||||
await tester.pump();
|
||||
expect(_validateCalled, 2);
|
||||
expect(validateCalled, 2);
|
||||
});
|
||||
|
||||
testWidgets('validate is called if widget is enabled', (WidgetTester tester) async {
|
||||
int _validateCalled = 0;
|
||||
int validateCalled = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
@ -421,7 +421,7 @@ void main() {
|
|||
enabled: true,
|
||||
autovalidateMode: AutovalidateMode.always,
|
||||
validator: (String? value) {
|
||||
_validateCalled += 1;
|
||||
validateCalled += 1;
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
@ -430,10 +430,10 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
expect(_validateCalled, 1);
|
||||
expect(validateCalled, 1);
|
||||
await tester.enterText(find.byType(TextField), 'a');
|
||||
await tester.pump();
|
||||
expect(_validateCalled, 2);
|
||||
expect(validateCalled, 2);
|
||||
});
|
||||
|
||||
|
||||
|
@ -669,7 +669,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('onChanged callbacks value and FormFieldState.value are sync', (WidgetTester tester) async {
|
||||
bool _called = false;
|
||||
bool called = false;
|
||||
|
||||
late FormFieldState<String> state;
|
||||
|
||||
|
@ -679,7 +679,7 @@ void main() {
|
|||
child: Center(
|
||||
child: TextFormField(
|
||||
onChanged: (String value) {
|
||||
_called = true;
|
||||
called = true;
|
||||
expect(value, state.value);
|
||||
},
|
||||
),
|
||||
|
@ -692,7 +692,7 @@ void main() {
|
|||
|
||||
await tester.enterText(find.byType(TextField), 'Soup');
|
||||
|
||||
expect(_called, true);
|
||||
expect(called, true);
|
||||
});
|
||||
|
||||
testWidgets('autofillHints is passed to super', (WidgetTester tester) async {
|
||||
|
@ -713,7 +713,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async {
|
||||
int _validateCalled = 0;
|
||||
int validateCalled = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
@ -722,7 +722,7 @@ void main() {
|
|||
body: TextFormField(
|
||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||
validator: (String? value) {
|
||||
_validateCalled++;
|
||||
validateCalled++;
|
||||
return null;
|
||||
},
|
||||
),
|
||||
|
@ -731,10 +731,10 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
expect(_validateCalled, 0);
|
||||
expect(validateCalled, 0);
|
||||
await tester.enterText(find.byType(TextField), 'a');
|
||||
await tester.pump();
|
||||
expect(_validateCalled, 1);
|
||||
expect(validateCalled, 1);
|
||||
});
|
||||
|
||||
testWidgets('textSelectionControls is passed to super', (WidgetTester tester) async {
|
||||
|
|
|
@ -329,16 +329,16 @@ void main() {
|
|||
);
|
||||
|
||||
testWidgets('Text geometry set in Theme has higher precedence than that of Localizations', (WidgetTester tester) async {
|
||||
const double _kMagicFontSize = 4321.0;
|
||||
const double kMagicFontSize = 4321.0;
|
||||
final ThemeData fallback = ThemeData.fallback();
|
||||
final ThemeData customTheme = fallback.copyWith(
|
||||
primaryTextTheme: fallback.primaryTextTheme.copyWith(
|
||||
bodyText2: fallback.primaryTextTheme.bodyText2!.copyWith(
|
||||
fontSize: _kMagicFontSize,
|
||||
fontSize: kMagicFontSize,
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(customTheme.primaryTextTheme.bodyText2!.fontSize, _kMagicFontSize);
|
||||
expect(customTheme.primaryTextTheme.bodyText2!.fontSize, kMagicFontSize);
|
||||
|
||||
late double actualFontSize;
|
||||
await tester.pumpWidget(Directionality(
|
||||
|
@ -356,7 +356,7 @@ void main() {
|
|||
),
|
||||
));
|
||||
|
||||
expect(actualFontSize, _kMagicFontSize);
|
||||
expect(actualFontSize, kMagicFontSize);
|
||||
});
|
||||
|
||||
testWidgets('Default Theme provides all basic TextStyle properties', (WidgetTester tester) async {
|
||||
|
|
|
@ -66,7 +66,7 @@ void main() {
|
|||
)).style;
|
||||
}
|
||||
|
||||
final List<bool> _isSelected = <bool>[false, true];
|
||||
final List<bool> isSelected = <bool>[false, true];
|
||||
final ThemeData theme = ThemeData();
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
|
@ -76,10 +76,10 @@ void main() {
|
|||
child: ToggleButtons(
|
||||
onPressed: (int index) {
|
||||
setState(() {
|
||||
_isSelected[index] = !_isSelected[index];
|
||||
isSelected[index] = !isSelected[index];
|
||||
});
|
||||
},
|
||||
isSelected: _isSelected,
|
||||
isSelected: isSelected,
|
||||
children: const <Widget>[
|
||||
Text('First child'),
|
||||
Text('Second child'),
|
||||
|
@ -91,8 +91,8 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
expect(_isSelected[0], isFalse);
|
||||
expect(_isSelected[1], isTrue);
|
||||
expect(isSelected[0], isFalse);
|
||||
expect(isSelected[1], isTrue);
|
||||
expect(
|
||||
buttonTextStyle('First child').color,
|
||||
theme.colorScheme.onSurface.withOpacity(0.87),
|
||||
|
@ -105,8 +105,8 @@ void main() {
|
|||
await tester.tap(find.text('Second child'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(_isSelected[0], isFalse);
|
||||
expect(_isSelected[1], isFalse);
|
||||
expect(isSelected[0], isFalse);
|
||||
expect(isSelected[1], isFalse);
|
||||
expect(
|
||||
buttonTextStyle('First child').color,
|
||||
theme.colorScheme.onSurface.withOpacity(0.87),
|
||||
|
@ -127,14 +127,14 @@ void main() {
|
|||
matching: find.byType(DefaultTextStyle),
|
||||
)).style;
|
||||
}
|
||||
final List<bool> _isSelected = <bool>[false, true];
|
||||
final List<bool> isSelected = <bool>[false, true];
|
||||
final ThemeData theme = ThemeData();
|
||||
|
||||
await tester.pumpWidget(
|
||||
Material(
|
||||
child: boilerplate(
|
||||
child: ToggleButtons(
|
||||
isSelected: _isSelected,
|
||||
isSelected: isSelected,
|
||||
children: const <Widget>[
|
||||
Text('First child'),
|
||||
Text('Second child'),
|
||||
|
@ -144,8 +144,8 @@ void main() {
|
|||
),
|
||||
);
|
||||
|
||||
expect(_isSelected[0], isFalse);
|
||||
expect(_isSelected[1], isTrue);
|
||||
expect(isSelected[0], isFalse);
|
||||
expect(isSelected[1], isTrue);
|
||||
expect(
|
||||
buttonTextStyle('First child').color,
|
||||
theme.colorScheme.onSurface.withOpacity(0.38),
|
||||
|
@ -159,8 +159,8 @@ void main() {
|
|||
await tester.pumpAndSettle();
|
||||
|
||||
// Nothing should change
|
||||
expect(_isSelected[0], isFalse);
|
||||
expect(_isSelected[1], isTrue);
|
||||
expect(isSelected[0], isFalse);
|
||||
expect(isSelected[1], isTrue);
|
||||
expect(
|
||||
buttonTextStyle('First child').color,
|
||||
theme.colorScheme.onSurface.withOpacity(0.38),
|
||||
|
|
|
@ -507,7 +507,7 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('Custom tooltip margin', (WidgetTester tester) async {
|
||||
const double _customMarginValue = 10.0;
|
||||
const double customMarginValue = 10.0;
|
||||
final GlobalKey key = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
|
@ -520,7 +520,7 @@ void main() {
|
|||
key: key,
|
||||
message: tooltipText,
|
||||
padding: EdgeInsets.zero,
|
||||
margin: const EdgeInsets.all(_customMarginValue),
|
||||
margin: const EdgeInsets.all(customMarginValue),
|
||||
child: const SizedBox(
|
||||
width: 0.0,
|
||||
height: 0.0,
|
||||
|
@ -539,29 +539,29 @@ void main() {
|
|||
_findTooltipContainer(tooltipText),
|
||||
);
|
||||
final Offset topLeftTooltipContentInGlobal = tester.getTopLeft(find.text(tooltipText));
|
||||
expect(topLeftTooltipContentInGlobal.dx, topLeftTipInGlobal.dx + _customMarginValue);
|
||||
expect(topLeftTooltipContentInGlobal.dy, topLeftTipInGlobal.dy + _customMarginValue);
|
||||
expect(topLeftTooltipContentInGlobal.dx, topLeftTipInGlobal.dx + customMarginValue);
|
||||
expect(topLeftTooltipContentInGlobal.dy, topLeftTipInGlobal.dy + customMarginValue);
|
||||
|
||||
final Offset topRightTipInGlobal = tester.getTopRight(
|
||||
_findTooltipContainer(tooltipText),
|
||||
);
|
||||
final Offset topRightTooltipContentInGlobal = tester.getTopRight(find.text(tooltipText));
|
||||
expect(topRightTooltipContentInGlobal.dx, topRightTipInGlobal.dx - _customMarginValue);
|
||||
expect(topRightTooltipContentInGlobal.dy, topRightTipInGlobal.dy + _customMarginValue);
|
||||
expect(topRightTooltipContentInGlobal.dx, topRightTipInGlobal.dx - customMarginValue);
|
||||
expect(topRightTooltipContentInGlobal.dy, topRightTipInGlobal.dy + customMarginValue);
|
||||
|
||||
final Offset bottomLeftTipInGlobal = tester.getBottomLeft(
|
||||
_findTooltipContainer(tooltipText),
|
||||
);
|
||||
final Offset bottomLeftTooltipContentInGlobal = tester.getBottomLeft(find.text(tooltipText));
|
||||
expect(bottomLeftTooltipContentInGlobal.dx, bottomLeftTipInGlobal.dx + _customMarginValue);
|
||||
expect(bottomLeftTooltipContentInGlobal.dy, bottomLeftTipInGlobal.dy - _customMarginValue);
|
||||
expect(bottomLeftTooltipContentInGlobal.dx, bottomLeftTipInGlobal.dx + customMarginValue);
|
||||
expect(bottomLeftTooltipContentInGlobal.dy, bottomLeftTipInGlobal.dy - customMarginValue);
|
||||
|
||||
final Offset bottomRightTipInGlobal = tester.getBottomRight(
|
||||
_findTooltipContainer(tooltipText),
|
||||
);
|
||||
final Offset bottomRightTooltipContentInGlobal = tester.getBottomRight(find.text(tooltipText));
|
||||
expect(bottomRightTooltipContentInGlobal.dx, bottomRightTipInGlobal.dx - _customMarginValue);
|
||||
expect(bottomRightTooltipContentInGlobal.dy, bottomRightTipInGlobal.dy - _customMarginValue);
|
||||
expect(bottomRightTooltipContentInGlobal.dx, bottomRightTipInGlobal.dx - customMarginValue);
|
||||
expect(bottomRightTooltipContentInGlobal.dy, bottomRightTipInGlobal.dy - customMarginValue);
|
||||
});
|
||||
|
||||
testWidgets('Default tooltip message textStyle - light', (WidgetTester tester) async {
|
||||
|
|
|
@ -21,9 +21,9 @@ void main() {
|
|||
..paragraph(offset: const Offset(64.0, 96.0)),
|
||||
);
|
||||
|
||||
final Widget _error = Builder(builder: (BuildContext context) => throw 'pillow');
|
||||
final Widget error = Builder(builder: (BuildContext context) => throw 'pillow');
|
||||
|
||||
await tester.pumpWidget(Center(child: SizedBox(width: 100.0, child: _error)));
|
||||
await tester.pumpWidget(Center(child: SizedBox(width: 100.0, child: error)));
|
||||
expect(tester.takeException(), 'pillow');
|
||||
expect(
|
||||
find.byType(ErrorWidget),
|
||||
|
@ -32,10 +32,10 @@ void main() {
|
|||
..paragraph(offset: const Offset(0.0, 96.0)),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(Center(child: SizedBox(height: 100.0, child: _error)));
|
||||
await tester.pumpWidget(Center(child: SizedBox(height: 100.0, child: error)));
|
||||
expect(tester.takeException(), null);
|
||||
|
||||
await tester.pumpWidget(Center(child: SizedBox(key: UniqueKey(), height: 100.0, child: _error)));
|
||||
await tester.pumpWidget(Center(child: SizedBox(key: UniqueKey(), height: 100.0, child: error)));
|
||||
expect(tester.takeException(), 'pillow');
|
||||
expect(
|
||||
find.byType(ErrorWidget),
|
||||
|
@ -45,7 +45,7 @@ void main() {
|
|||
);
|
||||
|
||||
RenderErrorBox.minimumWidth = 800.0;
|
||||
await tester.pumpWidget(Center(child: _error));
|
||||
await tester.pumpWidget(Center(child: error));
|
||||
expect(tester.takeException(), 'pillow');
|
||||
expect(
|
||||
find.byType(ErrorWidget),
|
||||
|
@ -54,7 +54,7 @@ void main() {
|
|||
..paragraph(offset: const Offset(0.0, 96.0)),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(Center(child: _error));
|
||||
await tester.pumpWidget(Center(child: error));
|
||||
expect(tester.takeException(), null);
|
||||
expect(
|
||||
find.byType(ErrorWidget),
|
||||
|
@ -64,7 +64,7 @@ void main() {
|
|||
);
|
||||
|
||||
RenderErrorBox.backgroundColor = const Color(0xFF112233);
|
||||
await tester.pumpWidget(Center(child: _error));
|
||||
await tester.pumpWidget(Center(child: error));
|
||||
expect(tester.takeException(), null);
|
||||
expect(
|
||||
find.byType(ErrorWidget),
|
||||
|
|
|
@ -16,8 +16,8 @@ typedef MethodCallHandler = Future<dynamic> Function(MethodCall call);
|
|||
typedef SimpleAnnotationFinder = Iterable<HitTestTarget> Function(Offset offset);
|
||||
|
||||
void main() {
|
||||
final TestMouseTrackerFlutterBinding _binding = TestMouseTrackerFlutterBinding();
|
||||
MethodCallHandler? _methodCallHandler;
|
||||
final TestMouseTrackerFlutterBinding binding = TestMouseTrackerFlutterBinding();
|
||||
MethodCallHandler? methodCallHandler;
|
||||
|
||||
// Only one of `logCursors` and `cursorHandler` should be specified.
|
||||
void _setUpMouseTracker({
|
||||
|
@ -26,14 +26,14 @@ void main() {
|
|||
MethodCallHandler? cursorHandler,
|
||||
}) {
|
||||
assert(logCursors == null || cursorHandler == null);
|
||||
_methodCallHandler = logCursors != null
|
||||
methodCallHandler = logCursors != null
|
||||
? (MethodCall call) async {
|
||||
logCursors.add(_CursorUpdateDetails.wrap(call));
|
||||
return;
|
||||
}
|
||||
: cursorHandler;
|
||||
|
||||
_binding.setHitTest((BoxHitTestResult result, Offset position) {
|
||||
binding.setHitTest((BoxHitTestResult result, Offset position) {
|
||||
for (final HitTestTarget target in annotationFinder(position)) {
|
||||
result.addWithRawTransform(
|
||||
transform: Matrix4.identity(),
|
||||
|
@ -55,17 +55,17 @@ void main() {
|
|||
}
|
||||
|
||||
setUp(() {
|
||||
_binding.postFrameCallbacks.clear();
|
||||
_binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.mouseCursor, (MethodCall call) async {
|
||||
if (_methodCallHandler != null) {
|
||||
return _methodCallHandler!(call);
|
||||
binding.postFrameCallbacks.clear();
|
||||
binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.mouseCursor, (MethodCall call) async {
|
||||
if (methodCallHandler != null) {
|
||||
return methodCallHandler!(call);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
_binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.mouseCursor, null);
|
||||
binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.mouseCursor, null);
|
||||
});
|
||||
|
||||
test('Should work on platforms that does not support mouse cursor', () async {
|
||||
|
@ -221,8 +221,8 @@ void main() {
|
|||
|
||||
// Synthesize a new frame while changing annotation
|
||||
annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing);
|
||||
_binding.scheduleMouseTrackerPostFrameCheck();
|
||||
_binding.flushPostFrameCallbacks(Duration.zero);
|
||||
binding.scheduleMouseTrackerPostFrameCheck();
|
||||
binding.flushPostFrameCallbacks(Duration.zero);
|
||||
|
||||
expect(logCursors, <_CursorUpdateDetails>[
|
||||
_CursorUpdateDetails.activateSystemCursor(device: 0, kind: SystemMouseCursors.grabbing.kind),
|
||||
|
@ -231,7 +231,7 @@ void main() {
|
|||
|
||||
// Synthesize a new frame without changing annotation
|
||||
annotation = const TestAnnotationTarget(cursor: SystemMouseCursors.grabbing);
|
||||
_binding.scheduleMouseTrackerPostFrameCheck();
|
||||
binding.scheduleMouseTrackerPostFrameCheck();
|
||||
|
||||
expect(logCursors, <_CursorUpdateDetails>[]);
|
||||
logCursors.clear();
|
||||
|
|
|
@ -16,9 +16,9 @@ MouseTracker get _mouseTracker => RendererBinding.instance!.mouseTracker;
|
|||
typedef SimpleAnnotationFinder = Iterable<TestAnnotationEntry> Function(Offset offset);
|
||||
|
||||
void main() {
|
||||
final TestMouseTrackerFlutterBinding _binding = TestMouseTrackerFlutterBinding();
|
||||
final TestMouseTrackerFlutterBinding binding = TestMouseTrackerFlutterBinding();
|
||||
void _setUpMouseAnnotationFinder(SimpleAnnotationFinder annotationFinder) {
|
||||
_binding.setHitTest((BoxHitTestResult result, Offset position) {
|
||||
binding.setHitTest((BoxHitTestResult result, Offset position) {
|
||||
for (final TestAnnotationEntry entry in annotationFinder(position)) {
|
||||
result.addWithRawTransform(
|
||||
transform: entry.transform,
|
||||
|
@ -70,7 +70,7 @@ void main() {
|
|||
}
|
||||
|
||||
setUp(() {
|
||||
_binding.postFrameCallbacks.clear();
|
||||
binding.postFrameCallbacks.clear();
|
||||
});
|
||||
|
||||
final Matrix4 translate10by20 = Matrix4.translationValues(10, 20, 0);
|
||||
|
@ -270,10 +270,10 @@ void main() {
|
|||
|
||||
// Adding an annotation should trigger Enter event.
|
||||
isInHitRegion = true;
|
||||
_binding.scheduleMouseTrackerPostFrameCheck();
|
||||
expect(_binding.postFrameCallbacks, hasLength(1));
|
||||
binding.scheduleMouseTrackerPostFrameCheck();
|
||||
expect(binding.postFrameCallbacks, hasLength(1));
|
||||
|
||||
_binding.flushPostFrameCallbacks(Duration.zero);
|
||||
binding.flushPostFrameCallbacks(Duration.zero);
|
||||
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
|
||||
EventMatcher<PointerEnterEvent>(const PointerEnterEvent(position: Offset(0, 100)).transformed(translate10by20)),
|
||||
]));
|
||||
|
@ -281,14 +281,14 @@ void main() {
|
|||
|
||||
// Removing an annotation should trigger events.
|
||||
isInHitRegion = false;
|
||||
_binding.scheduleMouseTrackerPostFrameCheck();
|
||||
expect(_binding.postFrameCallbacks, hasLength(1));
|
||||
binding.scheduleMouseTrackerPostFrameCheck();
|
||||
expect(binding.postFrameCallbacks, hasLength(1));
|
||||
|
||||
_binding.flushPostFrameCallbacks(Duration.zero);
|
||||
binding.flushPostFrameCallbacks(Duration.zero);
|
||||
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
|
||||
EventMatcher<PointerExitEvent>(const PointerExitEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)),
|
||||
]));
|
||||
expect(_binding.postFrameCallbacks, hasLength(0));
|
||||
expect(binding.postFrameCallbacks, hasLength(0));
|
||||
});
|
||||
|
||||
test('should correctly handle when the annotation moves in or out of the pointer', () {
|
||||
|
@ -316,29 +316,29 @@ void main() {
|
|||
|
||||
// During a frame, the annotation moves into the pointer.
|
||||
isInHitRegion = true;
|
||||
expect(_binding.postFrameCallbacks, hasLength(0));
|
||||
_binding.scheduleMouseTrackerPostFrameCheck();
|
||||
expect(_binding.postFrameCallbacks, hasLength(1));
|
||||
expect(binding.postFrameCallbacks, hasLength(0));
|
||||
binding.scheduleMouseTrackerPostFrameCheck();
|
||||
expect(binding.postFrameCallbacks, hasLength(1));
|
||||
|
||||
_binding.flushPostFrameCallbacks(Duration.zero);
|
||||
binding.flushPostFrameCallbacks(Duration.zero);
|
||||
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
|
||||
EventMatcher<PointerEnterEvent>(const PointerEnterEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)),
|
||||
]));
|
||||
events.clear();
|
||||
|
||||
expect(_binding.postFrameCallbacks, hasLength(0));
|
||||
expect(binding.postFrameCallbacks, hasLength(0));
|
||||
|
||||
// During a frame, the annotation moves out of the pointer.
|
||||
isInHitRegion = false;
|
||||
expect(_binding.postFrameCallbacks, hasLength(0));
|
||||
_binding.scheduleMouseTrackerPostFrameCheck();
|
||||
expect(_binding.postFrameCallbacks, hasLength(1));
|
||||
expect(binding.postFrameCallbacks, hasLength(0));
|
||||
binding.scheduleMouseTrackerPostFrameCheck();
|
||||
expect(binding.postFrameCallbacks, hasLength(1));
|
||||
|
||||
_binding.flushPostFrameCallbacks(Duration.zero);
|
||||
binding.flushPostFrameCallbacks(Duration.zero);
|
||||
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
|
||||
EventMatcher<PointerExitEvent>(const PointerExitEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)),
|
||||
]));
|
||||
expect(_binding.postFrameCallbacks, hasLength(0));
|
||||
expect(binding.postFrameCallbacks, hasLength(0));
|
||||
});
|
||||
|
||||
test('should correctly handle when the pointer is added or removed on the annotation', () {
|
||||
|
@ -363,7 +363,7 @@ void main() {
|
|||
_pointerData(PointerChange.add, const Offset(0.0, 100.0)),
|
||||
]));
|
||||
|
||||
expect(_binding.postFrameCallbacks, hasLength(0));
|
||||
expect(binding.postFrameCallbacks, hasLength(0));
|
||||
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
|
||||
EventMatcher<PointerEnterEvent>(const PointerEnterEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)),
|
||||
]));
|
||||
|
@ -373,7 +373,7 @@ void main() {
|
|||
ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
|
||||
_pointerData(PointerChange.remove, const Offset(0.0, 100.0)),
|
||||
]));
|
||||
expect(_binding.postFrameCallbacks, hasLength(0));
|
||||
expect(binding.postFrameCallbacks, hasLength(0));
|
||||
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
|
||||
EventMatcher<PointerExitEvent>(const PointerExitEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)),
|
||||
]));
|
||||
|
@ -399,7 +399,7 @@ void main() {
|
|||
]));
|
||||
addTearDown(() => dispatchRemoveDevice());
|
||||
|
||||
expect(_binding.postFrameCallbacks, hasLength(0));
|
||||
expect(binding.postFrameCallbacks, hasLength(0));
|
||||
events.clear();
|
||||
|
||||
// Moves the mouse into the region. Should trigger Enter.
|
||||
|
@ -407,7 +407,7 @@ void main() {
|
|||
ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
|
||||
_pointerData(PointerChange.hover, const Offset(0.0, 100.0)),
|
||||
]));
|
||||
expect(_binding.postFrameCallbacks, hasLength(0));
|
||||
expect(binding.postFrameCallbacks, hasLength(0));
|
||||
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
|
||||
EventMatcher<PointerEnterEvent>(const PointerEnterEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)),
|
||||
EventMatcher<PointerHoverEvent>(const PointerHoverEvent(position: Offset(0.0, 100.0)).transformed(translate10by20)),
|
||||
|
@ -419,7 +419,7 @@ void main() {
|
|||
ui.window.onPointerDataPacket!(ui.PointerDataPacket(data: <ui.PointerData>[
|
||||
_pointerData(PointerChange.hover, const Offset(200.0, 100.0)),
|
||||
]));
|
||||
expect(_binding.postFrameCallbacks, hasLength(0));
|
||||
expect(binding.postFrameCallbacks, hasLength(0));
|
||||
expect(events, _equalToEventsOnCriticalFields(<BaseEventMatcher>[
|
||||
EventMatcher<PointerExitEvent>(const PointerExitEvent(position: Offset(200.0, 100.0)).transformed(translate10by20)),
|
||||
]));
|
||||
|
@ -435,7 +435,7 @@ void main() {
|
|||
]));
|
||||
expect(_mouseTracker.mouseIsConnected, isFalse);
|
||||
|
||||
expect(_binding.postFrameCallbacks, hasLength(0));
|
||||
expect(binding.postFrameCallbacks, hasLength(0));
|
||||
});
|
||||
|
||||
test('should not flip out if not all mouse events are listened to', () {
|
||||
|
|
|
@ -154,7 +154,7 @@ void main() {
|
|||
group('FractionalTranslation', () {
|
||||
testWidgets('hit test - entirely inside the bounding box', (WidgetTester tester) async {
|
||||
final GlobalKey key1 = GlobalKey();
|
||||
bool _pointerDown = false;
|
||||
bool pointerDown = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
|
@ -162,7 +162,7 @@ void main() {
|
|||
translation: Offset.zero,
|
||||
child: Listener(
|
||||
onPointerDown: (PointerDownEvent event) {
|
||||
_pointerDown = true;
|
||||
pointerDown = true;
|
||||
},
|
||||
child: SizedBox(
|
||||
key: key1,
|
||||
|
@ -176,14 +176,14 @@ void main() {
|
|||
),
|
||||
),
|
||||
);
|
||||
expect(_pointerDown, isFalse);
|
||||
expect(pointerDown, isFalse);
|
||||
await tester.tap(find.byKey(key1));
|
||||
expect(_pointerDown, isTrue);
|
||||
expect(pointerDown, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('hit test - partially inside the bounding box', (WidgetTester tester) async {
|
||||
final GlobalKey key1 = GlobalKey();
|
||||
bool _pointerDown = false;
|
||||
bool pointerDown = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
|
@ -191,7 +191,7 @@ void main() {
|
|||
translation: const Offset(0.5, 0.5),
|
||||
child: Listener(
|
||||
onPointerDown: (PointerDownEvent event) {
|
||||
_pointerDown = true;
|
||||
pointerDown = true;
|
||||
},
|
||||
child: SizedBox(
|
||||
key: key1,
|
||||
|
@ -205,14 +205,14 @@ void main() {
|
|||
),
|
||||
),
|
||||
);
|
||||
expect(_pointerDown, isFalse);
|
||||
expect(pointerDown, isFalse);
|
||||
await tester.tap(find.byKey(key1));
|
||||
expect(_pointerDown, isTrue);
|
||||
expect(pointerDown, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('hit test - completely outside the bounding box', (WidgetTester tester) async {
|
||||
final GlobalKey key1 = GlobalKey();
|
||||
bool _pointerDown = false;
|
||||
bool pointerDown = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
|
@ -220,7 +220,7 @@ void main() {
|
|||
translation: const Offset(1.0, 1.0),
|
||||
child: Listener(
|
||||
onPointerDown: (PointerDownEvent event) {
|
||||
_pointerDown = true;
|
||||
pointerDown = true;
|
||||
},
|
||||
child: SizedBox(
|
||||
key: key1,
|
||||
|
@ -234,9 +234,9 @@ void main() {
|
|||
),
|
||||
),
|
||||
);
|
||||
expect(_pointerDown, isFalse);
|
||||
expect(pointerDown, isFalse);
|
||||
await tester.tap(find.byKey(key1));
|
||||
expect(_pointerDown, isTrue);
|
||||
expect(pointerDown, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('semantics bounds are updated', (WidgetTester tester) async {
|
||||
|
|
|
@ -444,7 +444,7 @@ void main() {
|
|||
|
||||
testWidgets('Big child into small fitted box - hit testing', (WidgetTester tester) async {
|
||||
final GlobalKey key1 = GlobalKey();
|
||||
bool _pointerDown = false;
|
||||
bool pointerDown = false;
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: SizedBox(
|
||||
|
@ -457,7 +457,7 @@ void main() {
|
|||
height: 1000.0,
|
||||
child: Listener(
|
||||
onPointerDown: (PointerDownEvent event) {
|
||||
_pointerDown = true;
|
||||
pointerDown = true;
|
||||
},
|
||||
child: Container(
|
||||
key: key1,
|
||||
|
@ -469,9 +469,9 @@ void main() {
|
|||
),
|
||||
),
|
||||
);
|
||||
expect(_pointerDown, isFalse);
|
||||
expect(pointerDown, isFalse);
|
||||
await tester.tap(find.byKey(key1));
|
||||
expect(_pointerDown, isTrue);
|
||||
expect(pointerDown, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Can set and update clipBehavior', (WidgetTester tester) async {
|
||||
|
|
|
@ -10,10 +10,10 @@ import '../painting/mocks_for_image_cache.dart';
|
|||
|
||||
|
||||
void main() {
|
||||
late ImageProvider _image;
|
||||
late ImageProvider image;
|
||||
|
||||
setUpAll(() async {
|
||||
_image = TestImageProvider(
|
||||
image = TestImageProvider(
|
||||
21,
|
||||
42,
|
||||
image: await createTestImage(width: 10, height: 10),
|
||||
|
@ -23,7 +23,7 @@ void main() {
|
|||
testWidgets('ImageIcon sizing - no theme, default size', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
child: ImageIcon(_image),
|
||||
child: ImageIcon(image),
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -37,13 +37,12 @@ void main() {
|
|||
Center(
|
||||
child: IconTheme(
|
||||
data: const IconThemeData(opacity: 0.5),
|
||||
child: ImageIcon(_image),
|
||||
child: ImageIcon(image),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final Image image = tester.widget(find.byType(Image));
|
||||
expect(image.color!.alpha, equals(128));
|
||||
expect(tester.widget<Image>(find.byType(Image)).color!.alpha, equals(128));
|
||||
});
|
||||
|
||||
testWidgets('ImageIcon sizing - no theme, explicit size', (WidgetTester tester) async {
|
||||
|
|
|
@ -74,9 +74,9 @@ class _ShowABCFieldState extends State<ShowABCField> {
|
|||
|
||||
void main() {
|
||||
testWidgets('InheritedModel basics', (WidgetTester tester) async {
|
||||
int _a = 0;
|
||||
int _b = 1;
|
||||
int _c = 2;
|
||||
int a = 0;
|
||||
int b = 1;
|
||||
int c = 2;
|
||||
|
||||
final Widget abcPage = StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
|
@ -97,9 +97,9 @@ void main() {
|
|||
body: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return ABCModel(
|
||||
a: _a,
|
||||
b: _b,
|
||||
c: _c,
|
||||
a: a,
|
||||
b: b,
|
||||
c: c,
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -114,7 +114,7 @@ void main() {
|
|||
// Rebuilds the ABCModel which triggers a rebuild
|
||||
// of showA because showA depends on the 'a' aspect
|
||||
// of the ABCModel.
|
||||
setState(() { _a += 1; });
|
||||
setState(() { a += 1; });
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
|
@ -123,7 +123,7 @@ void main() {
|
|||
// Rebuilds the ABCModel which triggers a rebuild
|
||||
// of showB because showB depends on the 'b' aspect
|
||||
// of the ABCModel.
|
||||
setState(() { _b += 1; });
|
||||
setState(() { b += 1; });
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
|
@ -132,7 +132,7 @@ void main() {
|
|||
// Rebuilds the ABCModel which triggers a rebuild
|
||||
// of showC because showC depends on the 'c' aspect
|
||||
// of the ABCModel.
|
||||
setState(() { _c += 1; });
|
||||
setState(() { c += 1; });
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -206,9 +206,9 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('Inner InheritedModel shadows the outer one', (WidgetTester tester) async {
|
||||
int _a = 0;
|
||||
int _b = 1;
|
||||
int _c = 2;
|
||||
int a = 0;
|
||||
int b = 1;
|
||||
int c = 2;
|
||||
|
||||
// Same as in abcPage in the "InheritedModel basics" test except:
|
||||
// there are two ABCModels and the inner model's "a" and "b"
|
||||
|
@ -234,12 +234,12 @@ void main() {
|
|||
body: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return ABCModel( // The "outer" model
|
||||
a: _a,
|
||||
b: _b,
|
||||
c: _c,
|
||||
a: a,
|
||||
b: b,
|
||||
c: c,
|
||||
child: ABCModel( // The "inner" model
|
||||
a: 100 + _a,
|
||||
b: 100 + _b,
|
||||
a: 100 + a,
|
||||
b: 100 + b,
|
||||
aspects: const <String>{'a'},
|
||||
child: Center(
|
||||
child: Column(
|
||||
|
@ -254,19 +254,19 @@ void main() {
|
|||
ElevatedButton(
|
||||
child: const Text('Increment a'),
|
||||
onPressed: () {
|
||||
setState(() { _a += 1; });
|
||||
setState(() { a += 1; });
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('Increment b'),
|
||||
onPressed: () {
|
||||
setState(() { _b += 1; });
|
||||
setState(() { b += 1; });
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('Increment c'),
|
||||
onPressed: () {
|
||||
setState(() { _c += 1; });
|
||||
setState(() { c += 1; });
|
||||
},
|
||||
),
|
||||
],
|
||||
|
@ -324,10 +324,10 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('InheritedModel inner models supported aspect change', (WidgetTester tester) async {
|
||||
int _a = 0;
|
||||
int _b = 1;
|
||||
int _c = 2;
|
||||
Set<String>? _innerModelAspects = <String>{'a'};
|
||||
int a = 0;
|
||||
int b = 1;
|
||||
int c = 2;
|
||||
Set<String>? innerModelAspects = <String>{'a'};
|
||||
|
||||
// Same as in abcPage in the "Inner InheritedModel shadows the outer one"
|
||||
// test except: the "Add b aspect" changes adds 'b' to the set of
|
||||
|
@ -351,13 +351,13 @@ void main() {
|
|||
body: StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return ABCModel( // The "outer" model
|
||||
a: _a,
|
||||
b: _b,
|
||||
c: _c,
|
||||
a: a,
|
||||
b: b,
|
||||
c: c,
|
||||
child: ABCModel( // The "inner" model
|
||||
a: 100 + _a,
|
||||
b: 100 + _b,
|
||||
aspects: _innerModelAspects,
|
||||
a: 100 + a,
|
||||
b: 100 + b,
|
||||
aspects: innerModelAspects,
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
@ -371,19 +371,19 @@ void main() {
|
|||
ElevatedButton(
|
||||
child: const Text('Increment a'),
|
||||
onPressed: () {
|
||||
setState(() { _a += 1; });
|
||||
setState(() { a += 1; });
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('Increment b'),
|
||||
onPressed: () {
|
||||
setState(() { _b += 1; });
|
||||
setState(() { b += 1; });
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
child: const Text('Increment c'),
|
||||
onPressed: () {
|
||||
setState(() { _c += 1; });
|
||||
setState(() { c += 1; });
|
||||
},
|
||||
),
|
||||
ElevatedButton(
|
||||
|
@ -405,14 +405,14 @@ void main() {
|
|||
},
|
||||
);
|
||||
|
||||
_innerModelAspects = <String>{'a'};
|
||||
innerModelAspects = <String>{'a'};
|
||||
await tester.pumpWidget(MaterialApp(home: abcPage));
|
||||
expect(find.text('a: 100 [0]'), findsOneWidget); // showA depends on the inner model
|
||||
expect(find.text('b: 1 [0]'), findsOneWidget); // showB depends on the outer model
|
||||
expect(find.text('c: 2 [0]'), findsOneWidget);
|
||||
expect(find.text('a: 100 b: 101 c: null'), findsOneWidget); // inner model's a, b, c
|
||||
|
||||
_innerModelAspects = <String>{'a', 'b'};
|
||||
innerModelAspects = <String>{'a', 'b'};
|
||||
await tester.tap(find.text('rebuild'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('a: 100 [1]'), findsOneWidget); // rebuilt showA still depend on the inner model
|
||||
|
@ -447,7 +447,7 @@ void main() {
|
|||
expect(find.text('c: 3 [2]'), findsOneWidget); // rebuilt showC still depends on the outer model
|
||||
expect(find.text('a: 101 b: 102 c: null'), findsOneWidget);
|
||||
|
||||
_innerModelAspects = <String>{'a', 'b', 'c'};
|
||||
innerModelAspects = <String>{'a', 'b', 'c'};
|
||||
await tester.tap(find.text('rebuild'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('a: 101 [3]'), findsOneWidget); // rebuilt showA still depend on the inner model
|
||||
|
@ -456,7 +456,7 @@ void main() {
|
|||
expect(find.text('a: 101 b: 102 c: null'), findsOneWidget); // inner model's a, b, c
|
||||
|
||||
// Now the inner model supports no aspects
|
||||
_innerModelAspects = <String>{};
|
||||
innerModelAspects = <String>{};
|
||||
await tester.tap(find.text('rebuild'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('a: 1 [4]'), findsOneWidget); // rebuilt showA now depends on the outer model
|
||||
|
@ -465,7 +465,7 @@ void main() {
|
|||
expect(find.text('a: 101 b: 102 c: null'), findsOneWidget); // inner model's a, b, c
|
||||
|
||||
// Now the inner model supports all aspects
|
||||
_innerModelAspects = null;
|
||||
innerModelAspects = null;
|
||||
await tester.tap(find.text('rebuild'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('a: 101 [5]'), findsOneWidget); // rebuilt showA now depends on the inner model
|
||||
|
|
|
@ -470,14 +470,14 @@ void main() {
|
|||
|
||||
testWidgets('NestedScrollView and internal scrolling', (WidgetTester tester) async {
|
||||
debugDisableShadows = false;
|
||||
const List<String> _tabs = <String>['Hello', 'World'];
|
||||
const List<String> tabs = <String>['Hello', 'World'];
|
||||
int buildCount = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(home: Material(child:
|
||||
// THE FOLLOWING SECTION IS FROM THE NestedScrollView DOCUMENTATION
|
||||
// (EXCEPT FOR THE CHANGES TO THE buildCount COUNTER)
|
||||
DefaultTabController(
|
||||
length: _tabs.length, // This is the number of tabs.
|
||||
length: tabs.length, // This is the number of tabs.
|
||||
child: NestedScrollView(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
|
@ -510,7 +510,7 @@ void main() {
|
|||
bottom: TabBar(
|
||||
// These are the widgets to put in each tab in the tab
|
||||
// bar.
|
||||
tabs: _tabs.map<Widget>((String name) => Tab(text: name)).toList(),
|
||||
tabs: tabs.map<Widget>((String name) => Tab(text: name)).toList(),
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
),
|
||||
),
|
||||
|
@ -520,7 +520,7 @@ void main() {
|
|||
body: TabBarView(
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
// These are the contents of the tab views, below the tabs.
|
||||
children: _tabs.map<Widget>((String name) {
|
||||
children: tabs.map<Widget>((String name) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
|
|
|
@ -1384,9 +1384,9 @@ void main() {
|
|||
),
|
||||
));
|
||||
|
||||
final CurveTween _defaultBarrierTween = CurveTween(curve: Curves.ease);
|
||||
final CurveTween defaultBarrierTween = CurveTween(curve: Curves.ease);
|
||||
int _getExpectedBarrierTweenAlphaValue(double t) {
|
||||
return Color.getAlphaFromOpacity(_defaultBarrierTween.transform(t));
|
||||
return Color.getAlphaFromOpacity(defaultBarrierTween.transform(t));
|
||||
}
|
||||
|
||||
await tester.tap(find.text('X'));
|
||||
|
@ -1447,9 +1447,9 @@ void main() {
|
|||
),
|
||||
));
|
||||
|
||||
final CurveTween _customBarrierTween = CurveTween(curve: Curves.linear);
|
||||
final CurveTween customBarrierTween = CurveTween(curve: Curves.linear);
|
||||
int _getExpectedBarrierTweenAlphaValue(double t) {
|
||||
return Color.getAlphaFromOpacity(_customBarrierTween.transform(t));
|
||||
return Color.getAlphaFromOpacity(customBarrierTween.transform(t));
|
||||
}
|
||||
|
||||
await tester.tap(find.text('X'));
|
||||
|
@ -1510,9 +1510,9 @@ void main() {
|
|||
),
|
||||
));
|
||||
|
||||
final CurveTween _defaultBarrierTween = CurveTween(curve: Curves.ease);
|
||||
final CurveTween defaultBarrierTween = CurveTween(curve: Curves.ease);
|
||||
int _getExpectedBarrierTweenAlphaValue(double t) {
|
||||
return Color.getAlphaFromOpacity(_defaultBarrierTween.transform(t));
|
||||
return Color.getAlphaFromOpacity(defaultBarrierTween.transform(t));
|
||||
}
|
||||
|
||||
await tester.tap(find.text('X'));
|
||||
|
|
|
@ -341,7 +341,7 @@ void main() {
|
|||
|
||||
testWidgets('Translated child into translated box - hit test', (WidgetTester tester) async {
|
||||
final GlobalKey key1 = GlobalKey();
|
||||
bool _pointerDown = false;
|
||||
bool pointerDown = false;
|
||||
await tester.pumpWidget(
|
||||
Transform.translate(
|
||||
offset: const Offset(100.0, 50.0),
|
||||
|
@ -349,7 +349,7 @@ void main() {
|
|||
offset: const Offset(1000.0, 1000.0),
|
||||
child: Listener(
|
||||
onPointerDown: (PointerDownEvent event) {
|
||||
_pointerDown = true;
|
||||
pointerDown = true;
|
||||
},
|
||||
child: Container(
|
||||
key: key1,
|
||||
|
@ -359,9 +359,9 @@ void main() {
|
|||
),
|
||||
),
|
||||
);
|
||||
expect(_pointerDown, isFalse);
|
||||
expect(pointerDown, isFalse);
|
||||
await tester.tap(find.byKey(key1));
|
||||
expect(_pointerDown, isTrue);
|
||||
expect(pointerDown, isTrue);
|
||||
});
|
||||
|
||||
Widget _generateTransform(bool needsCompositing, double angle) {
|
||||
|
@ -588,9 +588,9 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets("Transform.scale() scales widget uniformly with 'scale' parameter", (WidgetTester tester) async {
|
||||
const double _scale = 1.5;
|
||||
const double _height = 100;
|
||||
const double _width = 150;
|
||||
const double scale = 1.5;
|
||||
const double height = 100;
|
||||
const double width = 150;
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: SizedBox(
|
||||
|
@ -598,26 +598,26 @@ void main() {
|
|||
width: 400,
|
||||
child: Center(
|
||||
child: Transform.scale(
|
||||
scale: _scale,
|
||||
scale: scale,
|
||||
child: Container(
|
||||
height: _height,
|
||||
width: _width,
|
||||
height: height,
|
||||
width: width,
|
||||
decoration: const BoxDecoration(),
|
||||
),
|
||||
),
|
||||
),
|
||||
)));
|
||||
|
||||
const Size _target = Size(_width * _scale, _height * _scale);
|
||||
const Size target = Size(width * scale, height * scale);
|
||||
|
||||
expect(tester.getBottomRight(find.byType(Container)), _target.bottomRight(tester.getTopLeft(find.byType(Container))));
|
||||
expect(tester.getBottomRight(find.byType(Container)), target.bottomRight(tester.getTopLeft(find.byType(Container))));
|
||||
});
|
||||
|
||||
testWidgets("Transform.scale() scales widget according to 'scaleX' and 'scaleY'", (WidgetTester tester) async {
|
||||
const double _scaleX = 1.5;
|
||||
const double _scaleY = 1.2;
|
||||
const double _height = 100;
|
||||
const double _width = 150;
|
||||
const double scaleX = 1.5;
|
||||
const double scaleY = 1.2;
|
||||
const double height = 100;
|
||||
const double width = 150;
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: SizedBox(
|
||||
|
@ -625,20 +625,20 @@ void main() {
|
|||
width: 400,
|
||||
child: Center(
|
||||
child: Transform.scale(
|
||||
scaleX: _scaleX,
|
||||
scaleY: _scaleY,
|
||||
scaleX: scaleX,
|
||||
scaleY: scaleY,
|
||||
child: Container(
|
||||
height: _height,
|
||||
width: _width,
|
||||
height: height,
|
||||
width: width,
|
||||
decoration: const BoxDecoration(),
|
||||
),
|
||||
),
|
||||
),
|
||||
)));
|
||||
|
||||
const Size _target = Size(_width * _scaleX, _height * _scaleY);
|
||||
const Size target = Size(width * scaleX, height * scaleY);
|
||||
|
||||
expect(tester.getBottomRight(find.byType(Container)), _target.bottomRight(tester.getTopLeft(find.byType(Container))));
|
||||
expect(tester.getBottomRight(find.byType(Container)), target.bottomRight(tester.getTopLeft(find.byType(Container))));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -361,23 +361,23 @@ mixin CommandHandlerFactory {
|
|||
)));
|
||||
}
|
||||
|
||||
Future<Result> _scroll(Command command, WidgetController _prober, CreateFinderFactory finderFactory) async {
|
||||
Future<Result> _scroll(Command command, WidgetController prober, CreateFinderFactory finderFactory) async {
|
||||
final Scroll scrollCommand = command as Scroll;
|
||||
final Finder target = await waitForElement(finderFactory.createFinder(scrollCommand.finder));
|
||||
final int totalMoves = scrollCommand.duration.inMicroseconds * scrollCommand.frequency ~/ Duration.microsecondsPerSecond;
|
||||
final Offset delta = Offset(scrollCommand.dx, scrollCommand.dy) / totalMoves.toDouble();
|
||||
final Duration pause = scrollCommand.duration ~/ totalMoves;
|
||||
final Offset startLocation = _prober.getCenter(target);
|
||||
final Offset startLocation = prober.getCenter(target);
|
||||
Offset currentLocation = startLocation;
|
||||
final TestPointer pointer = TestPointer();
|
||||
_prober.binding.handlePointerEvent(pointer.down(startLocation));
|
||||
prober.binding.handlePointerEvent(pointer.down(startLocation));
|
||||
await Future<void>.value(); // so that down and move don't happen in the same microtask
|
||||
for (int moves = 0; moves < totalMoves; moves += 1) {
|
||||
currentLocation = currentLocation + delta;
|
||||
_prober.binding.handlePointerEvent(pointer.move(currentLocation));
|
||||
prober.binding.handlePointerEvent(pointer.move(currentLocation));
|
||||
await Future<void>.delayed(pause);
|
||||
}
|
||||
_prober.binding.handlePointerEvent(pointer.up());
|
||||
prober.binding.handlePointerEvent(pointer.up());
|
||||
|
||||
return Result.empty;
|
||||
}
|
||||
|
|
|
@ -463,7 +463,7 @@ class _CellSheet extends StatelessWidget {
|
|||
final List<Widget> children;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext _context) {
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||
final double rowWidth = constraints.biggest.width;
|
||||
final int cellsPerRow = (rowWidth / cellSize.width).floor();
|
||||
|
|
|
@ -662,19 +662,19 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
|
|||
assert(inTest);
|
||||
_oldExceptionHandler = FlutterError.onError;
|
||||
_oldStackTraceDemangler = FlutterError.demangleStackTrace;
|
||||
int _exceptionCount = 0; // number of un-taken exceptions
|
||||
int exceptionCount = 0; // number of un-taken exceptions
|
||||
FlutterError.onError = (FlutterErrorDetails details) {
|
||||
if (_pendingExceptionDetails != null) {
|
||||
debugPrint = debugPrintOverride; // just in case the test overrides it -- otherwise we won't see the errors!
|
||||
if (_exceptionCount == 0) {
|
||||
_exceptionCount = 2;
|
||||
if (exceptionCount == 0) {
|
||||
exceptionCount = 2;
|
||||
FlutterError.dumpErrorToConsole(_pendingExceptionDetails!, forceReport: true);
|
||||
} else {
|
||||
_exceptionCount += 1;
|
||||
exceptionCount += 1;
|
||||
}
|
||||
FlutterError.dumpErrorToConsole(details, forceReport: true);
|
||||
_pendingExceptionDetails = FlutterErrorDetails(
|
||||
exception: 'Multiple exceptions ($_exceptionCount) were detected during the running of the current test, and at least one was unexpected.',
|
||||
exception: 'Multiple exceptions ($exceptionCount) were detected during the running of the current test, and at least one was unexpected.',
|
||||
library: 'Flutter test framework',
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -221,9 +221,9 @@ void main() {
|
|||
|
||||
Widget _row(List<Widget> widgets) => _boilerplate(Row(children: widgets));
|
||||
|
||||
final Finder _findIcons = find.byWidgetPredicate((Widget widget) => widget is Icon);
|
||||
final Finder _findTexts = find.byWidgetPredicate((Widget widget) => widget is Text);
|
||||
final Finder _findIconsAndTexts = find.byWidgetPredicate((Widget widget) => widget is Icon || widget is Text);
|
||||
final Finder findIcons = find.byWidgetPredicate((Widget widget) => widget is Icon);
|
||||
final Finder findTexts = find.byWidgetPredicate((Widget widget) => widget is Text);
|
||||
final Finder findIconsAndTexts = find.byWidgetPredicate((Widget widget) => widget is Icon || widget is Text);
|
||||
|
||||
testWidgets('Black icons on white background', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_row(<Widget>[
|
||||
|
@ -231,7 +231,7 @@ void main() {
|
|||
_icon(color: Colors.black, background: Colors.white),
|
||||
]));
|
||||
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
});
|
||||
|
||||
testWidgets('Black icons on black background', (WidgetTester tester) async {
|
||||
|
@ -240,7 +240,7 @@ void main() {
|
|||
_icon(color: Colors.black, background: Colors.black),
|
||||
]));
|
||||
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
});
|
||||
|
||||
testWidgets('White icons on black background ("dark mode")', (WidgetTester tester) async {
|
||||
|
@ -249,7 +249,7 @@ void main() {
|
|||
_icon(color: Colors.white, background: Colors.black),
|
||||
]));
|
||||
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
});
|
||||
|
||||
testWidgets('Using different icons', (WidgetTester tester) async {
|
||||
|
@ -260,7 +260,7 @@ void main() {
|
|||
_icon(color: Colors.black, background: Colors.white, icon: Icons.beach_access),
|
||||
]));
|
||||
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
});
|
||||
|
||||
testWidgets('One invalid instance fails entire test', (WidgetTester tester) async {
|
||||
|
@ -269,7 +269,7 @@ void main() {
|
|||
_icon(color: Colors.black, background: Colors.black),
|
||||
]));
|
||||
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
});
|
||||
|
||||
testWidgets('White on different colors, passing', (WidgetTester tester) async {
|
||||
|
@ -280,7 +280,7 @@ void main() {
|
|||
_icon(color: Colors.white, background: Colors.purple[800]!, icon: Icons.beach_access),
|
||||
]));
|
||||
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
});
|
||||
|
||||
testWidgets('White on different colors, failing', (WidgetTester tester) async {
|
||||
|
@ -291,13 +291,13 @@ void main() {
|
|||
_icon(color: Colors.white, background: Colors.purple[800]!, icon: Icons.beach_access),
|
||||
]));
|
||||
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
});
|
||||
|
||||
testWidgets('Absence of icons, passing', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(_row(<Widget>[]));
|
||||
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
});
|
||||
|
||||
testWidgets('Absence of icons, passing - 2nd test', (WidgetTester tester) async {
|
||||
|
@ -306,7 +306,7 @@ void main() {
|
|||
_text(color: Colors.black, background: Colors.black),
|
||||
]));
|
||||
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
});
|
||||
|
||||
testWidgets('Guideline ignores widgets of other types', (WidgetTester tester) async {
|
||||
|
@ -317,9 +317,9 @@ void main() {
|
|||
_text(color: Colors.black, background: Colors.black),
|
||||
]));
|
||||
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findTexts)));
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIconsAndTexts)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findTexts)));
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIconsAndTexts)));
|
||||
});
|
||||
|
||||
testWidgets('Custom minimum ratio - Icons', (WidgetTester tester) async {
|
||||
|
@ -328,8 +328,8 @@ void main() {
|
|||
_icon(color: Colors.black, background: Colors.white),
|
||||
]));
|
||||
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons, minimumRatio: 3.0)));
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findIcons, minimumRatio: 3.0)));
|
||||
});
|
||||
|
||||
testWidgets('Custom minimum ratio - Texts', (WidgetTester tester) async {
|
||||
|
@ -338,8 +338,8 @@ void main() {
|
|||
_text(color: Colors.black, background: Colors.white),
|
||||
]));
|
||||
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findTexts)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findTexts, minimumRatio: 3.0)));
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findTexts)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findTexts, minimumRatio: 3.0)));
|
||||
});
|
||||
|
||||
testWidgets('Custom minimum ratio - Different standards for icons and texts', (WidgetTester tester) async {
|
||||
|
@ -350,8 +350,8 @@ void main() {
|
|||
_text(color: Colors.black, background: Colors.white),
|
||||
]));
|
||||
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findTexts, minimumRatio: 3.0)));
|
||||
await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: findIcons)));
|
||||
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: findTexts, minimumRatio: 3.0)));
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -132,11 +132,11 @@ class IdeConfigCommand extends FlutterCommand {
|
|||
}
|
||||
|
||||
// Skip files we aren't interested in.
|
||||
final RegExp _trackedIdeaFileRegExp = RegExp(
|
||||
final RegExp trackedIdeaFileRegExp = RegExp(
|
||||
r'(\.name|modules.xml|vcs.xml)$',
|
||||
);
|
||||
final bool isATrackedIdeaFile = _hasDirectoryInPath(srcFile, '.idea') &&
|
||||
(_trackedIdeaFileRegExp.hasMatch(relativePath) ||
|
||||
(trackedIdeaFileRegExp.hasMatch(relativePath) ||
|
||||
_hasDirectoryInPath(srcFile, 'runConfigurations'));
|
||||
final bool isAnImlOutsideIdea = !isATrackedIdeaFile && srcFile.path.endsWith('.iml');
|
||||
if (!isATrackedIdeaFile && !isAnImlOutsideIdea) {
|
||||
|
|
|
@ -21,8 +21,8 @@ import 'flutter_test_adapter.dart';
|
|||
/// adapters.
|
||||
class DapServer {
|
||||
DapServer(
|
||||
Stream<List<int>> _input,
|
||||
StreamSink<List<int>> _output, {
|
||||
Stream<List<int>> input,
|
||||
StreamSink<List<int>> output, {
|
||||
required FileSystem fileSystem,
|
||||
required Platform platform,
|
||||
this.ipv6 = false,
|
||||
|
@ -30,7 +30,7 @@ class DapServer {
|
|||
this.enableAuthCodes = true,
|
||||
bool test = false,
|
||||
this.logger,
|
||||
}) : channel = ByteStreamServerChannel(_input, _output, logger) {
|
||||
}) : channel = ByteStreamServerChannel(input, output, logger) {
|
||||
adapter = test
|
||||
? FlutterTestDebugAdapter(channel,
|
||||
fileSystem: fileSystem,
|
||||
|
|
|
@ -88,7 +88,7 @@ class FlutterVersion {
|
|||
|
||||
String? _repositoryUrl;
|
||||
String? get repositoryUrl {
|
||||
final String _ = channel;
|
||||
final String _ = channel; // ignore: no_leading_underscores_for_local_identifiers
|
||||
return _repositoryUrl;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,14 +39,14 @@ void main() {
|
|||
);
|
||||
}
|
||||
|
||||
const FakeCommand _kWhichSysctlCommand = FakeCommand(
|
||||
const FakeCommand kWhichSysctlCommand = FakeCommand(
|
||||
command: <String>[
|
||||
'which',
|
||||
'sysctl',
|
||||
],
|
||||
);
|
||||
|
||||
const FakeCommand _kx64CheckCommand = FakeCommand(
|
||||
const FakeCommand kx64CheckCommand = FakeCommand(
|
||||
command: <String>[
|
||||
'sysctl',
|
||||
'hw.optional.arm64',
|
||||
|
@ -61,8 +61,8 @@ void main() {
|
|||
}) {
|
||||
final FakeProcessManager fakeProcessManager =
|
||||
FakeProcessManager.list(<FakeCommand>[
|
||||
_kWhichSysctlCommand,
|
||||
_kx64CheckCommand,
|
||||
kWhichSysctlCommand,
|
||||
kx64CheckCommand,
|
||||
]);
|
||||
final Xcode xcode = Xcode.test(
|
||||
processManager: fakeProcessManager,
|
||||
|
|
|
@ -94,70 +94,70 @@ baz=qux
|
|||
});
|
||||
|
||||
group('text wrapping', () {
|
||||
const int _lineLength = 40;
|
||||
const String _longLine = 'This is a long line that needs to be wrapped.';
|
||||
final String _longLineWithNewlines = 'This is a long line with newlines that\n'
|
||||
const int lineLength = 40;
|
||||
const String longLine = 'This is a long line that needs to be wrapped.';
|
||||
final String longLineWithNewlines = 'This is a long line with newlines that\n'
|
||||
'needs to be wrapped.\n\n'
|
||||
'${'0123456789' * 5}';
|
||||
final String _longAnsiLineWithNewlines = '${AnsiTerminal.red}This${AnsiTerminal.resetAll} is a long line with newlines that\n'
|
||||
final String longAnsiLineWithNewlines = '${AnsiTerminal.red}This${AnsiTerminal.resetAll} is a long line with newlines that\n'
|
||||
'needs to be wrapped.\n\n'
|
||||
'${AnsiTerminal.green}0123456789${AnsiTerminal.resetAll}'
|
||||
'${'0123456789' * 3}'
|
||||
'${AnsiTerminal.green}0123456789${AnsiTerminal.resetAll}';
|
||||
const String _onlyAnsiSequences = '${AnsiTerminal.red}${AnsiTerminal.resetAll}';
|
||||
final String _indentedLongLineWithNewlines = ' This is an indented long line with newlines that\n'
|
||||
const String onlyAnsiSequences = '${AnsiTerminal.red}${AnsiTerminal.resetAll}';
|
||||
final String indentedLongLineWithNewlines = ' This is an indented long line with newlines that\n'
|
||||
'needs to be wrapped.\n\tAnd preserves tabs.\n \n '
|
||||
'${'0123456789' * 5}';
|
||||
const String _shortLine = 'Short line.';
|
||||
const String _indentedLongLine = ' This is an indented long line that needs to be '
|
||||
const String shortLine = 'Short line.';
|
||||
const String indentedLongLine = ' This is an indented long line that needs to be '
|
||||
'wrapped and indentation preserved.';
|
||||
testWithoutContext('does not wrap by default in tests', () {
|
||||
expect(wrapText(_longLine, columnWidth: 80, shouldWrap: true), equals(_longLine));
|
||||
expect(wrapText(longLine, columnWidth: 80, shouldWrap: true), equals(longLine));
|
||||
});
|
||||
|
||||
testWithoutContext('can override wrap preference if preference is off', () {
|
||||
expect(wrapText(_longLine, columnWidth: _lineLength, shouldWrap: true), equals('''
|
||||
expect(wrapText(longLine, columnWidth: lineLength, shouldWrap: true), equals('''
|
||||
This is a long line that needs to be
|
||||
wrapped.'''));
|
||||
});
|
||||
|
||||
testWithoutContext('can override wrap preference if preference is on', () {
|
||||
expect(wrapText(_longLine, shouldWrap: false, columnWidth: 80), equals(_longLine));
|
||||
expect(wrapText(longLine, shouldWrap: false, columnWidth: 80), equals(longLine));
|
||||
});
|
||||
|
||||
testWithoutContext('does not wrap at all if not told to wrap', () {
|
||||
expect(wrapText(_longLine, columnWidth: 80, shouldWrap: false), equals(_longLine));
|
||||
expect(wrapText(longLine, columnWidth: 80, shouldWrap: false), equals(longLine));
|
||||
});
|
||||
|
||||
testWithoutContext('does not wrap short lines.', () {
|
||||
expect(wrapText(_shortLine, columnWidth: _lineLength, shouldWrap: true), equals(_shortLine));
|
||||
expect(wrapText(shortLine, columnWidth: lineLength, shouldWrap: true), equals(shortLine));
|
||||
});
|
||||
|
||||
testWithoutContext('able to wrap long lines', () {
|
||||
expect(wrapText(_longLine, columnWidth: _lineLength, shouldWrap: true), equals('''
|
||||
expect(wrapText(longLine, columnWidth: lineLength, shouldWrap: true), equals('''
|
||||
This is a long line that needs to be
|
||||
wrapped.'''));
|
||||
});
|
||||
|
||||
testWithoutContext('able to handle dynamically changing terminal column size', () {
|
||||
expect(wrapText(_longLine, columnWidth: 20, shouldWrap: true), equals('''
|
||||
expect(wrapText(longLine, columnWidth: 20, shouldWrap: true), equals('''
|
||||
This is a long line
|
||||
that needs to be
|
||||
wrapped.'''));
|
||||
|
||||
expect(wrapText(_longLine, columnWidth: _lineLength, shouldWrap: true), equals('''
|
||||
expect(wrapText(longLine, columnWidth: lineLength, shouldWrap: true), equals('''
|
||||
This is a long line that needs to be
|
||||
wrapped.'''));
|
||||
});
|
||||
|
||||
testWithoutContext('wrap long lines with no whitespace', () {
|
||||
expect(wrapText('0123456789' * 5, columnWidth: _lineLength, shouldWrap: true), equals('''
|
||||
expect(wrapText('0123456789' * 5, columnWidth: lineLength, shouldWrap: true), equals('''
|
||||
0123456789012345678901234567890123456789
|
||||
0123456789'''));
|
||||
});
|
||||
|
||||
testWithoutContext('refuses to wrap to a column smaller than 10 characters', () {
|
||||
expect(wrapText('$_longLine ${'0123456789' * 4}', columnWidth: 1, shouldWrap: true), equals('''
|
||||
expect(wrapText('$longLine ${'0123456789' * 4}', columnWidth: 1, shouldWrap: true), equals('''
|
||||
This is a
|
||||
long line
|
||||
that needs
|
||||
|
@ -169,21 +169,21 @@ wrapped.
|
|||
0123456789'''));
|
||||
});
|
||||
testWithoutContext('preserves indentation', () {
|
||||
expect(wrapText(_indentedLongLine, columnWidth: _lineLength, shouldWrap: true), equals('''
|
||||
expect(wrapText(indentedLongLine, columnWidth: lineLength, shouldWrap: true), equals('''
|
||||
This is an indented long line that
|
||||
needs to be wrapped and indentation
|
||||
preserved.'''));
|
||||
});
|
||||
|
||||
testWithoutContext('preserves indentation and stripping trailing whitespace', () {
|
||||
expect(wrapText('$_indentedLongLine ', columnWidth: _lineLength, shouldWrap: true), equals('''
|
||||
expect(wrapText('$indentedLongLine ', columnWidth: lineLength, shouldWrap: true), equals('''
|
||||
This is an indented long line that
|
||||
needs to be wrapped and indentation
|
||||
preserved.'''));
|
||||
});
|
||||
|
||||
testWithoutContext('wraps text with newlines', () {
|
||||
expect(wrapText(_longLineWithNewlines, columnWidth: _lineLength, shouldWrap: true), equals('''
|
||||
expect(wrapText(longLineWithNewlines, columnWidth: lineLength, shouldWrap: true), equals('''
|
||||
This is a long line with newlines that
|
||||
needs to be wrapped.
|
||||
|
||||
|
@ -192,7 +192,7 @@ needs to be wrapped.
|
|||
});
|
||||
|
||||
testWithoutContext('wraps text with ANSI sequences embedded', () {
|
||||
expect(wrapText(_longAnsiLineWithNewlines, columnWidth: _lineLength, shouldWrap: true), equals('''
|
||||
expect(wrapText(longAnsiLineWithNewlines, columnWidth: lineLength, shouldWrap: true), equals('''
|
||||
${AnsiTerminal.red}This${AnsiTerminal.resetAll} is a long line with newlines that
|
||||
needs to be wrapped.
|
||||
|
||||
|
@ -201,12 +201,12 @@ ${AnsiTerminal.green}0123456789${AnsiTerminal.resetAll}'''));
|
|||
});
|
||||
|
||||
testWithoutContext('wraps text with only ANSI sequences', () {
|
||||
expect(wrapText(_onlyAnsiSequences, columnWidth: _lineLength, shouldWrap: true),
|
||||
expect(wrapText(onlyAnsiSequences, columnWidth: lineLength, shouldWrap: true),
|
||||
equals('${AnsiTerminal.red}${AnsiTerminal.resetAll}'));
|
||||
});
|
||||
|
||||
testWithoutContext('preserves indentation in the presence of newlines', () {
|
||||
expect(wrapText(_indentedLongLineWithNewlines, columnWidth: _lineLength, shouldWrap: true), equals('''
|
||||
expect(wrapText(indentedLongLineWithNewlines, columnWidth: lineLength, shouldWrap: true), equals('''
|
||||
This is an indented long line with
|
||||
newlines that
|
||||
needs to be wrapped.
|
||||
|
@ -217,37 +217,37 @@ needs to be wrapped.
|
|||
});
|
||||
|
||||
testWithoutContext('removes trailing whitespace when wrapping', () {
|
||||
expect(wrapText('$_longLine \t', columnWidth: _lineLength, shouldWrap: true), equals('''
|
||||
expect(wrapText('$longLine \t', columnWidth: lineLength, shouldWrap: true), equals('''
|
||||
This is a long line that needs to be
|
||||
wrapped.'''));
|
||||
});
|
||||
|
||||
testWithoutContext('honors hangingIndent parameter', () {
|
||||
expect(wrapText(_longLine, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
expect(wrapText(longLine, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
This is a long line that needs to be
|
||||
wrapped.'''));
|
||||
});
|
||||
|
||||
testWithoutContext('handles hangingIndent with a single unwrapped line.', () {
|
||||
expect(wrapText(_shortLine, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
expect(wrapText(shortLine, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
Short line.'''));
|
||||
});
|
||||
|
||||
testWithoutContext('handles hangingIndent with two unwrapped lines and the second is empty.', () {
|
||||
expect(wrapText('$_shortLine\n', columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
expect(wrapText('$shortLine\n', columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
Short line.
|
||||
'''));
|
||||
});
|
||||
|
||||
testWithoutContext('honors hangingIndent parameter on already indented line.', () {
|
||||
expect(wrapText(_indentedLongLine, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
expect(wrapText(indentedLongLine, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
This is an indented long line that
|
||||
needs to be wrapped and
|
||||
indentation preserved.'''));
|
||||
});
|
||||
|
||||
testWithoutContext('honors hangingIndent and indent parameters at the same time.', () {
|
||||
expect(wrapText(_indentedLongLine, columnWidth: _lineLength, indent: 6, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
expect(wrapText(indentedLongLine, columnWidth: lineLength, indent: 6, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
This is an indented long line
|
||||
that needs to be wrapped
|
||||
and indentation
|
||||
|
@ -255,14 +255,14 @@ Short line.
|
|||
});
|
||||
|
||||
testWithoutContext('honors indent parameter on already indented line.', () {
|
||||
expect(wrapText(_indentedLongLine, columnWidth: _lineLength, indent: 6, shouldWrap: true), equals('''
|
||||
expect(wrapText(indentedLongLine, columnWidth: lineLength, indent: 6, shouldWrap: true), equals('''
|
||||
This is an indented long line
|
||||
that needs to be wrapped and
|
||||
indentation preserved.'''));
|
||||
});
|
||||
|
||||
testWithoutContext('honors hangingIndent parameter on already indented line.', () {
|
||||
expect(wrapText(_indentedLongLineWithNewlines, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
expect(wrapText(indentedLongLineWithNewlines, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals('''
|
||||
This is an indented long line with
|
||||
newlines that
|
||||
needs to be wrapped.
|
||||
|
|
|
@ -30,8 +30,8 @@ void main() {
|
|||
});
|
||||
|
||||
testWithoutContext('device.getDevices', () async {
|
||||
final BasicProject _project = BasicProject();
|
||||
await _project.setUpIn(tempDir);
|
||||
final BasicProject project = BasicProject();
|
||||
await project.setUpIn(tempDir);
|
||||
|
||||
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ void main() {
|
|||
});
|
||||
|
||||
testWithoutContext('can run and terminate a Flutter app in debug mode', () async {
|
||||
final BasicProject _project = BasicProject();
|
||||
await _project.setUpIn(tempDir);
|
||||
final BasicProject project = BasicProject();
|
||||
await project.setUpIn(tempDir);
|
||||
|
||||
// Once the "topLevelFunction" output arrives, we can terminate the app.
|
||||
unawaited(
|
||||
|
@ -50,7 +50,7 @@ void main() {
|
|||
final List<OutputEventBody> outputEvents = await dap.client.collectAllOutput(
|
||||
launch: () => dap.client
|
||||
.launch(
|
||||
cwd: _project.dir.path,
|
||||
cwd: project.dir.path,
|
||||
toolArgs: <String>['-d', 'flutter-tester'],
|
||||
),
|
||||
);
|
||||
|
@ -67,8 +67,8 @@ void main() {
|
|||
});
|
||||
|
||||
testWithoutContext('can run and terminate a Flutter app in noDebug mode', () async {
|
||||
final BasicProject _project = BasicProject();
|
||||
await _project.setUpIn(tempDir);
|
||||
final BasicProject project = BasicProject();
|
||||
await project.setUpIn(tempDir);
|
||||
|
||||
// Once the "topLevelFunction" output arrives, we can terminate the app.
|
||||
unawaited(
|
||||
|
@ -80,7 +80,7 @@ void main() {
|
|||
final List<OutputEventBody> outputEvents = await dap.client.collectAllOutput(
|
||||
launch: () => dap.client
|
||||
.launch(
|
||||
cwd: _project.dir.path,
|
||||
cwd: project.dir.path,
|
||||
noDebug: true,
|
||||
toolArgs: <String>['-d', 'flutter-tester'],
|
||||
),
|
||||
|
@ -97,13 +97,13 @@ void main() {
|
|||
});
|
||||
|
||||
testWithoutContext('correctly outputs launch errors and terminates', () async {
|
||||
final CompileErrorProject _project = CompileErrorProject();
|
||||
await _project.setUpIn(tempDir);
|
||||
final CompileErrorProject project = CompileErrorProject();
|
||||
await project.setUpIn(tempDir);
|
||||
|
||||
final List<OutputEventBody> outputEvents = await dap.client.collectAllOutput(
|
||||
launch: () => dap.client
|
||||
.launch(
|
||||
cwd: _project.dir.path,
|
||||
cwd: project.dir.path,
|
||||
toolArgs: <String>['-d', 'flutter-tester'],
|
||||
),
|
||||
);
|
||||
|
@ -115,15 +115,15 @@ void main() {
|
|||
});
|
||||
|
||||
testWithoutContext('can hot reload', () async {
|
||||
final BasicProject _project = BasicProject();
|
||||
await _project.setUpIn(tempDir);
|
||||
final BasicProject project = BasicProject();
|
||||
await project.setUpIn(tempDir);
|
||||
|
||||
// Launch the app and wait for it to print "topLevelFunction".
|
||||
await Future.wait(<Future<Object>>[
|
||||
dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')),
|
||||
dap.client.start(
|
||||
launch: () => dap.client.launch(
|
||||
cwd: _project.dir.path,
|
||||
cwd: project.dir.path,
|
||||
noDebug: true,
|
||||
toolArgs: <String>['-d', 'flutter-tester'],
|
||||
),
|
||||
|
@ -152,15 +152,15 @@ void main() {
|
|||
});
|
||||
|
||||
testWithoutContext('can hot restart', () async {
|
||||
final BasicProject _project = BasicProject();
|
||||
await _project.setUpIn(tempDir);
|
||||
final BasicProject project = BasicProject();
|
||||
await project.setUpIn(tempDir);
|
||||
|
||||
// Launch the app and wait for it to print "topLevelFunction".
|
||||
await Future.wait(<Future<Object>>[
|
||||
dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')),
|
||||
dap.client.start(
|
||||
launch: () => dap.client.launch(
|
||||
cwd: _project.dir.path,
|
||||
cwd: project.dir.path,
|
||||
noDebug: true,
|
||||
toolArgs: <String>['-d', 'flutter-tester'],
|
||||
),
|
||||
|
@ -189,8 +189,8 @@ void main() {
|
|||
});
|
||||
|
||||
testWithoutContext('can hot restart when exceptions occur on outgoing isolates', () async {
|
||||
final BasicProjectThatThrows _project = BasicProjectThatThrows();
|
||||
await _project.setUpIn(tempDir);
|
||||
final BasicProjectThatThrows project = BasicProjectThatThrows();
|
||||
await project.setUpIn(tempDir);
|
||||
|
||||
// Launch the app and wait for it to stop at an exception.
|
||||
int originalThreadId, newThreadId;
|
||||
|
@ -200,7 +200,7 @@ void main() {
|
|||
dap.client.start(
|
||||
exceptionPauseMode: 'All', // Ensure we stop on all exceptions
|
||||
launch: () => dap.client.launch(
|
||||
cwd: _project.dir.path,
|
||||
cwd: project.dir.path,
|
||||
toolArgs: <String>['-d', 'flutter-tester'],
|
||||
),
|
||||
),
|
||||
|
@ -222,8 +222,8 @@ void main() {
|
|||
});
|
||||
|
||||
testWithoutContext('sends events for extension state updates', () async {
|
||||
final BasicProject _project = BasicProject();
|
||||
await _project.setUpIn(tempDir);
|
||||
final BasicProject project = BasicProject();
|
||||
await project.setUpIn(tempDir);
|
||||
const String debugPaintRpc = 'ext.flutter.debugPaint';
|
||||
|
||||
// Create a future to capture the isolate ID when the debug paint service
|
||||
|
@ -239,7 +239,7 @@ void main() {
|
|||
output.output.startsWith('topLevelFunction')),
|
||||
dap.client.start(
|
||||
launch: () => dap.client.launch(
|
||||
cwd: _project.dir.path,
|
||||
cwd: project.dir.path,
|
||||
toolArgs: <String>['-d', 'flutter-tester'],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -131,8 +131,8 @@ class OutOfProcessDapTestServer extends DapTestServer {
|
|||
...?additionalArgs,
|
||||
];
|
||||
|
||||
final Process _process = await Process.start(executable, args);
|
||||
final Process process = await Process.start(executable, args);
|
||||
|
||||
return OutOfProcessDapTestServer._(_process, logger);
|
||||
return OutOfProcessDapTestServer._(process, logger);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,32 +21,32 @@ void main() {
|
|||
});
|
||||
|
||||
testWithoutContext('can step over statements', () async {
|
||||
final SteppingProject _project = SteppingProject();
|
||||
await _project.setUpIn(tempDir);
|
||||
final SteppingProject project = SteppingProject();
|
||||
await project.setUpIn(tempDir);
|
||||
|
||||
final FlutterRunTestDriver _flutter = FlutterRunTestDriver(tempDir);
|
||||
final FlutterRunTestDriver flutter = FlutterRunTestDriver(tempDir);
|
||||
|
||||
await _flutter.run(withDebugger: true, startPaused: true);
|
||||
await _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine);
|
||||
await _flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint.
|
||||
await flutter.run(withDebugger: true, startPaused: true);
|
||||
await flutter.addBreakpoint(project.breakpointUri, project.breakpointLine);
|
||||
await flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint.
|
||||
|
||||
expect((await _flutter.getSourceLocation())?.line, equals(_project.breakpointLine));
|
||||
expect((await flutter.getSourceLocation())?.line, equals(project.breakpointLine));
|
||||
|
||||
// Issue 5 steps, ensuring that we end up on the annotated lines each time.
|
||||
for (int i = 1; i <= _project.numberOfSteps; i += 1) {
|
||||
await _flutter.stepOverOrOverAsyncSuspension();
|
||||
final SourcePosition? location = await _flutter.getSourceLocation();
|
||||
for (int i = 1; i <= project.numberOfSteps; i += 1) {
|
||||
await flutter.stepOverOrOverAsyncSuspension();
|
||||
final SourcePosition? location = await flutter.getSourceLocation();
|
||||
final int? actualLine = location?.line;
|
||||
|
||||
// Get the line we're expected to stop at by searching for the comment
|
||||
// within the source code.
|
||||
final int expectedLine = _project.lineForStep(i);
|
||||
final int expectedLine = project.lineForStep(i);
|
||||
|
||||
expect(actualLine, equals(expectedLine),
|
||||
reason: 'After $i steps, debugger should stop at $expectedLine but stopped at $actualLine'
|
||||
);
|
||||
}
|
||||
|
||||
await _flutter.stop();
|
||||
await flutter.stop();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ import 'test_utils.dart';
|
|||
|
||||
void main() {
|
||||
late Directory tempDir;
|
||||
late FlutterRunTestDriver _flutter;
|
||||
late FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('run_test.');
|
||||
_flutter = FlutterRunTestDriver(tempDir);
|
||||
flutter = FlutterRunTestDriver(tempDir);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await _flutter.stop();
|
||||
await flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
|
|
|
@ -15,130 +15,130 @@ import 'test_driver.dart';
|
|||
import 'test_utils.dart';
|
||||
|
||||
void batch1() {
|
||||
final BasicProject _project = BasicProject();
|
||||
final BasicProject project = BasicProject();
|
||||
Directory tempDir;
|
||||
FlutterRunTestDriver _flutter;
|
||||
FlutterRunTestDriver flutter;
|
||||
|
||||
Future<void> initProject() async {
|
||||
tempDir = createResolvedTempDirectorySync('run_expression_eval_test.');
|
||||
await _project.setUpIn(tempDir);
|
||||
_flutter = FlutterRunTestDriver(tempDir);
|
||||
await project.setUpIn(tempDir);
|
||||
flutter = FlutterRunTestDriver(tempDir);
|
||||
}
|
||||
|
||||
Future<void> cleanProject() async {
|
||||
await _flutter.stop();
|
||||
await flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
}
|
||||
|
||||
Future<void> breakInBuildMethod(FlutterTestDriver flutter) async {
|
||||
await _flutter.breakAt(
|
||||
_project.buildMethodBreakpointUri,
|
||||
_project.buildMethodBreakpointLine,
|
||||
await flutter.breakAt(
|
||||
project.buildMethodBreakpointUri,
|
||||
project.buildMethodBreakpointLine,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> breakInTopLevelFunction(FlutterTestDriver flutter) async {
|
||||
await _flutter.breakAt(
|
||||
_project.topLevelFunctionBreakpointUri,
|
||||
_project.topLevelFunctionBreakpointLine,
|
||||
await flutter.breakAt(
|
||||
project.topLevelFunctionBreakpointUri,
|
||||
project.topLevelFunctionBreakpointLine,
|
||||
);
|
||||
}
|
||||
|
||||
testWithoutContext('flutter run expression evaluation - can evaluate trivial expressions in top level function', () async {
|
||||
await initProject();
|
||||
await _flutter.run(withDebugger: true);
|
||||
await breakInTopLevelFunction(_flutter);
|
||||
await evaluateTrivialExpressions(_flutter);
|
||||
await flutter.run(withDebugger: true);
|
||||
await breakInTopLevelFunction(flutter);
|
||||
await evaluateTrivialExpressions(flutter);
|
||||
await cleanProject();
|
||||
});
|
||||
|
||||
testWithoutContext('flutter run expression evaluation - can evaluate trivial expressions in build method', () async {
|
||||
await initProject();
|
||||
await _flutter.run(withDebugger: true);
|
||||
await breakInBuildMethod(_flutter);
|
||||
await evaluateTrivialExpressions(_flutter);
|
||||
await flutter.run(withDebugger: true);
|
||||
await breakInBuildMethod(flutter);
|
||||
await evaluateTrivialExpressions(flutter);
|
||||
await cleanProject();
|
||||
});
|
||||
|
||||
testWithoutContext('flutter run expression evaluation - can evaluate complex expressions in top level function', () async {
|
||||
await initProject();
|
||||
await _flutter.run(withDebugger: true);
|
||||
await breakInTopLevelFunction(_flutter);
|
||||
await evaluateComplexExpressions(_flutter);
|
||||
await flutter.run(withDebugger: true);
|
||||
await breakInTopLevelFunction(flutter);
|
||||
await evaluateComplexExpressions(flutter);
|
||||
await cleanProject();
|
||||
});
|
||||
|
||||
testWithoutContext('flutter run expression evaluation - can evaluate complex expressions in build method', () async {
|
||||
await initProject();
|
||||
await _flutter.run(withDebugger: true);
|
||||
await breakInBuildMethod(_flutter);
|
||||
await evaluateComplexExpressions(_flutter);
|
||||
await flutter.run(withDebugger: true);
|
||||
await breakInBuildMethod(flutter);
|
||||
await evaluateComplexExpressions(flutter);
|
||||
await cleanProject();
|
||||
});
|
||||
|
||||
testWithoutContext('flutter run expression evaluation - can evaluate expressions returning complex objects in top level function', () async {
|
||||
await initProject();
|
||||
await _flutter.run(withDebugger: true);
|
||||
await breakInTopLevelFunction(_flutter);
|
||||
await evaluateComplexReturningExpressions(_flutter);
|
||||
await flutter.run(withDebugger: true);
|
||||
await breakInTopLevelFunction(flutter);
|
||||
await evaluateComplexReturningExpressions(flutter);
|
||||
await cleanProject();
|
||||
});
|
||||
|
||||
testWithoutContext('flutter run expression evaluation - can evaluate expressions returning complex objects in build method', () async {
|
||||
await initProject();
|
||||
await _flutter.run(withDebugger: true);
|
||||
await breakInBuildMethod(_flutter);
|
||||
await evaluateComplexReturningExpressions(_flutter);
|
||||
await flutter.run(withDebugger: true);
|
||||
await breakInBuildMethod(flutter);
|
||||
await evaluateComplexReturningExpressions(flutter);
|
||||
await cleanProject();
|
||||
});
|
||||
}
|
||||
|
||||
void batch2() {
|
||||
final TestsProject _project = TestsProject();
|
||||
final TestsProject project = TestsProject();
|
||||
Directory tempDir;
|
||||
FlutterTestTestDriver _flutter;
|
||||
FlutterTestTestDriver flutter;
|
||||
|
||||
Future<void> initProject() async {
|
||||
tempDir = createResolvedTempDirectorySync('test_expression_eval_test.');
|
||||
await _project.setUpIn(tempDir);
|
||||
_flutter = FlutterTestTestDriver(tempDir);
|
||||
await project.setUpIn(tempDir);
|
||||
flutter = FlutterTestTestDriver(tempDir);
|
||||
}
|
||||
|
||||
Future<void> cleanProject() async {
|
||||
await _flutter?.waitForCompletion();
|
||||
await flutter?.waitForCompletion();
|
||||
tryToDelete(tempDir);
|
||||
}
|
||||
|
||||
testWithoutContext('flutter test expression evaluation - can evaluate trivial expressions in a test', () async {
|
||||
await initProject();
|
||||
await _flutter.test(
|
||||
await flutter.test(
|
||||
withDebugger: true,
|
||||
beforeStart: () => _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine),
|
||||
beforeStart: () => flutter.addBreakpoint(project.breakpointUri, project.breakpointLine),
|
||||
);
|
||||
await _flutter.waitForPause();
|
||||
await evaluateTrivialExpressions(_flutter);
|
||||
await flutter.waitForPause();
|
||||
await evaluateTrivialExpressions(flutter);
|
||||
await cleanProject();
|
||||
});
|
||||
|
||||
testWithoutContext('flutter test expression evaluation - can evaluate complex expressions in a test', () async {
|
||||
await initProject();
|
||||
await _flutter.test(
|
||||
await flutter.test(
|
||||
withDebugger: true,
|
||||
beforeStart: () => _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine),
|
||||
beforeStart: () => flutter.addBreakpoint(project.breakpointUri, project.breakpointLine),
|
||||
);
|
||||
await _flutter.waitForPause();
|
||||
await evaluateComplexExpressions(_flutter);
|
||||
await flutter.waitForPause();
|
||||
await evaluateComplexExpressions(flutter);
|
||||
await cleanProject();
|
||||
});
|
||||
|
||||
testWithoutContext('flutter test expression evaluation - can evaluate expressions returning complex objects in a test', () async {
|
||||
await initProject();
|
||||
await _flutter.test(
|
||||
await flutter.test(
|
||||
withDebugger: true,
|
||||
beforeStart: () => _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine),
|
||||
beforeStart: () => flutter.addBreakpoint(project.breakpointUri, project.breakpointLine),
|
||||
);
|
||||
await _flutter.waitForPause();
|
||||
await evaluateComplexReturningExpressions(_flutter);
|
||||
await flutter.waitForPause();
|
||||
await evaluateComplexReturningExpressions(flutter);
|
||||
await cleanProject();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,15 +13,15 @@ import 'test_driver.dart';
|
|||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
FlutterRunTestDriver _flutterRun, _flutterAttach;
|
||||
final BasicProject _project = BasicProject();
|
||||
FlutterRunTestDriver flutterRun, flutterAttach;
|
||||
final BasicProject project = BasicProject();
|
||||
Directory tempDir;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('attach_test.');
|
||||
await _project.setUpIn(tempDir);
|
||||
_flutterRun = FlutterRunTestDriver(tempDir, logPrefix: ' RUN ');
|
||||
_flutterAttach = FlutterRunTestDriver(
|
||||
await project.setUpIn(tempDir);
|
||||
flutterRun = FlutterRunTestDriver(tempDir, logPrefix: ' RUN ');
|
||||
flutterAttach = FlutterRunTestDriver(
|
||||
tempDir,
|
||||
logPrefix: 'ATTACH ',
|
||||
// Only one DDS instance can be connected to the VM service at a time.
|
||||
|
@ -32,74 +32,74 @@ void main() {
|
|||
});
|
||||
|
||||
tearDown(() async {
|
||||
await _flutterAttach.detach();
|
||||
await _flutterRun.stop();
|
||||
await flutterAttach.detach();
|
||||
await flutterRun.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
testWithoutContext('can hot reload', () async {
|
||||
await _flutterRun.run(withDebugger: true);
|
||||
await _flutterAttach.attach(_flutterRun.vmServicePort);
|
||||
await _flutterAttach.hotReload();
|
||||
await flutterRun.run(withDebugger: true);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort);
|
||||
await flutterAttach.hotReload();
|
||||
});
|
||||
|
||||
testWithoutContext('can detach, reattach, hot reload', () async {
|
||||
await _flutterRun.run(withDebugger: true);
|
||||
await _flutterAttach.attach(_flutterRun.vmServicePort);
|
||||
await _flutterAttach.detach();
|
||||
await _flutterAttach.attach(_flutterRun.vmServicePort);
|
||||
await _flutterAttach.hotReload();
|
||||
await flutterRun.run(withDebugger: true);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort);
|
||||
await flutterAttach.detach();
|
||||
await flutterAttach.attach(flutterRun.vmServicePort);
|
||||
await flutterAttach.hotReload();
|
||||
});
|
||||
|
||||
testWithoutContext('killing process behaves the same as detach ', () async {
|
||||
await _flutterRun.run(withDebugger: true);
|
||||
await _flutterAttach.attach(_flutterRun.vmServicePort);
|
||||
await _flutterAttach.quit();
|
||||
_flutterAttach = FlutterRunTestDriver(
|
||||
await flutterRun.run(withDebugger: true);
|
||||
await flutterAttach.attach(flutterRun.vmServicePort);
|
||||
await flutterAttach.quit();
|
||||
flutterAttach = FlutterRunTestDriver(
|
||||
tempDir,
|
||||
logPrefix: 'ATTACH-2',
|
||||
spawnDdsInstance: false,
|
||||
);
|
||||
await _flutterAttach.attach(_flutterRun.vmServicePort);
|
||||
await _flutterAttach.hotReload();
|
||||
await flutterAttach.attach(flutterRun.vmServicePort);
|
||||
await flutterAttach.hotReload();
|
||||
});
|
||||
|
||||
testWithoutContext('sets activeDevToolsServerAddress extension', () async {
|
||||
await _flutterRun.run(
|
||||
await flutterRun.run(
|
||||
startPaused: true,
|
||||
withDebugger: true,
|
||||
additionalCommandArgs: <String>['--devtools-server-address', 'http://127.0.0.1:9105'],
|
||||
);
|
||||
await _flutterRun.resume();
|
||||
await flutterRun.resume();
|
||||
await pollForServiceExtensionValue<String>(
|
||||
testDriver: _flutterRun,
|
||||
testDriver: flutterRun,
|
||||
extension: 'ext.flutter.activeDevToolsServerAddress',
|
||||
continuePollingValue: '',
|
||||
matches: equals('http://127.0.0.1:9105'),
|
||||
);
|
||||
await pollForServiceExtensionValue<String>(
|
||||
testDriver: _flutterRun,
|
||||
testDriver: flutterRun,
|
||||
extension: 'ext.flutter.connectedVmServiceUri',
|
||||
continuePollingValue: '',
|
||||
matches: isNotEmpty,
|
||||
);
|
||||
|
||||
final Response response = await _flutterRun.callServiceExtension('ext.flutter.connectedVmServiceUri');
|
||||
final Response response = await flutterRun.callServiceExtension('ext.flutter.connectedVmServiceUri');
|
||||
final String vmServiceUri = response.json['value'] as String;
|
||||
|
||||
// Attach with a different DevTools server address.
|
||||
await _flutterAttach.attach(
|
||||
_flutterRun.vmServicePort,
|
||||
await flutterAttach.attach(
|
||||
flutterRun.vmServicePort,
|
||||
additionalCommandArgs: <String>['--devtools-server-address', 'http://127.0.0.1:9110'],
|
||||
);
|
||||
await pollForServiceExtensionValue<String>(
|
||||
testDriver: _flutterAttach,
|
||||
testDriver: flutterAttach,
|
||||
extension: 'ext.flutter.activeDevToolsServerAddress',
|
||||
continuePollingValue: '',
|
||||
matches: equals('http://127.0.0.1:9110'),
|
||||
);
|
||||
await pollForServiceExtensionValue<String>(
|
||||
testDriver: _flutterRun,
|
||||
testDriver: flutterRun,
|
||||
extension: 'ext.flutter.connectedVmServiceUri',
|
||||
continuePollingValue: '',
|
||||
matches: equals(vmServiceUri),
|
||||
|
|
|
@ -15,17 +15,17 @@ import 'test_utils.dart';
|
|||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
final BasicProject _project = BasicProject();
|
||||
FlutterRunTestDriver _flutter;
|
||||
final BasicProject project = BasicProject();
|
||||
FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('run_test.');
|
||||
await _project.setUpIn(tempDir);
|
||||
_flutter = FlutterRunTestDriver(tempDir);
|
||||
await project.setUpIn(tempDir);
|
||||
flutter = FlutterRunTestDriver(tempDir);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await _flutter.stop();
|
||||
await flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
|
@ -36,35 +36,35 @@ void main() {
|
|||
// some of the checks for devices.
|
||||
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||
|
||||
const ProcessManager _processManager = LocalProcessManager();
|
||||
final ProcessResult _proc = await _processManager.run(
|
||||
const ProcessManager processManager = LocalProcessManager();
|
||||
final ProcessResult proc = await processManager.run(
|
||||
<String>[flutterBin, 'run', '-d', 'invalid-device-id'],
|
||||
workingDirectory: tempDir.path,
|
||||
);
|
||||
|
||||
expect(_proc.stdout, isNot(contains('flutter has exited unexpectedly')));
|
||||
expect(_proc.stderr, isNot(contains('flutter has exited unexpectedly')));
|
||||
if (!_proc.stderr.toString().contains('Unable to locate a development')
|
||||
&& !_proc.stdout.toString().contains('No devices found with name or id matching')) {
|
||||
expect(proc.stdout, isNot(contains('flutter has exited unexpectedly')));
|
||||
expect(proc.stderr, isNot(contains('flutter has exited unexpectedly')));
|
||||
if (!proc.stderr.toString().contains('Unable to locate a development')
|
||||
&& !proc.stdout.toString().contains('No devices found with name or id matching')) {
|
||||
fail("'flutter run -d invalid-device-id' did not produce the expected error");
|
||||
}
|
||||
});
|
||||
|
||||
testWithoutContext('sets activeDevToolsServerAddress extension', () async {
|
||||
await _flutter.run(
|
||||
await flutter.run(
|
||||
startPaused: true,
|
||||
withDebugger: true,
|
||||
additionalCommandArgs: <String>['--devtools-server-address', 'http://127.0.0.1:9110'],
|
||||
);
|
||||
await _flutter.resume();
|
||||
await flutter.resume();
|
||||
await pollForServiceExtensionValue<String>(
|
||||
testDriver: _flutter,
|
||||
testDriver: flutter,
|
||||
extension: 'ext.flutter.activeDevToolsServerAddress',
|
||||
continuePollingValue: '',
|
||||
matches: equals('http://127.0.0.1:9110'),
|
||||
);
|
||||
await pollForServiceExtensionValue<String>(
|
||||
testDriver: _flutter,
|
||||
testDriver: flutter,
|
||||
extension: 'ext.flutter.connectedVmServiceUri',
|
||||
continuePollingValue: '',
|
||||
matches: isNotEmpty,
|
||||
|
|
|
@ -18,14 +18,14 @@ import 'test_utils.dart';
|
|||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
final ProjectWithEarlyError _project = ProjectWithEarlyError();
|
||||
const String _exceptionStart = '══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞══════════════════';
|
||||
FlutterRunTestDriver _flutter;
|
||||
final ProjectWithEarlyError project = ProjectWithEarlyError();
|
||||
const String exceptionStart = '══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞══════════════════';
|
||||
FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('run_test.');
|
||||
await _project.setUpIn(tempDir);
|
||||
_flutter = FlutterRunTestDriver(tempDir);
|
||||
await project.setUpIn(tempDir);
|
||||
flutter = FlutterRunTestDriver(tempDir);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
|
@ -75,23 +75,23 @@ void main() {
|
|||
|
||||
await process.exitCode;
|
||||
|
||||
expect(stdout.toString(), contains(_exceptionStart));
|
||||
expect(stdout.toString(), contains(exceptionStart));
|
||||
});
|
||||
|
||||
testWithoutContext('flutter run in machine mode does not print an error', () async {
|
||||
final StringBuffer stdout = StringBuffer();
|
||||
|
||||
await _flutter.run(
|
||||
await flutter.run(
|
||||
startPaused: true,
|
||||
withDebugger: true,
|
||||
structuredErrors: true,
|
||||
);
|
||||
await _flutter.resume();
|
||||
await flutter.resume();
|
||||
|
||||
final Completer<void> completer = Completer<void>();
|
||||
|
||||
await Future<void>(() async {
|
||||
_flutter.stdout.listen((String line) {
|
||||
flutter.stdout.listen((String line) {
|
||||
stdout.writeln(line);
|
||||
});
|
||||
await completer.future;
|
||||
|
@ -99,8 +99,8 @@ void main() {
|
|||
// We don't expect to see any output but want to write to stdout anyway.
|
||||
completer.complete();
|
||||
});
|
||||
await _flutter.stop();
|
||||
await flutter.stop();
|
||||
|
||||
expect(stdout.toString(), isNot(contains(_exceptionStart)));
|
||||
expect(stdout.toString(), isNot(contains(exceptionStart)));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,30 +17,30 @@ import 'test_utils.dart';
|
|||
const Duration requiredLifespan = Duration(seconds: 5);
|
||||
|
||||
void main() {
|
||||
final BasicProject _project = BasicProject();
|
||||
FlutterRunTestDriver _flutter;
|
||||
final BasicProject project = BasicProject();
|
||||
FlutterRunTestDriver flutter;
|
||||
Directory tempDir;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('lifetime_test.');
|
||||
await _project.setUpIn(tempDir);
|
||||
_flutter = FlutterRunTestDriver(tempDir);
|
||||
await project.setUpIn(tempDir);
|
||||
flutter = FlutterRunTestDriver(tempDir);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await _flutter.stop();
|
||||
await flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
testWithoutContext('flutter run does not terminate when a debugger is attached', () async {
|
||||
await _flutter.run(withDebugger: true);
|
||||
await flutter.run(withDebugger: true);
|
||||
await Future<void>.delayed(requiredLifespan);
|
||||
expect(_flutter.hasExited, equals(false));
|
||||
expect(flutter.hasExited, equals(false));
|
||||
});
|
||||
|
||||
testWithoutContext('flutter run does not terminate when a debugger is attached and pause-on-exceptions', () async {
|
||||
await _flutter.run(withDebugger: true, pauseOnExceptions: true);
|
||||
await flutter.run(withDebugger: true, pauseOnExceptions: true);
|
||||
await Future<void>.delayed(requiredLifespan);
|
||||
expect(_flutter.hasExited, equals(false));
|
||||
expect(flutter.hasExited, equals(false));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ import 'test_utils.dart';
|
|||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
FlutterRunTestDriver _flutter;
|
||||
FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('run_test.');
|
||||
_flutter = FlutterRunTestDriver(tempDir);
|
||||
flutter = FlutterRunTestDriver(tempDir);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await _flutter.stop();
|
||||
await flutter.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
|
|
|
@ -44,11 +44,11 @@ Future<void> waitForObservatoryMessage(Process process, int port) async {
|
|||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
final BasicProject _project = BasicProject();
|
||||
final BasicProject project = BasicProject();
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('run_test.');
|
||||
await _project.setUpIn(tempDir);
|
||||
await project.setUpIn(tempDir);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
|
|
|
@ -17,33 +17,33 @@ import 'test_utils.dart';
|
|||
// stateful one and back.
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
final HotReloadProject _project = HotReloadProject();
|
||||
FlutterRunTestDriver _flutter;
|
||||
final HotReloadProject project = HotReloadProject();
|
||||
FlutterRunTestDriver flutter;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('hot_reload_test.');
|
||||
await _project.setUpIn(tempDir);
|
||||
_flutter = FlutterRunTestDriver(tempDir);
|
||||
await project.setUpIn(tempDir);
|
||||
flutter = FlutterRunTestDriver(tempDir);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await _flutter?.stop();
|
||||
await flutter?.stop();
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
testWithoutContext('Can switch between stateless and stateful', () async {
|
||||
await _flutter.run();
|
||||
await _flutter.hotReload();
|
||||
await flutter.run();
|
||||
await flutter.hotReload();
|
||||
final StringBuffer stdout = StringBuffer();
|
||||
final StreamSubscription<String> subscription = _flutter.stdout.listen(stdout.writeln);
|
||||
final StreamSubscription<String> subscription = flutter.stdout.listen(stdout.writeln);
|
||||
|
||||
// switch to stateful.
|
||||
_project.toggleState();
|
||||
await _flutter.hotReload();
|
||||
project.toggleState();
|
||||
await flutter.hotReload();
|
||||
|
||||
// switch to stateless.
|
||||
_project.toggleState();
|
||||
await _flutter.hotReload();
|
||||
project.toggleState();
|
||||
await flutter.hotReload();
|
||||
|
||||
final String logs = stdout.toString();
|
||||
|
||||
|
|
|
@ -103,8 +103,8 @@ abstract class FlutterTestDriver {
|
|||
}
|
||||
_debugPrint('Spawning flutter $arguments in ${_projectFolder.path}');
|
||||
|
||||
const ProcessManager _processManager = LocalProcessManager();
|
||||
_process = await _processManager.start(
|
||||
const ProcessManager processManager = LocalProcessManager();
|
||||
_process = await processManager.start(
|
||||
<String>[flutterBin]
|
||||
.followedBy(arguments)
|
||||
.toList(),
|
||||
|
@ -760,8 +760,8 @@ class FlutterRunTestDriver extends FlutterTestDriver {
|
|||
}
|
||||
|
||||
class FlutterTestTestDriver extends FlutterTestDriver {
|
||||
FlutterTestTestDriver(Directory _projectFolder, {String? logPrefix})
|
||||
: super(_projectFolder, logPrefix: logPrefix);
|
||||
FlutterTestTestDriver(Directory projectFolder, {String? logPrefix})
|
||||
: super(projectFolder, logPrefix: logPrefix);
|
||||
|
||||
Future<void> test({
|
||||
String testFile = 'test/test.dart',
|
||||
|
|
|
@ -21,8 +21,8 @@ void main() {
|
|||
setUp(() async {
|
||||
tempDir = createResolvedTempDirectorySync('vmservice_integration_test.');
|
||||
|
||||
final BasicProject _project = BasicProject();
|
||||
await _project.setUpIn(tempDir);
|
||||
final BasicProject project = BasicProject();
|
||||
await project.setUpIn(tempDir);
|
||||
|
||||
flutter = FlutterRunTestDriver(tempDir);
|
||||
await flutter.run(withDebugger: true);
|
||||
|
|
|
@ -20,27 +20,27 @@ void main() {
|
|||
});
|
||||
|
||||
testWithoutContext('Web debugger can step over statements', () async {
|
||||
final WebSteppingProject _project = WebSteppingProject();
|
||||
await _project.setUpIn(tempDirectory);
|
||||
final WebSteppingProject project = WebSteppingProject();
|
||||
await project.setUpIn(tempDirectory);
|
||||
|
||||
flutter = FlutterRunTestDriver(tempDirectory);
|
||||
|
||||
await flutter.run(
|
||||
withDebugger: true, startPaused: true, chrome: true,
|
||||
additionalCommandArgs: <String>['--verbose', '--web-renderer=html']);
|
||||
await flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine);
|
||||
await flutter.addBreakpoint(project.breakpointUri, project.breakpointLine);
|
||||
await flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint.
|
||||
expect((await flutter.getSourceLocation()).line, equals(_project.breakpointLine));
|
||||
expect((await flutter.getSourceLocation()).line, equals(project.breakpointLine));
|
||||
|
||||
// Issue 5 steps, ensuring that we end up on the annotated lines each time.
|
||||
for (int i = 1; i <= _project.numberOfSteps; i += 1) {
|
||||
for (int i = 1; i <= project.numberOfSteps; i += 1) {
|
||||
await flutter.stepOverOrOverAsyncSuspension();
|
||||
final SourcePosition location = await flutter.getSourceLocation();
|
||||
final int actualLine = location.line;
|
||||
|
||||
// Get the line we're expected to stop at by searching for the comment
|
||||
// within the source code.
|
||||
final int expectedLine = _project.lineForStep(i);
|
||||
final int expectedLine = project.lineForStep(i);
|
||||
|
||||
expect(actualLine, equals(expectedLine),
|
||||
reason: 'After $i steps, debugger should stop at $expectedLine but stopped at $actualLine'
|
||||
|
|
|
@ -152,11 +152,11 @@ class PathUrlStrategy extends HashUrlStrategy {
|
|||
/// The [PlatformLocation] parameter is useful for testing to mock out browser
|
||||
/// interactions.
|
||||
PathUrlStrategy([
|
||||
PlatformLocation _platformLocation = const BrowserPlatformLocation(),
|
||||
PlatformLocation platformLocation = const BrowserPlatformLocation(),
|
||||
]) : _basePath = stripTrailingSlash(extractPathname(checkBaseHref(
|
||||
_platformLocation.getBaseHref(),
|
||||
platformLocation.getBaseHref(),
|
||||
))),
|
||||
super(_platformLocation);
|
||||
super(platformLocation);
|
||||
|
||||
final String _basePath;
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@ class PathUrlStrategy extends HashUrlStrategy {
|
|||
///
|
||||
/// The [PlatformLocation] parameter is useful for testing to mock out browser
|
||||
/// interations.
|
||||
PathUrlStrategy([PlatformLocation? _platformLocation])
|
||||
: super(_platformLocation);
|
||||
PathUrlStrategy([PlatformLocation? platformLocation])
|
||||
: super(platformLocation);
|
||||
|
||||
@override
|
||||
String getPath() => '';
|
||||
|
|
Loading…
Reference in a new issue