call method

ReactElement call([
  1. dynamic c1 = notSpecified,
  2. dynamic c2 = notSpecified,
  3. dynamic c3 = notSpecified,
  4. dynamic c4 = notSpecified,
  5. dynamic c5 = notSpecified,
  6. dynamic c6 = notSpecified,
  7. dynamic c7 = notSpecified,
  8. dynamic c8 = notSpecified,
  9. dynamic c9 = notSpecified,
  10. dynamic c10 = notSpecified,
  11. dynamic c11 = notSpecified,
  12. dynamic c12 = notSpecified,
  13. dynamic c13 = notSpecified,
  14. dynamic c14 = notSpecified,
  15. dynamic c15 = notSpecified,
  16. dynamic c16 = notSpecified,
  17. dynamic c17 = notSpecified,
  18. dynamic c18 = notSpecified,
  19. dynamic c19 = notSpecified,
  20. dynamic c20 = notSpecified,
  21. dynamic c21 = notSpecified,
  22. dynamic c22 = notSpecified,
  23. dynamic c23 = notSpecified,
  24. dynamic c24 = notSpecified,
  25. dynamic c25 = notSpecified,
  26. dynamic c26 = notSpecified,
  27. dynamic c27 = notSpecified,
  28. dynamic c28 = notSpecified,
  29. dynamic c29 = notSpecified,
  30. dynamic c30 = notSpecified,
  31. dynamic c31 = notSpecified,
  32. dynamic c32 = notSpecified,
  33. dynamic c33 = notSpecified,
  34. dynamic c34 = notSpecified,
  35. dynamic c35 = notSpecified,
  36. dynamic c36 = notSpecified,
  37. dynamic c37 = notSpecified,
  38. dynamic c38 = notSpecified,
  39. dynamic c39 = notSpecified,
  40. dynamic c40 = notSpecified,
])

Creates a new component with this builder's props and the specified children.

(alias for build with support for variadic children)

This method actually takes any number of children as arguments (c2, c3, ...) via noSuchMethod.

Restricted statically to 40 arguments until the dart2js fix in github.com/dart-lang/sdk/pull/26032 is released.

Implementation

ReactElement call([c1 = notSpecified, c2 = notSpecified, c3 = notSpecified, c4 = notSpecified, c5 = notSpecified, c6 = notSpecified, c7 = notSpecified, c8 = notSpecified, c9 = notSpecified, c10 = notSpecified, c11 = notSpecified, c12 = notSpecified, c13 = notSpecified, c14 = notSpecified, c15 = notSpecified, c16 = notSpecified, c17 = notSpecified, c18 = notSpecified, c19 = notSpecified, c20 = notSpecified, c21 = notSpecified, c22 = notSpecified, c23 = notSpecified, c24 = notSpecified, c25 = notSpecified, c26 = notSpecified, c27 = notSpecified, c28 = notSpecified, c29 = notSpecified, c30 = notSpecified, c31 = notSpecified, c32 = notSpecified, c33 = notSpecified, c34 = notSpecified, c35 = notSpecified, c36 = notSpecified, c37 = notSpecified, c38 = notSpecified, c39 = notSpecified, c40 = notSpecified]) {
  List childArguments;
  // Use `identical` since it compiles down to `===` in dart2js instead of calling equality helper functions,
  // and we don't want to allow any object overriding `operator==` to claim it's equal to `_notSpecified`.
  if (identical(c1, notSpecified)) {
    // Use a const list so that empty children prop values are always identical
    // in the JS props, resulting in JS libraries (e.g., react-redux) and Dart code alike
    // not marking props as having changed as a result of rerendering the ReactElement with a new list.
    childArguments = const [];
  } else if (identical(c2, notSpecified)) {
    childArguments = [c1];
  } else if (identical(c3, notSpecified)) {
    childArguments = [c1, c2];
  } else if (identical(c4, notSpecified)) {
    childArguments = [c1, c2, c3];
  } else if (identical(c5, notSpecified)) {
    childArguments = [c1, c2, c3, c4];
  } else if (identical(c6, notSpecified)) {
    childArguments = [c1, c2, c3, c4, c5];
  } else if (identical(c7, notSpecified)) {
    childArguments = [c1, c2, c3, c4, c5, c6];
  } else {
    childArguments = [c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31, c32, c33, c34, c35, c36, c37, c38, c39, c40]
      .takeWhile((child) => !identical(child, notSpecified))
      .toList();
  }

  // Ideally we'd put this assert into _sharedAsserts, but we want to make sure this conditional child logic
  // gets compiled out by directly nesting it within an `assert`.
  assert(_validateChildren(childArguments.length == 1 ? childArguments.single : childArguments));
  _sharedAsserts();

  // Use `build` instead of using emulated function behavior to work around DDC issue
  // https://github.com/dart-lang/sdk/issues/29904
  // Should have the benefit of better performance;
  return componentFactory!.build(props, childArguments);
}