Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 不同分辨率设备上的颤振警报对话框小部件大小问题_Flutter_Flutter Alertdialog_Flutter Radiobutton - Fatal编程技术网

Flutter 不同分辨率设备上的颤振警报对话框小部件大小问题

Flutter 不同分辨率设备上的颤振警报对话框小部件大小问题,flutter,flutter-alertdialog,flutter-radiobutton,Flutter,Flutter Alertdialog,Flutter Radiobutton,我想要这样。我在ALertDialog中使用了radiolistile。在不同的android设备中,它会产生不同大小的对话框。因此导致像素错误溢出或只是黑屏 这是我的密码 @override Widget build(BuildContext context){Size Size Size=MediaQuery.of(context).Size; return AlertDialog( insetPadding: EdgeInsets.symmetric(

我想要这样。我在
ALertDialog
中使用了
radiolistile
。在不同的android设备中,它会产生不同大小的对话框。因此导致像素错误溢出或只是黑屏

这是我的密码

@override Widget build(BuildContext context){Size Size Size=MediaQuery.of(context).Size;

return AlertDialog(
        insetPadding: EdgeInsets.symmetric(
            horizontal: SizeConfig.safeBlockHorizontal * 16,
            vertical: SizeConfig.safeBlockHorizontal * 40),
        title: Text("Methods"),
        content: ListView(children: <Widget>[
          Container(
            decoration: BoxDecoration(
                shape: BoxShape.rectangle,
                border: Border.all(
                    color: Theme.of(context).hintColor, width: 1.0)),
            child: RadioListTile(
                value: 1,
                groupValue: _crtIndex,
                title: Column(
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text(
                          "12 months",
                          style: TextStyle(
                              fontWeight: FontWeight.bold, fontSize: 13),
                        ),
                        Text(
                          "Rs.4,375",
                          style: TextStyle(
                              fontWeight: FontWeight.bold, fontSize: 13),
                        ),
                      ],
                    ),
                    SizedBox(width: size.width * 0.005),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text(
                          "50% off",
                          style: TextStyle(
                            fontWeight: FontWeight.normal,
                            fontSize: 13,
                          ),
                        ),

                        Text(
                          "9,876",
                          style: TextStyle(
                              fontWeight: FontWeight.normal,
                              fontSize: 13,
                              decoration: TextDecoration.lineThrough),
                        ),
                      ],
                    ),
                  ],
                ),
                activeColor: Colors.teal,
                onChanged: (val) {
                  setState(() {
                    _crtIndex = val;
                  });
                }),
          ),
          SizedBox(height: size.height * 0.01),
          new FlatButton(
        color: Colors.red,
        child: new Text('BUY NOW AND SAVE'),
        onPressed: () {
           Navigator.of(context).pop();
        },
      ),
    ]));
返回警报对话框(
插入添加:EdgeInsets.symmetric(
水平:SizeConfig.safeBlockHorizontal*16,
垂直:SizeFig.SafeBlock水平*40),
标题:文本(“方法”),
内容:列表视图(子项:[
容器(
装饰:盒子装饰(
形状:BoxShape.rectangle,
边界:边界(
颜色:Theme.of(context.hintColor,宽度:1.0)),
孩子:放射科医生(
价值:1,
组值:_crtIndex,
标题:专栏(
儿童:[
划船(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
正文(
“12个月”,
样式:TextStyle(
fontWeight:fontWeight.bold,fontSize:13),
),
正文(
“4375卢比”,
样式:TextStyle(
fontWeight:fontWeight.bold,fontSize:13),
),
],
),
SizedBox(宽度:size.width*0.005),
划船(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
正文(
“五折”,
样式:TextStyle(
fontWeight:fontWeight.normal,
尺寸:13,
),
),
正文(
"9,876",
样式:TextStyle(
fontWeight:fontWeight.normal,
尺寸:13,
装饰:文本装饰。线条贯穿),
),
],
),
],
),
activeColor:Colors.teal,
一旦更改:(val){
设置状态(){
_crtIndex=val;
});
}),
),
SizedBox(高度:size.height*0.01),
新扁平按钮(
颜色:颜色,红色,
子项:新文本(“立即购买并保存”),
已按下:(){
Navigator.of(context.pop();
},
),
]));
我还尝试将
AlertDialog
放在
SizedBox
中,也放在
Container
中,并尝试设置高度和宽度

我使用了
Size Size=MediaQuery.of(context.Size;
来获取高度和宽度

我还尝试了
插入:EdgeInsets.symmetric(水平:*值,垂直:*值),

什么都没用


我是颤振新手。请帮助。提前谢谢您查看我制作的示例:

import 'package:flutter/material.dart';

import 'package:json_parsing_example/offerScreen.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Login(),
      debugShowCheckedModeBanner: false,
    );
  }
}

