move method

Future<Object> move(
  1. Object tabIds,
  2. MoveProperties moveProperties
)

Moves one or more tabs to a new position within its window, or to a new window. Note that tabs can only be moved to and from normal (window.type === "normal") windows. tabIds The tab ID or list of tab IDs to move.

Implementation

Future<Object> move(
  Object tabIds,
  MoveProperties moveProperties,
) async {
  var $res = await $js.chrome.tabs
      .move(
        switch (tabIds) {
          int() => tabIds.toJS,
          List<int>() => tabIds.toJSArray((e) => e.toJS),
          _ => throw UnsupportedError(
              'Received type: ${tabIds.runtimeType}. Supported types are: int, List<int>')
        },
        moveProperties.toJS,
      )
      .toDart;
  return $res.when(
    isOther: (v) => Tab.fromJS((v as $js.Tab)),
    isArray: (v) =>
        v.toDart.cast<$js.Tab>().map((e) => Tab.fromJS(e)).toList(),
  );
}