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
437 stars 22 forks source link

Pass parameters to widgets #7

Closed simc closed 3 years ago

simc commented 3 years ago

This is a very promising project. It would be awesome if it was possible to define parameters that can be passed to widgets and changed in monach to test different configurations of a widget.

For example like this:

Widget textWidget(Color textColor) => Text('I am a Text widget', style: TextStyle(color: textColor));
fertrig commented 3 years ago

We agree that it would be nice to change those parameter on the UI. Currently, you can do that in code:

Text textWidget(Color textColor) =>
    Text('I am a Text widget', style: TextStyle(color: textColor));

Widget red() => textWidget(Colors.red);
Widget yellow() => textWidget(Colors.yellow);
Widget blue() => textWidget(Colors.blue);

You will then see red, yellow and blue as stories in the Monarch UI. As you change the colors in code, the Monarch UI will reflect the changes automatically. The feedback is fast enough once you get going.

Future versions of Monarch will let you change that on the Monarch UI so you can play with stories live.