Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6adb3c7

Browse files
committed
docs: Update docs for momentary flag
1 parent b00fbf6 commit 6adb3c7

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

packages/flutter/lib/src/cupertino/sliding_segmented_control.dart

+7-4
Original file line numberDiff line numberDiff line change
@@ -491,15 +491,18 @@ class CupertinoSlidingSegmentedControl<T extends Object> extends StatefulWidget
491491
/// Defaults to `EdgeInsets.symmetric(vertical: 2, horizontal: 3)`.
492492
final EdgeInsetsGeometry padding;
493493

494-
/// Determines whether segments in the segmented control show selected state.
494+
/// Determines whether segments provide only momentary feedback when pressed
495+
/// rather than maintaining a persistent selected state.
495496
///
496-
/// If true, segments in the control don’t show selected state and
497-
/// don’t update the value of selectedSegmentIndex after tracking ends.
497+
/// When true, segments behave more like buttons that trigger actions rather
498+
/// than options that can be selected and remain in that state.
498499
///
499500
/// Defaults to false.
500501
///
501502
/// {@tool dartpad}
502-
/// This example shows a [CupertinoSlidingSegmentedControl] with [isMomentary] set to true.
503+
/// This example shows a [CupertinoSlidingSegmentedControl] with [isMomentary] set
504+
/// to true, providing feedback to the user when the segment is selected with a
505+
/// text scaling effect.
503506
///
504507
/// ** See code in examples/api/lib/cupertino/segmented_control/cupertino_sliding_segmented_control.1.dart **
505508
/// {@end-tool}

packages/flutter/test/cupertino/sliding_segmented_control_test.dart

+10-3
Original file line numberDiff line numberDiff line change
@@ -2173,13 +2173,20 @@ void main() {
21732173
);
21742174

21752175
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.text('A')));
2176-
await gesture.moveBy(const Offset(10, 0));
2177-
await tester.pumpAndSettle(const Duration(milliseconds: 206));
21782176
final Finder scaleTransition = find.ancestor(
21792177
of: find.text('A'),
21802178
matching: find.byType(ScaleTransition),
21812179
);
2182-
final double scale = tester.widget<ScaleTransition>(scaleTransition).scale.value;
2180+
2181+
await tester.pumpAndSettle(const Duration(milliseconds: 206));
2182+
double scale = tester.widget<ScaleTransition>(scaleTransition).scale.value;
21832183
expect(scale, greaterThan(1.0));
2184+
2185+
await gesture.up();
2186+
2187+
await tester.pumpAndSettle();
2188+
scale = tester.widget<ScaleTransition>(scaleTransition).scale.value;
2189+
// Spring animations approach but don't exactly reach normal scale.
2190+
expect(scale, moreOrLessEquals(1.0, epsilon: 0.01));
21842191
});
21852192
}

0 commit comments

Comments
 (0)