storyboard
通过将小部件与您的应用隔离,加快 Flutter 用户界面的迭代开发。
在 Flutter 中进行组件故事板设计
以下为英文项目原文快照,最新内容请访问 GitHub。
Faster iterative development of Flutter user interfaces by isolating widgets from your app, inspired by Storybook. Stage a collection of Widgets outside their normal app context. By repeating the same widget in various configurations or states in a single view, the effect of code changes to the Widget can quickly be assessed. This is especially useful for cosmetic changes, but also effective for behavior changes.
The first step is to build a few stories, from which your Storyboard will be composed. Building stories is done by providing concrete children of the Story abstract class, e.g.
import 'package:mypackage/contacts.dart';
import 'package:storyboard/storyboard.dart';
class ContactsListStory extends Story {
@override
List<Widget> get storyContent {
return [ContactsList()];
}
}
At a minimum, the abstract storyContent getter, which provides the widgets to be observed, must be overridden. Overriding the title will alter the heading presented for the story. Overriding isFullScreen (or implementing FullScreenStory) will instruct the Widget to render itself within a new Navigator route without scaffolding.
The build method itself can also be overridden to completely customize the display of the Story.
A storyboard is little more than a collection of stories.
import 'package:flutter/material.dart';
import 'package:storyboard/storyboard.dart';
import 'stories/contacts_story.dart';
void main() {
runApp(MaterialApp(
home: Storyboard([
ContactsListStory(),
ContactsCardStory(contact: Contact("alice")),
ContactsCardStory(contact: Contact("bob")),
ContactsCardStory(contact: Contact("charlie")),
])));
}
Or more simply, run the convenience StoryboardApp directly.
void main() {
runApp(StoryboardApp([
ContactsListStory(),
ContactsCardStory(contact: Contact("alice")),
ContactsCardStory(contact: Contact("bob")),
ContactsCardStory(contact: Contact("charlie")),
]));
}
See the article Storyboarding Widgets in Flutter.
依赖清单 3 项
{"sdk":"flutter"}^4.0.0-nullsafety.0{"sdk":"flutter"}先按使用场景筛选,再比较项目活跃情况,最后到原始仓库核对使用要求。
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