Previewing widgets
Setup
To show your app's theme, you need to create a preview configuration.
It should only take a few minutes.
Previewing
To create a widget preview, create a public top-level function containing "preview" in its name:
Widget preview() {
return MyWidget();
}
Widget anotherPreview() {
return AnotherWidget();
}
You can also return multiple widgets from a preview method:
List<Widget> preview() {
return [MyWidget(), AnotherWidget()];
}
tip
The function must be top-level; not within a class. It must be public.
Limitations
Previews run within the Flutter test environment, which means platform-specific plugins won't work.