基本上,我想重写位于showDialog
中的祖先packages/flutter/lib/src/material/dialog.dart
函数的一些属性>
我想更改barrierColor
属性并从showGeneralDialog构建器方法中删除SafeArea
小部件。
//... Future<T> showDialog<T>({ @required BuildContext context, bool barrierDismissible = true, @Deprecated( 'Instead of using the "child" argument, return the child from a closure ' 'provided to the "builder" argument. This will ensure that the BuildContext ' 'is appropriate for widgets built in the dialog.' ) Widget child, WidgetBuilder builder, }) { assert(child == null || builder == null); assert(debugCheckHasMaterialLocalizations(context)); final ThemeData theme = Theme.of(context, shadowThemeOnly: true); return showGeneralDialog( context: context, pageBuilder: (BuildContext buildContext, Animation<double> animation, Animation<double> secondaryAnimation) { final Widget pageChild = child ?? Builder(builder: builder); return SafeArea( // <-- !remove SafeArea widget! child: Builder( builder: (BuildContext context) { return theme != null ? Theme(data: theme, child: pageChild) : pageChild; } ), ); }, barrierDismissible: barrierDismissible, barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, barrierColor: Colors.black54, // <-- !change the color! transitionDuration: const Duration(milliseconds: 150), transitionBuilder: _buildMaterialDialogTransitions, ); }
可以在
main.dart
文件中执行吗?如果是,谁能举个例子吗?
基本上,我想覆盖位于packages / flutter / lib / src / material / dialog.dart中的祖先showDialog函数的一些道具,我想更改barrierColor属性并删除SafeArea ...
您可以仅将该函数复制/粘贴到main.dart文件中,在其中更改名称和barrierColor,因为您可以使用showGeneralDialog,所以它可以工作