Skip to content

Commit b43ab31

Browse files
committed
Fix Dart formatting and display example analysis
1 parent a44bfc2 commit b43ab31

32 files changed

Lines changed: 961 additions & 394 deletions

‎examples/cocoapods_example/lib/main.dart‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ class _NativeApiSmokeTestPageState extends State<NativeApiSmokeTestPage> {
6565
}),
6666
_check('WindowManager current window', () {
6767
final current = WindowManager.instance.getCurrent();
68-
return current == null ? 'no active native window' : (current.title ?? '');
68+
return current == null
69+
? 'no active native window'
70+
: (current.title ?? '');
6971
}),
7072
_check('Preferences read/write', () {
7173
final prefs = Preferences.createWithScope('cocoapods_example')!;

‎examples/display_example/lib/main.dart‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,9 @@ class DisplayCanvas extends StatelessWidget {
610610
SizedBox(width: (4 * scale).clamp(2.0, 4.0)),
611611
Expanded(
612612
child: Text(
613-
(window.title?.isNotEmpty ?? false) ? window.title! : 'Window',
613+
(window.title?.isNotEmpty ?? false)
614+
? window.title!
615+
: 'Window',
614616
style: TextStyle(
615617
fontSize: (10 * scale).clamp(6.0, 10.0),
616618
color: Colors.orange[900],
@@ -798,7 +800,7 @@ class DisplayDetails extends StatelessWidget {
798800
List<Widget> _buildDetailSections() {
799801
return [
800802
_buildSection('Basic Information', [
801-
_DetailItem(Icons.badge, 'ID', display.id ?? ''),
803+
_DetailItem(Icons.badge, 'ID', display.id.toString()),
802804
_DetailItem(Icons.label, 'Name', display.name ?? ''),
803805
_DetailItem(Icons.star, 'Primary', display.isPrimary ? 'Yes' : 'No'),
804806
]),

‎examples/menu_example/lib/main.dart‎

Lines changed: 95 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
158158
});
159159

160160
// 1. Normal menu item
161-
final normalItem = MenuItem.createWithLabelAndType('Normal Menu Item', MenuItemType.normal)!;
161+
final normalItem = MenuItem.createWithLabelAndType(
162+
'Normal Menu Item',
163+
MenuItemType.normal,
164+
)!;
162165
normalItem.addListener((event) {
163166
if (event is! MenuItemClickedEvent) return;
164167
_addToHistory('Normal item clicked (ID: ${event.itemId})');
@@ -170,7 +173,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
170173
_contextMenu.addSeparator();
171174

172175
// 3. Checkbox menu item
173-
_checkboxItem = MenuItem.createWithLabelAndType('Checkbox Item', MenuItemType.checkbox)!;
176+
_checkboxItem = MenuItem.createWithLabelAndType(
177+
'Checkbox Item',
178+
MenuItemType.checkbox,
179+
)!;
174180
_checkboxItem.state = MenuItemState.unchecked;
175181
_checkboxItem.addListener((event) {
176182
if (event is! MenuItemClickedEvent) return;
@@ -188,7 +194,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
188194
_menuItems.add(_checkboxItem);
189195

190196
// 4. Radio menu items (grouped together)
191-
_radio1 = MenuItem.createWithLabelAndType('Radio Option 1', MenuItemType.radio)!;
197+
_radio1 = MenuItem.createWithLabelAndType(
198+
'Radio Option 1',
199+
MenuItemType.radio,
200+
)!;
192201
_radio1.radioGroup = 1; // Set radio group ID
193202
_radio1.state = MenuItemState.checked; // Default selection
194203
_radio1.addListener((event) {
@@ -204,7 +213,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
204213
_contextMenu.addItem(_radio1);
205214
_menuItems.add(_radio1);
206215

207-
_radio2 = MenuItem.createWithLabelAndType('Radio Option 2', MenuItemType.radio)!;
216+
_radio2 = MenuItem.createWithLabelAndType(
217+
'Radio Option 2',
218+
MenuItemType.radio,
219+
)!;
208220
_radio2.radioGroup = 1; // Same radio group
209221
_radio2.state = MenuItemState.unchecked;
210222
_radio2.addListener((event) {
@@ -220,7 +232,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
220232
_contextMenu.addItem(_radio2);
221233
_menuItems.add(_radio2);
222234

223-
_radio3 = MenuItem.createWithLabelAndType('Radio Option 3', MenuItemType.radio)!;
235+
_radio3 = MenuItem.createWithLabelAndType(
236+
'Radio Option 3',
237+
MenuItemType.radio,
238+
)!;
224239
_radio3.radioGroup = 1; // Same radio group
225240
_radio3.state = MenuItemState.unchecked;
226241
_radio3.addListener((event) {
@@ -237,7 +252,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
237252
_menuItems.add(_radio3);
238253

239254
// 5. Disabled menu items
240-
_disabledItem = MenuItem.createWithLabelAndType('Disabled Item', MenuItemType.normal)!;
255+
_disabledItem = MenuItem.createWithLabelAndType(
256+
'Disabled Item',
257+
MenuItemType.normal,
258+
)!;
241259
_disabledItem.isEnabled = false;
242260
_disabledItem.addListener((event) {
243261
if (event is! MenuItemClickedEvent) return;
@@ -246,7 +264,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
246264
_contextMenu.addItem(_disabledItem);
247265
_menuItems.add(_disabledItem);
248266

249-
_disabledCheckbox = MenuItem.createWithLabelAndType('Disabled Checkbox', MenuItemType.checkbox)!;
267+
_disabledCheckbox = MenuItem.createWithLabelAndType(
268+
'Disabled Checkbox',
269+
MenuItemType.checkbox,
270+
)!;
250271
_disabledCheckbox.state = MenuItemState.checked;
251272
_disabledCheckbox.isEnabled = false;
252273
_disabledCheckbox.addListener((event) {
@@ -260,8 +281,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
260281
_contextMenu.addSeparator();
261282

262283
// 8. Menu item with dynamic label
263-
final dynamicLabelItem =
264-
MenuItem.createWithLabelAndType(_currentLabel, MenuItemType.normal)!;
284+
final dynamicLabelItem = MenuItem.createWithLabelAndType(
285+
_currentLabel,
286+
MenuItemType.normal,
287+
)!;
265288
dynamicLabelItem.addListener((event) {
266289
if (event is! MenuItemClickedEvent) return;
267290
_addToHistory('Dynamic label item clicked (ID: ${event.itemId})');
@@ -270,7 +293,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
270293
_menuItems.add(dynamicLabelItem);
271294

272295
// 9. Menu item with tooltip
273-
final tooltipItem = MenuItem.createWithLabelAndType('Item with Tooltip', MenuItemType.normal)!;
296+
final tooltipItem = MenuItem.createWithLabelAndType(
297+
'Item with Tooltip',
298+
MenuItemType.normal,
299+
)!;
274300
tooltipItem.tooltip = 'This is a helpful tooltip message';
275301
tooltipItem.addListener((event) {
276302
if (event is! MenuItemClickedEvent) return;
@@ -284,7 +310,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
284310

285311
// 11. Submenu
286312
_submenu = Menu.create()!;
287-
_submenuItem = MenuItem.createWithLabelAndType('Submenu', MenuItemType.submenu)!;
313+
_submenuItem = MenuItem.createWithLabelAndType(
314+
'Submenu',
315+
MenuItemType.submenu,
316+
)!;
288317

289318
_submenuItem.addListener((event) {
290319
if (event is! MenuItemSubmenuOpenedEvent) return;
@@ -296,14 +325,20 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
296325
});
297326

298327
// Add items to submenu
299-
final subItem1 = MenuItem.createWithLabelAndType('Submenu Item 1', MenuItemType.normal)!;
328+
final subItem1 = MenuItem.createWithLabelAndType(
329+
'Submenu Item 1',
330+
MenuItemType.normal,
331+
)!;
300332
subItem1.addListener((event) {
301333
if (event is! MenuItemClickedEvent) return;
302334
_addToHistory('Submenu Item 1 clicked (ID: ${event.itemId})');
303335
});
304336
_submenu.addItem(subItem1);
305337

306-
final subItem2 = MenuItem.createWithLabelAndType('Submenu Item 2', MenuItemType.normal)!;
338+
final subItem2 = MenuItem.createWithLabelAndType(
339+
'Submenu Item 2',
340+
MenuItemType.normal,
341+
)!;
307342
subItem2.addListener((event) {
308343
if (event is! MenuItemClickedEvent) return;
309344
_addToHistory('Submenu Item 2 clicked (ID: ${event.itemId})');
@@ -312,7 +347,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
312347

313348
_submenu.addSeparator();
314349

315-
final subItem3 = MenuItem.createWithLabelAndType('Submenu Item 3', MenuItemType.normal)!;
350+
final subItem3 = MenuItem.createWithLabelAndType(
351+
'Submenu Item 3',
352+
MenuItemType.normal,
353+
)!;
316354
subItem3.addListener((event) {
317355
if (event is! MenuItemClickedEvent) return;
318356
_addToHistory('Submenu Item 3 clicked (ID: ${event.itemId})');
@@ -329,7 +367,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
329367
_contextMenu.addSeparator();
330368

331369
// 13. Menu items with special characters
332-
final specialCharsItem = MenuItem.createWithLabelAndType('Special: 中文 日本語 🎉 @#\$%', MenuItemType.normal)!;
370+
final specialCharsItem = MenuItem.createWithLabelAndType(
371+
'Special: 中文 日本語 🎉 @#\$%',
372+
MenuItemType.normal,
373+
)!;
333374
specialCharsItem.addListener((event) {
334375
if (event is! MenuItemClickedEvent) return;
335376
_addToHistory('Special chars item clicked (ID: ${event.itemId})');
@@ -352,14 +393,20 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
352393
_addToHistory('Positioning menu closed');
353394
});
354395

355-
final item1 = MenuItem.createWithLabelAndType('Positioning Menu Item 1', MenuItemType.normal)!;
396+
final item1 = MenuItem.createWithLabelAndType(
397+
'Positioning Menu Item 1',
398+
MenuItemType.normal,
399+
)!;
356400
item1.addListener((event) {
357401
if (event is! MenuItemClickedEvent) return;
358402
_addToHistory('Positioning menu item 1 clicked');
359403
});
360404
_positioningMenu.addItem(item1);
361405

362-
final item2 = MenuItem.createWithLabelAndType('Positioning Menu Item 2', MenuItemType.normal)!;
406+
final item2 = MenuItem.createWithLabelAndType(
407+
'Positioning Menu Item 2',
408+
MenuItemType.normal,
409+
)!;
363410
item2.addListener((event) {
364411
if (event is! MenuItemClickedEvent) return;
365412
_addToHistory('Positioning menu item 2 clicked');
@@ -435,7 +482,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
435482
}
436483

437484
void _addNewMenuItem() {
438-
final newItem = MenuItem.createWithLabelAndType('New Item ${_menuItems.length + 1}', MenuItemType.normal)!;
485+
final newItem = MenuItem.createWithLabelAndType(
486+
'New Item ${_menuItems.length + 1}',
487+
MenuItemType.normal,
488+
)!;
439489
newItem.addListener((event) {
440490
if (event is! MenuItemClickedEvent) return;
441491
_addToHistory('New item ${_menuItems.length} clicked');
@@ -447,7 +497,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
447497
}
448498

449499
void _insertMenuItemAtPosition() {
450-
final insertItem = MenuItem.createWithLabelAndType('Inserted Item', MenuItemType.normal)!;
500+
final insertItem = MenuItem.createWithLabelAndType(
501+
'Inserted Item',
502+
MenuItemType.normal,
503+
)!;
451504
insertItem.addListener((event) {
452505
if (event is! MenuItemClickedEvent) return;
453506
_addToHistory('Inserted item clicked');
@@ -662,12 +715,18 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
662715
}
663716

664717
void _showMenuAtAbsolutePosition(Offset position) {
665-
_positioningMenu.open(PositioningStrategy.absolute(position)!, Placement.bottomStart);
718+
_positioningMenu.open(
719+
PositioningStrategy.absolute(position)!,
720+
Placement.bottomStart,
721+
);
666722
_addToHistory('Opened menu at absolute position: $position');
667723
}
668724

669725
void _showMenuAtCursorPosition() {
670-
_positioningMenu.open(PositioningStrategy.cursorPosition()!, Placement.bottomStart);
726+
_positioningMenu.open(
727+
PositioningStrategy.cursorPosition()!,
728+
Placement.bottomStart,
729+
);
671730
_addToHistory('Opened menu at cursor position');
672731
}
673732

@@ -679,7 +738,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
679738
menu.setBackend(_contextMenu.backend);
680739

681740
// Checkable item with Checked state
682-
final checkableItem = MenuItem.createWithLabelAndType('Checkable', MenuItemType.checkbox)!;
741+
final checkableItem = MenuItem.createWithLabelAndType(
742+
'Checkable',
743+
MenuItemType.checkbox,
744+
)!;
683745
checkableItem.state = MenuItemState.checked;
684746
checkableItem.addListener((event) {
685747
if (event is! MenuItemClickedEvent) return;
@@ -688,7 +750,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
688750
menu.addItem(checkableItem);
689751

690752
// Disabled item
691-
final disabledItem = MenuItem.createWithLabelAndType('Disabled', MenuItemType.normal)!;
753+
final disabledItem = MenuItem.createWithLabelAndType(
754+
'Disabled',
755+
MenuItemType.normal,
756+
)!;
692757
disabledItem.isEnabled = false;
693758
disabledItem.addListener((event) {
694759
if (event is! MenuItemClickedEvent) return;
@@ -698,7 +763,10 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
698763

699764
// Add a few more items for context
700765
menu.addSeparator();
701-
final exitItem = MenuItem.createWithLabelAndType('Close Menu', MenuItemType.normal)!;
766+
final exitItem = MenuItem.createWithLabelAndType(
767+
'Close Menu',
768+
MenuItemType.normal,
769+
)!;
702770
exitItem.addListener((event) {
703771
if (event is! MenuItemClickedEvent) return;
704772
menu.close();
@@ -734,7 +802,9 @@ class _MenuExamplePageState extends State<MenuExamplePage> {
734802
(backend) => DropdownMenuItem(
735803
value: backend,
736804
enabled: Menu.isBackendSupported(backend),
737-
child: Text(backend == MenuBackend.winUi3 ? 'WinUI 3' : 'Native'),
805+
child: Text(
806+
backend == MenuBackend.winUi3 ? 'WinUI 3' : 'Native',
807+
),
738808
),
739809
)
740810
.toList(),

0 commit comments

Comments
 (0)