aves_mio/.flutter/packages/flutter/test/system_context_menu_utils.dart
Fabio Micheluz 2c988f959b
Some checks are pending
Quality check / Flutter analysis (push) Waiting to run
Quality check / CodeQL analysis (java-kotlin) (push) Waiting to run
first commit
2026-02-19 13:25:23 +01:00

25 lines
1.2 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart' show FlutterError;
/// Returns a [IOSSystemContextMenuItem] of the correct subclass given its
/// json data.
IOSSystemContextMenuItemData systemContextMenuItemDataFromJson(Map<String, dynamic> json) {
final type = json['type'] as String?;
final title = json['title'] as String?;
return switch (type) {
'copy' => const IOSSystemContextMenuItemDataCopy(),
'cut' => const IOSSystemContextMenuItemDataCut(),
'paste' => const IOSSystemContextMenuItemDataPaste(),
'selectAll' => const IOSSystemContextMenuItemDataSelectAll(),
'searchWeb' => IOSSystemContextMenuItemDataSearchWeb(title: title!),
'share' => IOSSystemContextMenuItemDataShare(title: title!),
'lookUp' => IOSSystemContextMenuItemDataLookUp(title: title!),
'captureTextFromCamera' => const IOSSystemContextMenuItemDataLiveText(),
'custom' => IOSSystemContextMenuItemDataCustom(title: title!, onPressed: () {}),
_ => throw FlutterError('Invalid json for IOSSystemContextMenuItem.type $type.'),
};
}