class Login extends StatefulWidget {
  @override
  _LoginState createState() => _LoginState();
}

class _LoginState extends State<Login> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: SafeArea(
            child: Center(
      child: Column(
        children: <Widget>[
          RaisedButton(
            child: Text('Tap'),
            onPressed: () async {
              var response = await Navigator.push(
                  context,
                  MaterialPageRoute(
                    builder: (context) => OfferPage(),
                  ));
              if (response !=
                  null) // This is when the user presses the back button
              {
                // if user inputs anything then this is where the output will come
                print(response);
              }

              //this response is you value that you selected
              // you can do processing on this page or the selection
              //page
            },
          ),
          RaisedButton(
            child: Text('Tap2'),
            onPressed: () {
              showModalBottomSheet(
                isScrollControlled: true,
                context: context,
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.vertical(
                    top: Radius.circular(20),
                  ),
                ),
                clipBehavior: Clip.antiAliasWithSaveLayer,
                builder: (context) => Container(
                  height: MediaQuery.of(context).size.height * 0.95,
                  child: Column(
                    children: <Widget>[
                      Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: <Widget>[
                          Padding(
                            padding: const EdgeInsets.only(right: 12, top: 15),
                            child: GestureDetector(
                              onTap: () {
                                Navigator.of(context).pop(null);
                              },
                              child: Icon(
                                Icons.close,
                                size: 30,
                              ),
                            ),
                          ),
                        ],
                      ),
                      Expanded(
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: <Widget>[
                            Container(
                              margin: EdgeInsets.symmetric(horizontal: 10),
                              decoration: BoxDecoration(
                                  shape: BoxShape.rectangle,
                                  border: Border.all(
                                      color: Theme.of(context).hintColor,
                                      width: 0.5)),
                              child: Padding(
                                padding: const EdgeInsets.all(8.0),
                                child: RadioListTile(
                                    value: 1,
                                    groupValue: 1,
                                    title: Column(
                                      children: [
                                        Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                          children: [
                                            Text(
                                              "12 months",
                                              style: TextStyle(
                                                  fontWeight: FontWeight.bold,
                                                  fontSize: 13),
                                            ),
                                            Text(
                                              "Rs.4,375",
                                              style: TextStyle(
                                                  fontWeight: FontWeight.bold,
                                                  fontSize: 13),
                                            ),
                                          ],
                                        ),
                                        SizedBox(
                                            width: MediaQuery.of(context)
                                                    .size
                                                    .width *
                                                0.005),
                                        Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                          children: [
                                            Text(
                                              "50% off",
                                              style: TextStyle(
                                                fontWeight: FontWeight.normal,
                                                fontSize: 13,
                                              ),
                                            ),
                                            Text(
                                              "9,876",
                                              style: TextStyle(
                                                  fontWeight: FontWeight.normal,
                                                  fontSize: 13,
                                                  decoration: TextDecoration
                                                      .lineThrough),
                                            ),
                                          ],
                                        ),
                                      ],
                                    ),
                                    activeColor: Colors.teal,
                                    onChanged: (val) {
                                      setState(() {});
                                    }),
                              ),
                            ),
                            SizedBox(
                              height: 10,
                            ),
                            Container(
                              margin: EdgeInsets.symmetric(horizontal: 10),
                              decoration: BoxDecoration(
                                  shape: BoxShape.rectangle,
                                  border: Border.all(
                                      color: Theme.of(context).hintColor,
                                      width: 1.0)),
                              child: Padding(
                                padding: const EdgeInsets.all(8.0),
                                child: RadioListTile(
                                    value: 1,
                                    groupValue: 1,
                                    title: Column(
                                      children: [
                                        Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                          children: [
                                            Text(
                                              "12 months",
                                              style: TextStyle(
                                                  fontWeight: FontWeight.bold,
                                                  fontSize: 13),
                                            ),
                                            Text(
                                              "Rs.4,375",
                                              style: TextStyle(
                                                  fontWeight: FontWeight.bold,
                                                  fontSize: 13),
                                            ),
                                          ],
                                        ),
                                        SizedBox(
                                            width: MediaQuery.of(context)
                                                    .size
                                                    .width *
                                                0.005),
                                        Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                          children: [
                                            Text(
                                              "50% off",
                                              style: TextStyle(
                                                fontWeight: FontWeight.normal,
                                                fontSize: 13,
                                              ),
                                            ),
                                            Text(
                                              "9,876",
                                              style: TextStyle(
                                                  fontWeight: FontWeight.normal,
                                                  fontSize: 13,
                                                  decoration: TextDecoration
                                                      .lineThrough),
                                            ),
                                          ],
                                        ),
                                      ],
                                    ),
                                    activeColor: Colors.teal,
                                    onChanged: (val) {
                                      setState(() {});
                                    }),
                              ),
                            ),
                            SizedBox(
                              height: 10,
                            ),
                            Container(
                              margin: EdgeInsets.symmetric(horizontal: 10),
                              decoration: BoxDecoration(
                                  shape: BoxShape.rectangle,
                                  border: Border.all(
                                      color: Theme.of(context).hintColor,
                                      width: 1.0)),
                              child: Padding(
                                padding: const EdgeInsets.all(8.0),
                                child: RadioListTile(
                                    value: 1,
                                    groupValue: 1,
                                    title: Column(
                                      children: [
                                        Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                          children: [
                                            Text(
                                              "12 months",
                                              style: TextStyle(
                                                  fontWeight: FontWeight.bold,
                                                  fontSize: 13),
                                            ),
                                            Text(
                                              "Rs.4,375",
                                              style: TextStyle(
                                                  fontWeight: FontWeight.bold,
                                                  fontSize: 13),
                                            ),
                                          ],
                                        ),
                                        SizedBox(
                                            width: MediaQuery.of(context)
                                                    .size
                                                    .width *
                                                0.005),
                                        Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                          children: [
                                            Text(
                                              "50% off",
                                              style: TextStyle(
                                                fontWeight: FontWeight.normal,
                                                fontSize: 13,
                                              ),
                                            ),
                                            Text(
                                              "9,876",
                                              style: TextStyle(
                                                  fontWeight: FontWeight.normal,
                                                  fontSize: 13,
                                                  decoration: TextDecoration
                                                      .lineThrough),
                                            ),
                                          ],
                                        ),
                                      ],
                                    ),
                                    activeColor: Colors.teal,
                                    onChanged: (val) {
                                      setState(() {});
                                    }),
                              ),
                            ),
                            SizedBox(
                                height:
                                    MediaQuery.of(context).size.height * 0.01),
                            Container(
                              width: MediaQuery.of(context).size.width,
                              height: 60,
                              child: Expanded(
                                child: Padding(
                                  padding: const EdgeInsets.symmetric(
                                      horizontal: 10),
                                  child: new FlatButton(
                                    color: Colors.red,
                                    child: new Text(
                                      'BUY NOW AND SAVE',
                                      style: TextStyle(
                                        color: Colors.white,
                                      ),
                                    ),
                                    onPressed: () {
                                      Navigator.of(context).pop();
                                    },
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
              );
            },
          ),
        ],
      ),
    )));
  }
}

