monarch icon indicating copy to clipboard operation
monarch copied to clipboard

Ignore non-story functions inside stories files

Open fertrig opened this issue 2 years ago • 0 comments

Story functions are simple functions that return a Widget and take zero arguments. Their type is Widget Function().

The stories files may have functions which are not stories, i.e. functions which take parameters. Unfortunately, the code generation builders think they are candidates for story functions. Thus, they process them and they fail with an unhelpful error message.

The builders should detect these non-story functions and ignore them.

Here are some sample functions which generate error messages:

/// Function with one argument
Widget textWidget(Color textColor) =>
    Text('I am a Text widget', style: TextStyle(color: textColor));

/// Private function
Widget _textWidget(Color textColor) =>
    Text('I am a Text widget', style: TextStyle(color: textColor));

/// Function that returns a text widget
Text textWidget(Color textColor) =>
    Text('I am a Text widget', style: TextStyle(color: textColor));

fertrig avatar Dec 22 '22 20:12 fertrig