14
私はFlutterアプリケーションを作成しています.iOSでよく使われる「曇りガラス」効果を使用/実装したいと思います。これはどうすればいいですか?Flutterで「曇りガラス」効果をどうやって行うのですか?
私はFlutterアプリケーションを作成しています.iOSでよく使われる「曇りガラス」効果を使用/実装したいと思います。これはどうすればいいですか?Flutterで「曇りガラス」効果をどうやって行うのですか?
この効果を得るにはBackdropFilter widgetを使用できます。
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
),
),
),
),
),
),
],
),
);
}
}
どのように私はつや消し効果がアプリの全体の幅/高さをカバーするだろうか? – Pieter
Stackを使用することができます。https://gist.github.com/collinjackson/321ee23b25e409d8747b623c97afa1d5 http://pasteboard.co/4ln6HDHWb.png –
また、フロストガラス効果をダイアログのモーダルバリアとして使用しようとしている場合ModalBarrierのコピーを修正して、BackdropFilterを組み込むことができます。 https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/modal_barrier.dart –