Foundation

Portal

A portal renders a portal widget that "floats" on top of a child widget.

This widget is typically used to create other high-level widgets, e.g., popover or tooltip. You should prefer those high-level widgets unless you're creating a custom widget.

1@override
2Widget build(BuildContext _) => FPortal(
3 spacing: const .spacing(8),
4 viewInsets: const .all(5),
5 portalBuilder: (context, _) => Container(
6 decoration: BoxDecoration(
7 color: context.theme.colors.background,
8 border: .all(color: context.theme.colors.border),
9 borderRadius: .circular(4),
10 ),
11 padding: const .only(left: 20, top: 14, right: 20, bottom: 10),
12 child: SizedBox(
13 width: 288,
14 child: Column(
15 mainAxisSize: .min,
16 crossAxisAlignment: .start,
17 children: [
18 Text('Dimensions', style: context.theme.typography.base),
19 const SizedBox(height: 7),
20 Text(
21 'Set the dimensions for the layer.',
22 style: context.theme.typography.sm.copyWith(
23 color: context.theme.colors.mutedForeground,
24 fontWeight: FontWeight.w300,
25 ),
26 ),
27 const SizedBox(height: 15),
28 for (final (label, value) in [
29 ('Width', '100%'),
30 ('Max. Width', '300px'),
31 ]) ...[
32 Row(
33 children: [
34 Expanded(
35 child: Text(label, style: context.theme.typography.sm),
36 ),
37 Expanded(
38 flex: 2,
39 child: FTextField(
40 control: .managed(initial: TextEditingValue(text: value)),
41 ),
42 ),
43 ],
44 ),
45 const SizedBox(height: 7),
46 ],
47 ],
48 ),
49 ),
50 ),
51 builder: (context, controller, _) =>
52 FButton(onPress: controller.toggle, child: const Text('Portal')),
53);
54

Usage

FPortal(...)

1FPortal(
2 controller: null,
3 portalBuilder: (context, controller) => const Text('Portal content'),
4 builder: (context, controller, child) => child!,
5 child: const Text('Child'),
6 barrier: null,
7)

Visualization

On this page