我需要使背景中的图片模糊,并使文本清晰地覆盖,但是由于某些原因,文本也很模糊,并且由于我在两列中都具有GridView,因此第二列中的最后一张图像是正确,并带有清晰的文字,但其余所有都不正确。
Expanded(
child: SmartRefresher(
enablePullDown: true,
header: WaterDropHeader(),
controller: _refreshController,
onRefresh: _refreshNews,
child: GridView.count(
crossAxisCount: 2,
childAspectRatio: 1.5,
crossAxisSpacing: 1.5,
mainAxisSpacing: 1,
padding:
EdgeInsets.only(left: 1, top: 0, right: 1, bottom: 60),
children: List.generate(
items.length,
(index) =>
Stack(
children: [
ClipRRect(
child:
Image.network(items[index].get_photoUrl),
borderRadius: BorderRadius.circular(30),
),
BackdropFilter(
filter: prefix0.ImageFilter.blur(
sigmaY: 1,
sigmaX: 1,
),
child: Container(
color: Colors.black.withOpacity(0)),
),
Center(
child: Text(
items[index].get_title,
style: prefix1.TextStyle(
fontSize: 12, color: Colors.white),
),
)
],
)
),
)))
答案 0 :(得分:1)
1.you can use Stack to show picture and text in the same container.
e.g -> new BackdropFilter(
filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
child: new Container(
decoration: new BoxDecoration(color:
Colors.white.withOpacity(0.0)),
),
)
Full example ->
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Stack(
children: <Widget>[
new Container(
decoration: new BoxDecoration(
image: new DecorationImage(
image: new ExactAssetImage('assets/dog.png'),
// NetworkImage("url")
fit: BoxFit.cover,
),
),
child: new BackdropFilter(
filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0),
child: new Container(
decoration: new BoxDecoration(color: Colors.white.withOpacity(0.0)),
),
),
),
Text("hello flutter ")
],
),
),
);
}
尝试
Happy Coding :))
答案 1 :(得分:1)
结果:
Expanded(
child: SmartRefresher(
enablePullDown: true,
header: WaterDropHeader(),
controller: _refreshController,
onRefresh: _refreshNews,
child: GridView.count(
crossAxisCount: 2,
childAspectRatio: 1.5,
crossAxisSpacing: 1.5,
mainAxisSpacing: 1,
padding:
EdgeInsets.only(left: 1, top: 0, right: 1, bottom: 60),
children: List.generate(
items.length,
(index) => Stack(
children: <Widget>[
ClipRRect(
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image:
NetworkImage(items[index].get_photoUrl),
),
),
child: new BackdropFilter(
filter: new ImageFilter.blur(
sigmaX: 1.5, sigmaY: 1.5),
child: Container(
color: Colors.white.withOpacity(0.0)),
),
),
borderRadius: BorderRadius.circular(30),
),
Center(child: Text(items[index].get_title))
],
),
),
)))