2017-04-21 4 views
14

मैं एक फ्लटर ऐप लिख रहा हूं, और मैं "फ्रॉस्टेड ग्लास" प्रभाव का उपयोग/कार्यान्वित करना चाहता हूं जो आईओएस पर आम है। मैं यह कैसे करु?मैं फ़्लटर में "फ्रॉस्टेड ग्लास" प्रभाव कैसे करूं?

उत्तर

24

आप इस प्रभाव को प्राप्त करने के लिए 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 
        ), 
       ), 
       ), 
      ), 
      ), 
     ), 
     ], 
    ), 
    ); 
    } 
} 
+0

मैं कैसे पाले सेओढ़ लिया प्रभाव ऐप्स के संपूर्ण चौड़ाई/ऊंचाई को कवर किया होगा? – Pieter

+1

आप एक स्टैक का उपयोग कर सकते हैं https://gist.github.com/collinjackson/321ee23b25e409d8747b623c97afa1d5 http://pasteboard.co/4ln6HDHWb.png –

+0

या, यदि आप फ्रॉस्टेड ग्लास प्रभाव का उपयोग संवाद के लिए एक मोडल बाधा के रूप में करने का प्रयास कर रहे हैं , आप बैडड्रॉपफ़िल्टर को शामिल करने के लिए मॉडलबैरियर की अपनी प्रति संशोधित कर सकते हैं। https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/modal_barrier.dart –

संबंधित मुद्दे