testWidgetMethod method

Expression testWidgetMethod({
  1. required String widgetName,
  2. required String? builder,
  3. required String goldenName,
  4. required String? theme,
  5. required bool darkTheme,
  6. required String dimension,
})

Generates a test method that runs a single Golden test.

Implementation

Expression testWidgetMethod({
  required String widgetName,
  required String? builder,
  required String goldenName,
  required String? theme,
  required bool darkTheme,
  required String dimension,
}) {
  return refer('testWidgets').newInstance([
    refer(
      '\'$dimension $widgetName ${darkTheme ? 'dark theme' : 'light theme'}\'',
    ),
    anonymousMethod(
      widgetName: widgetName,
      builder: builder,
      goldenName: goldenName,
      theme: theme,
      darkTheme: darkTheme,
      dimension: dimension,
    ).closure,
  ]);
}