这是一个例子:
如何在Flutter中制作这样的?
解决方法 您可以使用导航器推送半透明的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'),); }}总结
以上是内存溢出为你收集整理的飞镖 – 如何在颤动中制作全屏幕对话框?全部内容,希望文章能够帮你解决飞镖 – 如何在颤动中制作全屏幕对话框?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)