Motion
The kit animates presses, status changes and step transitions. Durations stay under 300 ms, with faster exits than entrances. Loading skeletons and displayed amounts stay still.
Tokens
Section titled “Tokens”PaymentMotion.of(context) returns the tokens for the current context. Every duration is Duration.zero, and the press scale is 1, when the platform or host asks for reduced motion (see Reduced motion).
| Token | Value | Use | Don't |
|---|---|---|---|
press | 100 ms | Press feedback and colors. | Use only for this role. |
quick | 150 ms | Selection and borders. | Use only for this role. |
enter | 220 ms | Status/content entering. | Use only for this role. |
exit | 150 ms | Matching exit. | Never slower than entry. |
sheetEnter | 280 ms | Sheet opening. | Use only for this role. |
sheetExit | 200 ms | Sheet closing. | Use only for this role. |
pressedScale | 0.96 | Compact controls held. | Never full-width buttons or rows. |
easeOut | Cubic(0.23, 1, 0.32, 1) | Entering or response. | Use only for this role. |
easeInOut | Cubic(0.77, 0, 0.175, 1) | On-screen size or position. | Use only for this role. |
drawer | Cubic(0.32, 0.72, 0, 1) | Sheets. | Use only for this role. |
Curves are static: PaymentMotion.easeOut (strong ease-out, Cubic(0.23, 1, 0.32, 1)), easeInOut for elements already on screen, and drawer (Cubic(0.32, 0.72, 0, 1)) for sheets.
final motion = PaymentMotion.of(context);
AnimatedSwitcher( duration: motion.enter, reverseDuration: motion.exit, transitionBuilder: PaymentMotion.fadeScale, child: Icon(icon, key: ValueKey(icon)),);Swap builders
Section titled “Swap builders”| Builder | Motion | Use for | Don’t |
|---|---|---|---|
PaymentMotion.fadeScale |
Fade plus a scale from 0.95 | Compact element swaps: an icon, a glyph, a badge, a task status mark | Full-width bands or rows; animate from nothing |
PaymentMotion.fadeRise |
Fade plus a fixed 8 dp rise, the same on every screen. back: true fades only, with no rise |
Forward content and step changes, such as onboarding’s loading, tasks and done; the back mode when the flow moves back | Animate from nothing |
motion.fullWidthSwap(child) |
Fade only, at enter in and exit out, with the height eased by AnimatedSize (enter, easeInOut) |
Full-width status content; a skeleton handing off to its content; a slot that appears or collapses | Scale; a search or filter result in content that is already showing |
PaymentMotion.topLayout |
No motion: the layout for a swap | Any AnimatedSwitcher: the leaving child keeps painting but takes no taps or keyboard focus and is hidden from screen readers; a leaving control loses focus |
Let a leaving “Pay” button be pressed |
fadeRise fits AnimatedSwitcher.transitionBuilder as it is. Flipping the direction mid-swap keeps the leaving child’s state. For the back mode, pass a closure, so going back never looks like going forward:
AnimatedSwitcher( duration: motion.enter, reverseDuration: motion.exit, transitionBuilder: (child, animation) => PaymentMotion.fadeRise(child, animation, back: goingBack), layoutBuilder: PaymentMotion.topLayout, child: KeyedSubtree(key: ValueKey(step), child: stepBody),);Full-width content fades and never scales: scaling a full-width slab moves its edges and reads as a lurch, the same reason full-width buttons don’t scale on press. The eased height keeps the content below from jumping when the new content is taller or shorter. Give each state its own key:
PaymentMotion.of(context).fullWidthSwap( KeyedSubtree(key: ValueKey(status), child: statusContent),)With the durations from PaymentMotion.of, every swap is instant under reduced motion; fullWidthSwap reads them itself. The payment and verification status views swap their status this way.
Content handoffs
Section titled “Content handoffs”Content that arrives or leaves moves only on a state change after the widget is built, never on its first build:
PaymentOnboardingViewbrings in loading, each task’s content and the done message withfadeRise, and the done mark settles in withfadeScale. Itserrorbanner fades in and out, and the step below glides.PaymentSignInViewandDocumentUploadTileuse a full-width fade and ease the height as a banner appears or clears. Screen readers can reach the current error from the first frame. A leaving banner drops out of focus, taps and screen-reader traversal immediately. Continue, Try again, Retake and Open settings stay usable when present.TransactionHistory,PaymentOverviewPage,PaymentDetailPagePropertyListandPromoSlothand their skeleton over to content withfullWidthSwap. Only the loading → ready step moves: a search, a filter or new data in content that is already showing changes at once, height included.PromoSlotfades between all its states, and a dismissed offer collapses withcollapseWhenEmptywhile the content below glides up.PaymentTaskListturns a task’s status mark withfadeScaleoverquick.AuthorizationPromptswaps its phase status with the shared full-width fade and eased height, keyed on the phase. The host header, amount and action rules sit outside the swap and update at once.ChartModuleswaps its plot at once: the plot keeps a fixed height, so nothing below moves.
The kit can only animate slots it owns. When your screen adds or removes a banner itself, wrap that slot in fullWidthSwap with a key per state, such as const SizedBox.shrink(key: ValueKey('none')) when it’s empty.
Reduced motion
Section titled “Reduced motion”The kit reads both places reduced motion can come from:
MediaQueryData.disableAnimations: a host or in-app override, or Android’s “Remove animations”.PlatformDispatcher.accessibilityFeatures.reduceMotion: iOS Settings → Accessibility → Motion → Reduce Motion. iOS delivers it only here, andMediaQueryDatadoesn’t carry it.
Under either flag every kit duration is 0 and the press scale is 1. There is no cross-fade variant. An upload whose progress the host doesn’t report shows the still busy glyph beside “Uploading” instead of a bar. A host can force reduced motion on, but can’t turn the OS setting off. A widget reads the flags when it builds, so a setting changed while the app runs applies from the widget’s next change.
SDK widgets inside the kit that read MediaQuery don’t see the iOS flag. A host that wants them to follow too can fold it into MediaQuery in MaterialApp.builder:
MaterialApp( builder: (context, child) { final features = View.of(context).platformDispatcher.accessibilityFeatures; return MediaQuery( data: MediaQuery.of(context).copyWith( disableAnimations: MediaQuery.disableAnimationsOf(context) || features.reduceMotion, ), child: child!, ); }, home: home,)Sheets, wide confirm dialogs and toasts follow the kit tokens and reduced motion. Some embedded SDK animations keep their platform behavior: checkbox and switch transitions, ink effects, pressed-highlight fade, floating input labels, slider thumbs and the phone drawer panel. Android’s “Remove animations” compresses those transitions. On iOS, use the MediaQuery adaptation above to pass the platform setting to SDK widgets that read it.
Rules the kit follows
Section titled “Rules the kit follows”- Compact swaps fade and scale in from 0.95, never from nothing. Full-width content fades only, and its height eases.
- Flow steps fade and rise a fixed 8 dp going forward, and fade only going back.
- Compact controls press to 0.96 over 100 ms. Full-width buttons do not scale: scaling a wide slab moves its edges several pixels and reads as a lurch, so they rely on Material’s pressed state.
- Navigation selection, drawer items, menus and anything keyboard-driven are instant. They are used constantly, and animation would only add delay. The drawer rule covers items and selection. The phone Drawer panel keeps its platform slide and edge-swipe gesture.
- The shared radio mark (
PaymentRadio,PaymentMethodPicker) eases its selected ring overquickoneaseOut, retargeting mid-flight; keyboard-driven selection and reduced motion stay instant. - Sheets take 280 ms in and 200 ms out on the drawer curve. Disclosures take 220 ms to open and 150 ms to close from rest.
- Reversing a running accordion reveal carries its current speed into a spring with no bounce. Height and opacity turn together. With reduced motion the accordion stops immediately at the new state.
- Implicit animations retarget when interrupted.
- Amounts, balances, countdowns and totals change in place with tabular digits. They never count or roll, so a payment amount never shows an intermediate wrong value. The only allowed motion is the action-bar total’s
quickcross-fade after a re-quote. - There is no spring token. Sheets keep the curve tokens; the SDK bottom sheet already carries the release velocity into its fling, and its dismiss and settle can be interrupted.
LoadingSkeletonis static: a shimmer repaints every frame and adds no information.PaymentSpinner, and the busy state ofPaymentButton, become a still hourglass under reduced motion.- Video never autoplays unless
autoPlay: true, and never under reduced motion or when iOS Auto-Play Video Previews is off (accessibilityFeatures.autoPlayVideos).
PaymentMotion
class PaymentMotion · lib/src/foundation/payment_motion.dart
Motion tokens shared by the kit.
Motion here is feedback only: a press was heard, a status changed, a step moved forward. Durations stay under 300 ms, exits are faster than enters, and everything collapses to Duration.zero when the platform or host asks for reduced motion.
PaymentMotion.of(…) — Reads reduced motion from both places it can come from: MediaQueryData.disableAnimations (a host override, or Android's "Remove animations") and AccessibilityFeatures.reduceMotion, the only flag iOS sets for Reduce Motion. MediaQueryData doesn't carry the second one, so a widget sees an OS change on its next rebuild.
| Parameter | Type | Default | Description |
|---|---|---|---|
contextrequiredpositional | BuildContext | — | — |
See also
Section titled “See also”- Focus and press for the 0.96 press scale.
- Spinner and Loading skeleton for waiting states.
- Accessibility for reduced motion.
Choose feedback
Section titled “Choose feedback”| The change is… | Motion |
|---|---|
| A press | press |
| A selection or border change | quick |
| A compact swap | enter + exit, fadeScale |
| A full-width content swap | fullWidthSwap |
| Loading handing off to content, or a slot appearing or collapsing | fullWidthSwap |
| A task’s status mark | quick, fadeScale |
| A flow step | fadeRise; back: true when going back |
| A sheet | sheetEnter + sheetExit, drawer curve |
| Any of these with reduced motion (either flag) | Zero duration, scale 1 |
Use the semantic motion tokens with the AnimatedSwitcher enter/exit pair above. Avoid raw durations and animated countdown ticks. The tokens also apply the kit’s reduced-motion behavior.