导入“包装:颤振/材料.省道”;
导入“package:json_parsing_example/offerScreen.dart”;
void main()=>runApp(MyApp());
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
主页:登录(),
debugShowCheckedModeBanner:false,
);
}
}
类登录扩展StatefulWidget{
@凌驾
_LoginState createState()=>\u LoginState();
}
类_LoginState扩展了状态{
@凌驾
小部件构建(构建上下文){
返回脚手架(
正文:安全区(
儿童:中心(
子:列(
儿童:[
升起的按钮(
子项:文本('Tap'),
onPressed:()异步{
var response=wait Navigator.push(
上下文
材料路线(
生成器:(上下文)=>OfferPage(),
));
如果(回答=
null)//这是用户按下“后退”按钮的时间
{
//如果用户输入任何内容,那么这就是输出的来源
打印(回复);
}
//此响应是您选择的值
//您可以在此页面或所选内容上进行处理
//页面
},
),
升起的按钮(
子项:文本('Tap2'),
已按下:(){
showModalBottomSheet(
是的,
上下文:上下文,
形状:圆形矩形边框(
borderRadius:borderRadius.vertical(
顶部:半径。圆形(20),
),
),
clipBehavior:Clip.antiAliasWithSaveLayer,
生成器:(上下文)=>容器(
高度:MediaQuery.of(上下文).size.height*0.95,
子:列(
儿童:[
划船(
mainAxisAlignment:mainAxisAlignment.end,
儿童:[
填充物(
填充:仅限常量边集(右:12,顶部:15),
儿童:手势检测器(
onTap:(){
Navigator.of(context.pop)(null);
},
子:图标(
图标。关闭,
import 'package:flutter/material.dart';

class OfferPage extends StatefulWidget {
  @override
  _OfferPageState createState() => _OfferPageState();
}

class _OfferPageState extends State<OfferPage> {
  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: Colors.white,
      body: SafeArea(
        child: Container(
          height: MediaQuery.of(context).size.height,
          width: MediaQuery.of(context).size.width,
          child: Column(
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.end,
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: GestureDetector(
                      onTap: () {
                        Navigator.of(context).pop(null);
                      },
                      child: Icon(
                        Icons.close,
                        size: 30,
                      ),
                    ),
                  ),
                ],
              ),
              Expanded(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      margin: EdgeInsets.symmetric(horizontal: 10),
                      decoration: BoxDecoration(
                          shape: BoxShape.rectangle,
                          border: Border.all(
                              color: Theme.of(context).hintColor, width: 0.5)),
                      child: Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: RadioListTile(
                            value: 1,
                            groupValue: 1,
                            title: Column(
                              children: [
                                Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text(
                                      "12 months",
                                      style: TextStyle(
                                          fontWeight: FontWeight.bold,
                                          fontSize: 13),
                                    ),
                                    Text(
                                      "Rs.4,375",
                                      style: TextStyle(
                                          fontWeight: FontWeight.bold,
                                          fontSize: 13),
                                    ),
                                  ],
                                ),
                                SizedBox(width: size.width * 0.005),
                                Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text(
                                      "50% off",
                                      style: TextStyle(
                                        fontWeight: FontWeight.normal,
                                        fontSize: 13,
                                      ),
                                    ),
                                    Text(
                                      "9,876",
                                      style: TextStyle(
                                          fontWeight: FontWeight.normal,
                                          fontSize: 13,
                                          decoration:
                                              TextDecoration.lineThrough),
                                    ),
                                  ],
                                ),
                              ],
                            ),
                            activeColor: Colors.teal,
                            onChanged: (val) {
                              setState(() {});
                            }),
                      ),
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    Container(
                      margin: EdgeInsets.symmetric(horizontal: 10),
                      decoration: BoxDecoration(
                          shape: BoxShape.rectangle,
                          border: Border.all(
                              color: Theme.of(context).hintColor, width: 1.0)),
                      child: Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: RadioListTile(
                            value: 1,
                            groupValue: 1,
                            title: Column(
                              children: [
                                Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text(
                                      "12 months",
                                      style: TextStyle(
                                          fontWeight: FontWeight.bold,
                                          fontSize: 13),
                                    ),
                                    Text(
                                      "Rs.4,375",
                                      style: TextStyle(
                                          fontWeight: FontWeight.bold,
                                          fontSize: 13),
                                    ),
                                  ],
                                ),
                                SizedBox(width: size.width * 0.005),
                                Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text(
                                      "50% off",
                                      style: TextStyle(
                                        fontWeight: FontWeight.normal,
                                        fontSize: 13,
                                      ),
                                    ),
                                    Text(
                                      "9,876",
                                      style: TextStyle(
                                          fontWeight: FontWeight.normal,
                                          fontSize: 13,
                                          decoration:
                                              TextDecoration.lineThrough),
                                    ),
                                  ],
                                ),
                              ],
                            ),
                            activeColor: Colors.teal,
                            onChanged: (val) {
                              setState(() {});
                            }),
                      ),
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    Container(
                      margin: EdgeInsets.symmetric(horizontal: 10),
                      decoration: BoxDecoration(
                          shape: BoxShape.rectangle,
                          border: Border.all(
                              color: Theme.of(context).hintColor, width: 1.0)),
                      child: Padding(
                        padding: const EdgeInsets.all(8.0),
                        child: RadioListTile(
                            value: 1,
                            groupValue: 1,
                            title: Column(
                              children: [
                                Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text(
                                      "12 months",
                                      style: TextStyle(
                                          fontWeight: FontWeight.bold,
                                          fontSize: 13),
                                    ),
                                    Text(
                                      "Rs.4,375",
                                      style: TextStyle(
                                          fontWeight: FontWeight.bold,
                                          fontSize: 13),
                                    ),
                                  ],
                                ),
                                SizedBox(width: size.width * 0.005),
                                Row(
                                  mainAxisAlignment:
                                      MainAxisAlignment.spaceBetween,
                                  children: [
                                    Text(
                                      "50% off",
                                      style: TextStyle(
                                        fontWeight: FontWeight.normal,
                                        fontSize: 13,
                                      ),
                                    ),
                                    Text(
                                      "9,876",
                                      style: TextStyle(
                                          fontWeight: FontWeight.normal,
                                          fontSize: 13,
                                          decoration:
                                              TextDecoration.lineThrough),
                                    ),
                                  ],
                                ),
                              ],
                            ),
                            activeColor: Colors.teal,
                            onChanged: (val) {
                              setState(() {});
                            }),
                      ),
                    ),
                    SizedBox(height: size.height * 0.01),
                    Container(
                      width: MediaQuery.of(context).size.width,
                      height: 60,
                      child: Expanded(
                        child: Padding(
                          padding: const EdgeInsets.symmetric(horizontal: 10),
                          child: new FlatButton(
                            color: Colors.red,
                            child: new Text(
                              'BUY NOW AND SAVE',
                              style: TextStyle(
                                color: Colors.white,
                              ),
                            ),
                            onPressed: () {
                              Navigator.of(context).pop("your selected value");
                            },
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}