Dropsource / monarch

Monarch is a tool for building Flutter widgets in isolation. It makes it easy to build, test and debug complex UIs.
https://monarchapp.io
MIT License
433 stars 22 forks source link

Ignore non-story functions inside stories files #65

Open fertrig opened 1 year ago

fertrig commented 1 year ago

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));