2017-04-21 14 views

Trả lời

24

Bạn có thể sử dụng BackdropFilter widget để đạt được hiệu ứng này.

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 
        ), 
       ), 
       ), 
      ), 
      ), 
     ), 
     ], 
    ), 
    ); 
    } 
} 
+0

Làm thế nào tôi sẽ làm cho hiệu ứng mờ che chiều rộng toàn bộ/chiều cao của ứng dụng? – Pieter

+1

bạn có thể sử dụng Stack https://gist.github.com/collinjackson/321ee23b25e409d8747b623c97afa1d5 http://pasteboard.co/4ln6HDHWb.png –

+0

hoặc nếu bạn đang cố gắng sử dụng hiệu ứng kính mờ như một rào cản phương thức cho hộp thoại , bạn có thể sửa đổi bản sao của ModalBarrier của bạn để bao gồm một BackdropFilter. https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/modal_barrier.dart –

Các vấn đề liên quan