Skip to content

Commit 9c0604c

Browse files
committed
Migrate usage snippets
1 parent 0ec8ac0 commit 9c0604c

401 files changed

Lines changed: 823 additions & 277258 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs_snippets/lib/snippets/themes/icon/usage.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,4 @@ import 'package:forui_assets/forui_assets.dart';
77
const dogIconWidget = Icon(FIcons.dog);
88

99
// White cat icon with a size of 24x24.
10-
const catIconWidget = Icon(
11-
FIcons.cat,
12-
size: 24,
13-
color: Color(0xFFFFFFFF),
14-
);
10+
const catIconWidget = Icon(FIcons.cat, size: 24, color: Color(0xFFFFFFFF));

docs_snippets/lib/usages/foundation/collapsible.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import 'package:forui/forui.dart';
33

44
const collapsible = FCollapsible(
55
// {@category "Core"}
6-
key: Key('key'),
76
value: 0.5,
87
child: Placeholder(),
98
// {@endcategory}

docs_snippets/lib/usages/foundation/focused_outline.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
21
import 'package:flutter/widgets.dart';
32
import 'package:forui/forui.dart';
43

54
final focusedOutline = FFocusedOutline(
65
// {@category "Core"}
7-
key: const Key('key'),
86
style: (style) => style,
97
focused: true,
108
child: const Placeholder(),

docs_snippets/lib/usages/foundation/portal.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'package:forui/forui.dart';
55

66
final portal = FPortal(
77
// {@category "Core"}
8-
key: const Key('key'),
98
controller: null,
109
portalBuilder: (context, controller) => const Text('Portal content'),
1110
builder: (context, controller, child) => child!,

docs_snippets/lib/usages/foundation/tappable.dart

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,56 @@ import 'package:forui/forui.dart';
55

66
final tappable = FTappable(
77
// {@category "Core"}
8-
key: const Key('key'),
98
style: (style) => style,
109
focusedOutlineStyle: (style) => style,
1110
selected: false,
1211
behavior: .translucent,
1312
builder: (context, states, child) => child!,
1413
child: const Text('Tap me'),
1514
// {@endcategory}
16-
// {@category "Callbacks"}
17-
onPress: () {},
18-
onLongPress: () {},
19-
onSecondaryPress: () {},
20-
onSecondaryLongPress: () {},
21-
onFocusChange: (focused) {},
22-
onHoverChange: (hovered) {},
23-
onStateChange: (delta) {},
24-
// {@endcategory}
2515
// {@category "Accessibility"}
2616
autofocus: false,
2717
focusNode: null,
18+
onFocusChange: (focused) {},
2819
semanticsLabel: 'Tappable button',
2920
excludeSemantics: false,
3021
shortcuts: null,
3122
actions: null,
3223
// {@endcategory}
24+
// {@category "Callbacks"}
25+
onPress: () {},
26+
onLongPress: () {},
27+
onSecondaryPress: () {},
28+
onSecondaryLongPress: () {},
29+
onHoverChange: (hovered) {},
30+
onStateChange: (delta) {},
31+
// {@endcategory}
3332
);
3433

3534
final tappableStatic = FTappable.static(
3635
// {@category "Core"}
37-
key: const Key('key'),
3836
style: (style) => style,
3937
focusedOutlineStyle: (style) => style,
4038
selected: false,
4139
behavior: .translucent,
4240
builder: (context, states, child) => child!,
4341
child: const Text('Tap me'),
4442
// {@endcategory}
45-
// {@category "Callbacks"}
46-
onPress: () {},
47-
onLongPress: () {},
48-
onSecondaryPress: () {},
49-
onSecondaryLongPress: () {},
50-
onFocusChange: (focused) {},
51-
onHoverChange: (hovered) {},
52-
onStateChange: (delta) {},
53-
// {@endcategory}
5443
// {@category "Accessibility"}
5544
autofocus: false,
5645
focusNode: null,
46+
onFocusChange: (focused) {},
5747
semanticsLabel: 'Tappable button',
5848
excludeSemantics: false,
5949
shortcuts: null,
6050
actions: null,
6151
// {@endcategory}
52+
// {@category "Callbacks"}
53+
onPress: () {},
54+
onLongPress: () {},
55+
onSecondaryPress: () {},
56+
onSecondaryLongPress: () {},
57+
onHoverChange: (hovered) {},
58+
onStateChange: (delta) {},
59+
// {@endcategory}
6260
);

docs_snippets/lib/usages/widgets/accordion.dart

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
1-
// ignore_for_file: sort_child_properties_last
1+
// ignore_for_file: avoid_redundant_argument_values, sort_child_properties_last
22

33
import 'package:flutter/widgets.dart';
44
import 'package:forui/forui.dart';
55

66
final accordion = FAccordion(
77
// {@category "core"}
8-
key: const Key('key'),
9-
style: FThemes.zinc.light.accordionStyle,
8+
style: (style) => style,
109
children: const [FAccordionItem(title: Text('Title'), child: SizedBox())],
1110
// {@endcategory}
1211
// {@category "Control"}
1312
control: const .managed(min: 1, max: 2),
1413
// {@endcategory}
1514
);
1615

16+
final accordionItem = FAccordionItem(
17+
// {@category "Core"}
18+
style: null,
19+
title: const Text('Title'),
20+
icon: const Icon(FIcons.chevronDown),
21+
initiallyExpanded: false,
22+
child: const Text('Content'),
23+
// {@endcategory}
24+
// {@category "Accessibility"}
25+
autofocus: false,
26+
focusNode: null,
27+
onFocusChange: (focused) {},
28+
// {@endcategory}
29+
// {@category "Callbacks"}
30+
onHoverChange: (hovered) {},
31+
onStateChange: (delta) {},
32+
// {@endcategory}
33+
);
34+
1735
// {@category "Control" "`.lifted()`"}
1836
/// Externally controls the accordion items' expanded state.
1937
final FAccordionControl lifted = .lifted(expanded: (index) => true, onChange: (index, expanded) {});

docs_snippets/lib/usages/widgets/alert.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ final alert = FAlert(
88
style: FAlertStyle.primary(),
99
// {@endcategory}
1010
// {@category "Core"}
11-
key: const Key('key'),
1211
icon: const Icon(FIcons.circleAlert),
1312
title: const Text('Alert Title'),
1413
subtitle: const Text('Alert subtitle with more details'),
@@ -25,6 +24,4 @@ final destructive = FAlertStyle.destructive();
2524

2625
// {@category "Style" "Custom `FAlertStyle`"}
2726
/// A custom alert style.
28-
final FBaseAlertStyle Function(FAlertStyle) custom = (style) => style.copyWith(
29-
decoration: style.decoration.copyWith(color: const Color(0xFFFEF2F2)),
30-
);
27+
final FBaseAlertStyle Function(FAlertStyle) custom = (style) => style;

docs_snippets/lib/usages/widgets/autocomplete.dart

Lines changed: 54 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import 'package:forui/forui.dart';
55

66
final autocomplete = FAutocomplete(
77
// {@category "Core"}
8-
key: const Key('key'),
98
style: (style) => style,
109
enabled: true,
1110
hint: 'Hint',
@@ -17,25 +16,15 @@ final autocomplete = FAutocomplete(
1716
// {@category "Popover Control"}
1817
popoverControl: const .managed(),
1918
// {@endcategory}
20-
// {@category "Content"}
21-
autoHide: true,
22-
contentAnchor: AlignmentDirectional.topStart,
23-
fieldAnchor: AlignmentDirectional.bottomStart,
24-
contentConstraints: const FAutoWidthPortalConstraints(maxHeight: 300),
25-
contentSpacing: const .spacing(4),
26-
contentOverflow: .flip,
27-
contentOffset: .zero,
28-
contentHideRegion: .excludeChild,
29-
contentGroupId: null,
30-
contentOnTapHide: () {},
31-
contentScrollController: null,
32-
contentPhysics: const ClampingScrollPhysics(),
33-
contentDivider: .none,
34-
filter: (query) => ['Apple', 'Banana'].where((item) => item.toLowerCase().startsWith(query.toLowerCase())),
35-
contentBuilder: (context, query, values) => [for (final value in values) .item(value: value)],
36-
contentEmptyBuilder: FAutocomplete.defaultContentEmptyBuilder,
37-
contentLoadingBuilder: FAutocomplete.defaultContentLoadingBuilder,
38-
contentErrorBuilder: (context, error, stackTrace) => const Text('Error'),
19+
// {@category "Form"}
20+
label: const Text('Label'),
21+
description: const Text('Description'),
22+
errorBuilder: FFormFieldProperties.defaultErrorBuilder,
23+
forceErrorText: null,
24+
onSaved: (value) {},
25+
onReset: () {},
26+
validator: (value) => null,
27+
autovalidateMode: .disabled,
3928
// {@endcategory}
4029
// {@category "Field"}
4130
builder: (context, style, states, child) => child,
@@ -90,21 +79,30 @@ final autocomplete = FAutocomplete(
9079
clearable: (value) => false,
9180
rightArrowToComplete: false,
9281
// {@endcategory}
93-
// {@category "Form"}
94-
label: const Text('Label'),
95-
description: const Text('Description'),
96-
errorBuilder: FFormFieldProperties.defaultErrorBuilder,
97-
forceErrorText: null,
98-
onSaved: (value) {},
99-
onReset: () {},
100-
validator: (value) => null,
101-
autovalidateMode: .disabled,
82+
// {@category "Content"}
83+
autoHide: true,
84+
contentAnchor: AlignmentDirectional.topStart,
85+
fieldAnchor: AlignmentDirectional.bottomStart,
86+
contentConstraints: const FAutoWidthPortalConstraints(maxHeight: 300),
87+
contentSpacing: const .spacing(4),
88+
contentOverflow: .flip,
89+
contentOffset: .zero,
90+
contentHideRegion: .excludeChild,
91+
contentGroupId: null,
92+
contentOnTapHide: () {},
93+
contentScrollController: null,
94+
contentPhysics: const ClampingScrollPhysics(),
95+
contentDivider: .none,
96+
filter: (query) => ['Apple', 'Banana'].where((item) => item.toLowerCase().startsWith(query.toLowerCase())),
97+
contentBuilder: (context, query, values) => [for (final value in values) .item(value: value)],
98+
contentEmptyBuilder: FAutocomplete.defaultContentEmptyBuilder,
99+
contentLoadingBuilder: FAutocomplete.defaultContentLoadingBuilder,
100+
contentErrorBuilder: (context, error, stackTrace) => const Text('Error'),
102101
// {@endcategory}
103102
);
104103

105104
final builder = FAutocomplete.builder(
106105
// {@category "Core"}
107-
key: const Key('key'),
108106
style: (style) => style,
109107
enabled: true,
110108
filter: (query) => ['Apple', 'Banana'].where((item) => item.toLowerCase().startsWith(query.toLowerCase())),
@@ -116,23 +114,15 @@ final builder = FAutocomplete.builder(
116114
// {@category "Popover Control"}
117115
popoverControl: const .managed(),
118116
// {@endcategory}
119-
// {@category "Content"}
120-
contentEmptyBuilder: FAutocomplete.defaultContentEmptyBuilder,
121-
contentLoadingBuilder: FAutocomplete.defaultContentLoadingBuilder,
122-
contentErrorBuilder: (context, error, stackTrace) => const Text('Error'),
123-
contentAnchor: AlignmentDirectional.topStart,
124-
fieldAnchor: AlignmentDirectional.bottomStart,
125-
contentConstraints: const FAutoWidthPortalConstraints(maxHeight: 300),
126-
contentSpacing: const .spacing(4),
127-
contentOverflow: .flip,
128-
contentOffset: .zero,
129-
contentHideRegion: .excludeChild,
130-
contentGroupId: null,
131-
contentOnTapHide: () {},
132-
autoHide: true,
133-
contentScrollController: null,
134-
contentPhysics: const ClampingScrollPhysics(),
135-
contentDivider: .none,
117+
// {@category "Form"}
118+
label: const Text('Label'),
119+
description: const Text('Description'),
120+
errorBuilder: FFormFieldProperties.defaultErrorBuilder,
121+
forceErrorText: null,
122+
onSaved: (value) {},
123+
onReset: () {},
124+
validator: (value) => null,
125+
autovalidateMode: .disabled,
136126
// {@endcategory}
137127
// {@category "Field"}
138128
hint: 'Hint',
@@ -188,15 +178,23 @@ final builder = FAutocomplete.builder(
188178
clearable: (value) => false,
189179
rightArrowToComplete: false,
190180
// {@endcategory}
191-
// {@category "Form"}
192-
label: const Text('Label'),
193-
description: const Text('Description'),
194-
errorBuilder: FFormFieldProperties.defaultErrorBuilder,
195-
forceErrorText: null,
196-
onSaved: (value) {},
197-
onReset: () {},
198-
validator: (value) => null,
199-
autovalidateMode: .disabled,
181+
// {@category "Content"}
182+
autoHide: true,
183+
contentEmptyBuilder: FAutocomplete.defaultContentEmptyBuilder,
184+
contentLoadingBuilder: FAutocomplete.defaultContentLoadingBuilder,
185+
contentErrorBuilder: (context, error, stackTrace) => const Text('Error'),
186+
contentAnchor: AlignmentDirectional.topStart,
187+
fieldAnchor: AlignmentDirectional.bottomStart,
188+
contentConstraints: const FAutoWidthPortalConstraints(maxHeight: 300),
189+
contentSpacing: const .spacing(4),
190+
contentOverflow: .flip,
191+
contentOffset: .zero,
192+
contentHideRegion: .excludeChild,
193+
contentGroupId: null,
194+
contentOnTapHide: () {},
195+
contentScrollController: null,
196+
contentPhysics: const ClampingScrollPhysics(),
197+
contentDivider: .none,
200198
// {@endcategory}
201199
);
202200

docs_snippets/lib/usages/widgets/avatar.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,18 @@ import 'package:forui/forui.dart';
55

66
final avatar = FAvatar(
77
// {@category "Core"}
8-
key: const Key('key'),
98
style: (style) => style,
109
size: 40.0,
1110
image: const NetworkImage('https://example.com/avatar.png'),
1211
// {@endcategory}
1312
// {@category "Others"}
14-
semanticsLabel: 'User avatar',
1513
fallback: const Text('AB'),
14+
semanticsLabel: 'User avatar',
1615
// {@endcategory}
1716
);
1817

1918
final raw = FAvatar.raw(
2019
// {@category "Core"}
21-
key: const Key('key'),
2220
style: (style) => style,
2321
size: 40.0,
2422
child: const Text('AB'),

docs_snippets/lib/usages/widgets/badge.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ final badge = FBadge(
88
style: FBadgeStyle.primary(),
99
// {@endcategory}
1010
// {@category "Core"}
11-
key: const Key('key'),
1211
child: const Text('Badge'),
1312
// {@endcategory}
1413
);
@@ -18,7 +17,6 @@ final raw = FBadge.raw(
1817
style: FBadgeStyle.primary(),
1918
// {@endcategory}
2019
// {@category "Core"}
21-
key: const Key('key'),
2220
builder: (context, style) => const Text('Badge'),
2321
// {@endcategory}
2422
);
@@ -41,6 +39,4 @@ final destructive = FBadgeStyle.destructive();
4139

4240
// {@category "Style" "Custom `FBadgeStyle`"}
4341
/// A custom badge style.
44-
final FBaseBadgeStyle Function(FBadgeStyle) custom = (style) => style.copyWith(
45-
decoration: style.decoration.copyWith(color: const Color(0xFF6366F1)),
46-
);
42+
final FBaseBadgeStyle Function(FBadgeStyle) custom = (style) => style;

0 commit comments

Comments
 (0)