gpt4 book ai didi

flutter - 标题在flexibleSpaceBar上没有正确显示

转载 作者:IT老高 更新时间:2023-10-28 12:40:41 27 4
gpt4 key购买 nike

我正在尝试显示标题,但如您所见,它没有正确显示。

enter image description here

我尝试将 softWrap 设置为 true,但还是一样。

代码来自flutter contacts_demo gallery

flexibleSpace: FlexibleSpaceBar(
title: const Text('Fantastic Beasts And Where To Find Them'),
background: Stack(
fit: StackFit.expand,
children: <Widget>[
Image.asset(
'people/ali_landscape.png',
package: 'flutter_gallery_assets',
fit: BoxFit.cover,
height: _appBarHeight,
),
// This gradient ensures that the toolbar icons are distinct
// against the background image.
const DecoratedBox(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment(0.0, -1.0),
end: Alignment(0.0, -0.4),
colors: <Color>[Color(0x60000000), Color(0x00000000)],
),
),
),
],
),
),

最佳答案

您可以将 ConstrainedBoxMediaQuery.of(context).size.width

一起使用
final mediaQuery = MediaQuery.of(context);

final availableWidth = mediaQuery.size.width - 160;

随着

title: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: availableWidth,
),
child: const Text('Fantastic Beasts And Where To Find Them'),
),

关于flutter - 标题在flexibleSpaceBar上没有正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53251903/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com