flutter 我如何把模糊图像在支架背景中抖动

jutyujz0  于 2023-01-27  发布在  Flutter
关注(0)|答案(1)|浏览(170)

我想把透明的图像背景上的文字。我尝试了容器的回报,但它不工作。我也尝试了容器的身体,但不幸的是,这也是我不工作。这是一个单屏幕应用程序。下面是我的代码。你的答案将对我很有帮助。提前感谢。

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
          leading: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Image.asset(
              "assets/tree.png",
            ),
          ),
          centerTitle: true,
          title: Text(
            "Welcome To Plants",
            style: TextStyle(
              color: Colors.green,
              fontWeight: FontWeight.w800,
            ),
          )),
      body: Column(
        children: [
          Flexible(
            child: ListView.builder(
              itemCount: _messages.length,
              reverse: true,
              itemBuilder: (context, index) => Padding(
                  padding: const EdgeInsets.all(8.0), child: _messages[index]),
            ),
          ),
          const Divider(
            color: Color.fromARGB(255, 51, 223, 56),
            thickness: 1,
          ),
          _istyping ? LinearProgressIndicator() : Container(),
          Padding(
            padding: const EdgeInsets.only(bottom: 10),
            child: Row(
              children: [
                Expanded(
                    child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: TextField(
                    controller: _controller,
                    onSubmitted: (value) => _sendMessage(),
                    decoration: const InputDecoration.collapsed(
                        hintText: "Type Here",
                        hintStyle: TextStyle(fontSize: 20)),
                  ),
                )),
                ButtonBar(children: [
                  IconButton(
                      onPressed: () {
                        _isImageSearch = false;
                        _sendMessage();
                      },
                      icon: Icon(
                        Icons.send,
                        color: Theme.of(context).primaryColor,
                      )),
                  TextButton(
                      onPressed: () {
                        _isImageSearch = true;
                        _sendMessage();
                      },
                      child: Text("Show Image"))
                ]),
              ],
            ),
          )
        ],
      )
b1zrtrql

b1zrtrql1#

导入以下模块

import 'dart:ui';

确保您在yaml文件中包含了该资产
例如:使用lib/utils/images/test.jpg
示例Scaffold

Scaffold(
  backgroundColor: Colors.transparent,
  body: Stack(
    children: <Widget>[
      Image.asset('lib/utils/images/test.jpg', fit: BoxFit.fill),
      BackdropFilter(
        filter: ImageFilter.blur(sigmaX: 5.0, sigmaY: 5.0),
        child: Container(
          color: Colors.black.withOpacity(0.5),
        ),
      ),
      // Add your UI component here
    ],
  ),
);

屏幕截图示例

相关问题