Flutter 链接预览
从提供的文本中提取的链接预览,具有基本自定义功能,并能够从缓存数据渲染。
入门
LinkPreview(
onPreviewDataFetched: _onPreviewDataFetched,
text: 'https://github.com/flyerhq',
width: MediaQuery.of(context).size.width,
)
自定义
final style = TextStyle(
color: Colors.red,
fontSize: 16,
fontWeight: FontWeight.w500,
height: 1.375,
);
LinkPreview(
linkStyle: style,
metadataTextStyle: style.copyWith(
fontSize: 14,
fontWeight: FontWeight.w400,
),
metadataTitleStyle: style.copyWith(
fontWeight: FontWeight.w800,
),
padding: EdgeInsets.symmetric(
horizontal: 24,
vertical: 16,
),
onPreviewDataFetched: _onPreviewDataFetched,
text: 'https://github.com/flyerhq',
textStyle: style,
width: width,
);
从缓存数据渲染
存储从 onPreviewDataFetched 回调接收到的数据,然后
LinkPreview(
previewData: _cachedData,
text: 'https://github.com/flyerhq',
width: MediaQuery.of(context).size.width,
)
