Split Rent Button
Display a pre-built Flutter widget that automatically opens the Flex Checkout modal when tapped.
Initialization
Import and render FlexSplitRentButton in your widget tree.
import 'package:flex_checkout_flutter/flex_checkout_flutter.dart';
import 'package:flutter/material.dart' hide Flex;
class PaymentScreen extends StatelessWidget {
const PaymentScreen({super.key});
Widget build(BuildContext context) {
return const Center(
child: FlexSplitRentButton(),
);
}
}
When tapped, the Split Rent Button automatically opens checkout. Make sure you have registered a token provider with sdk.loadToken and configured checkout callbacks with sdk.checkout before rendering the button.
final sdk = await Flex.initialize(
const FlexConfig(clientId: 'your-flex-client-id'),
);
sdk.loadToken(() async {
final response = await yourApi.getFlexToken();
return response.token;
});
sdk.checkout(CheckoutConfig(
onEvent: (event) {},
));
Options
| Parameter | Type | Description |
|---|---|---|
styles | ButtonStyles? | Optional height override for the button. |
variant | SplitRentButtonVariant? | Button display style. .defaultVariant (default) renders the standard split rent button. .listItem renders a white card-style split rent button with a chevron. .logo renders a circular icon button with the Flex logo and a label below. |
radius | SplitRentButtonRadius? | Button border radius style. .rounded (default), .square, or .pill. Ignored when variant is .listItem. Defaults to .pill when variant is .logo. |
color | SplitRentButtonColor? | Button color. .purple (default) or .white. Ignored when variant is .listItem. |
visible | bool | Whether the button is visible. Defaults to true. When false, the widget reserves the same space but the native view is hidden — useful for conditional rendering. |
Variant
The variant option controls the visual style of the button. If variant is not specified, the button renders as .defaultVariant.
defaultVariant
The standard split rent button.
// variant defaults to .defaultVariant if not specified
const FlexSplitRentButton();
listItem
A white card-style split rent button with a chevron. Intended for placement inside a list or menu where the host UI already supplies the surrounding chrome.
const FlexSplitRentButton(variant: SplitRentButtonVariant.listItem);
logo
A circular icon button with the Flex logo centered inside and a label below. Defaults to 54 logical pixel diameter.
const FlexSplitRentButton(variant: SplitRentButtonVariant.logo);
Radius
The radius option controls the button border radius. If radius is not specified, the button renders as .rounded.
square
A flat-cornered split rent button.
const FlexSplitRentButton(radius: SplitRentButtonRadius.square);
rounded
A rounded-corner split rent button (default).
// radius defaults to .rounded if not specified
const FlexSplitRentButton();
pill
A pill-shaped split rent button.
const FlexSplitRentButton(radius: SplitRentButtonRadius.pill);
Color
The color option controls the button color. If color is not specified, the button renders as .purple.
purple
The default purple split rent button.
// color defaults to .purple if not specified
const FlexSplitRentButton();
white
A white split rent button with a purple border.
const FlexSplitRentButton(color: SplitRentButtonColor.white);
The color option is ignored when variant is .listItem.
ButtonStyles
| Parameter | Type | Description |
|---|---|---|
height | double? | Height of the button in logical pixels. Defaults to system size. |
const FlexSplitRentButton(
styles: ButtonStyles(height: 48),
);
Multiple Buttons
You can add multiple Split Rent Buttons to the same screen:
Column(
children: const [
FlexSplitRentButton(),
FlexSplitRentButton(),
],
);
Next Steps
- Configure Checkout callbacks to handle events and errors
- Review the Installation guide for lifecycle management