飞镖 – 如何在Flutter中做“磨砂玻璃”效果?

前端之家收集整理的这篇文章主要介绍了飞镖 – 如何在Flutter中做“磨砂玻璃”效果?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在写一个Flutter应用程序,我想使用/实现在iOS上常见的“磨砂玻璃”效果.我该怎么做?

解决方法

您可以使用 BackdropFilter widget来实现这一效果.

screenshot

import 'dart:ui';
import 'package:flutter/material.dart';

void main() {
  runApp(new MaterialApp(home: new FrostedDemo()));
}

class FrostedDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Stack(
        children: <Widget>[
          new ConstrainedBox(
            constraints: const BoxConstraints.expand(),child: new Flutterlogo()
          ),new Center(
            child: new ClipRect(
              child: new BackdropFilter(
                filter: new ImageFilter.blur(sigmaX: 10.0,sigmaY: 10.0),child: new Container(
                  width: 200.0,height: 200.0,decoration: new BoxDecoration(
                    color: Colors.grey.shade200.withOpacity(0.5)
                  ),child: new Center(
                    child: new Text(
                      'Frosted',style: Theme.of(context).textTheme.display3
                    ),),],);
  }
}

猜你在找的Flutter相关文章