大佬教程收集整理的这篇文章主要介绍了飞镖 – 如何在颤动中制作全屏幕对话框?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
ModalRoute
:
import 'package:Flutter/material.dart'; class TutorialOverlay extends ModalRoute<void> { @override Duration get transitionDuration => Duration(milliseconds: 500); @override bool get opaque => false; @override bool get barrierDismissible => false; @override Color get barrierColor => Colors.black.withOpacity(0.5); @override String get barrierLabel => null; @override bool get maintainState => true; @override Widget buildPage( BuildContext context,Animation<double> animation,Animation<double> secondaryAnimation,) { // This makes sure that text and other content follows the material style return Material( type: MaterialType.transparency,// make sure that the overlay content is not cut off child: SafeArea( child: _buildOverlayContent(context),),); } Widget _buildOverlayContent(BuildContext context) { return Center( child: column( mainAxisSize: MainAxisSize.min,children: <Widget>[ Text( 'This is a nice overlay',style: TextStyle(color: Colors.white,fontSize: 30.0),RaisedButton( onPressed: () => Navigator.pop(context),child: Text('Dismiss'),) ],); } @override Widget buildTransitions( BuildContext context,Widget child) { // You can add your own animations for the overlay content return FadeTransition( opacity: animation,child: ScaleTransition( scale: animation,child: child,); } } // Example application: void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Playground',home: TestPage(),); } } class TestPage extends StatelessWidget { void _showOverlay(BuildContext context) { Navigator.of(context).push(TutorialOverlay()); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Test')),body: Padding( padding: EdgeInsets.all(16.0),child: Center( child: RaisedButton( onPressed: () => _showOverlay(context),child: Text('Show Overlay'),); } }
以上是大佬教程为你收集整理的飞镖 – 如何在颤动中制作全屏幕对话框?全部内容,希望文章能够帮你解决飞镖 – 如何在颤动中制作全屏幕对话框?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。