美文网首页
flutter 高度随着内容变化的dialog

flutter 高度随着内容变化的dialog

作者: 乱逃 | 来源:发表于2021-02-26 17:16 被阅读0次

    final appStrings = AppStrings.of(context);
    final mediaQuery = MediaQuery.of(context);
    final size = mediaQuery.size;
    final width = min(size.width, 400.0) * 0.763;

    final height = 100.0;
    final constraint = BoxConstraints(minWidth: width, minHeight: height,maxWidth:size.width);
    return showSimpleDialog(
        context: context,
        barrierColor: Colors.black.withOpacity(0.5),
        backgroundColor: Colors.transparent,
        padding: EdgeInsets.all(0),
        constraint: constraint,
        builder: (context, constraint) {
          return YourPage( );
        });

同样的,在你的page的build中:

final constraint = BoxConstraints(minWidth: width, minHeight: height,maxWidth:size.width,maxHeight:double.infinity );

return Container(
   constraints: constraint,
);

相关文章

网友评论

      本文标题:flutter 高度随着内容变化的dialog

      本文链接:https://www.haomeiwen.com/subject/ttcvfltx.html