[英]Scrolling in its own container in expanded widget flutter, How can i make it scroll through the whole page ? ( Flutter )
[英]Flutter : Imageblur filter is filling the whole parent widget . I tried using positioned widget and container with custom heights.But not working
我使用了网络图像,我想为图像标题模糊图像的一小部分。 但是 Backdropfilter 和 imagefilter.blur 填充了整个图像。
Container(
height: 400,
width: 350,
child: ClipRRect(
borderRadius: BorderRadius.circular(25),
child: Stack(
children: [
Image.network(
"https://www.newsbtc.com/wp-content/uploads/2020/12/shutterstock_104159111.jpg",
fit: BoxFit.cover,
height: 400,
width: 350,
),
Positioned(
top: 100,
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
child: Container(
height: 200,
color: Colors.transparent,
child: Text(
"Data",
style: TextStyle(fontSize: 30),
),
),
),
)
],
),
),
),
当前Output
需要 Output
您可以在下面复制粘贴运行完整代码
您可以使用ClipRect
Positioned(
bottom: 0,
child: ClipRect(
child: BackdropFilter(
工作演示
完整代码
import 'package:flutter/material.dart';
import 'dart:ui';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
height: 400,
width: 350,
child: ClipRRect(
borderRadius: BorderRadius.circular(25),
child: Stack(
children: [
Image.network(
"https://www.newsbtc.com/wp-content/uploads/2020/12/shutterstock_104159111.jpg",
fit: BoxFit.cover,
height: 400,
width: 350,
),
Positioned(
bottom: 0,
child: ClipRect(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
child: Container(
height: 200,
width: MediaQuery.of(context).size.width,
color: Colors.transparent,
child: Text(
"Data",
style: TextStyle(fontSize: 30),
),
),
),
),
)
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.