text static method
Short hand to create text-only page.
title
is the text to be displayed on backgroundColor
. The text color
alternates between Colors.black and Colors.white depending on the
calculated contrast. This is to ensure readability of text.
Works for inline and full-page stories. See StoryView.inline for more on what inline/full-page means.
Implementation
static StoryItem text(
String title,
Color backgroundColor, {
bool shown = false,
Duration duration = const Duration(seconds: 3),
double fontSize = 18,
bool roundedTop = false,
bool roundedBottom = false,
}) {
double contrast = ContrastHelper.contrast([
backgroundColor.red,
backgroundColor.green,
backgroundColor.blue,
], [
255,
255,
255
] /** white text */);
return StoryItem(
Container(
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.vertical(
top: Radius.circular(roundedTop ? 8 : 0),
bottom: Radius.circular(roundedBottom ? 8 : 0),
),
),
padding: EdgeInsets.symmetric(
horizontal: 24,
vertical: 16,
),
child: Center(
child: Text(
title,
style: TextStyle(
color: contrast > 1.8 ? Colors.white : Colors.black,
fontSize: fontSize,
),
textAlign: TextAlign.center,
),
),
//color: backgroundColor,
),
shown: shown,
duration: duration,
);
}