flutter 高度随着内容变化的dialog


    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)