颤振卡边框未生效

时间:2020-03-05 07:44:11

标签: flutter

我的卡边框有问题,因为它没有使用下面发布的代码执行。仅高程生效。谢谢您的帮助。

Widget build(BuildContext context) {
    return Card(
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(10),
      ),
      elevation: 25,
      child: InkWell(
        onTap: () {
          Navigator.push(
            context, 
            MaterialPageRoute(
              builder: (context) => SecondPage(routenum: routenum, from: from, to: to, via: via, )
            )
          );
        },
      child: Container(
        color: Colors.blue[300],
        padding: const EdgeInsets.all(10.0),
        child: Column(
          children: <Widget>[
            //Text(name),
            Text("Route Number :" +" " + routenum, style: TextStyle(color: Colors.white,)),
            Text(from, style: TextStyle(color: Colors.white,)),
            Text("via" + " " + via , style: TextStyle(color: Colors.white,)),
            Text(to, style: TextStyle(color: Colors.white,)),
            Text("(or Vice Versa)", style: TextStyle(color: Colors.white,)),
            // FlatButton(
            //   child: Text("See More"),
            //   onPressed:() {
            //     //Navigator.push(context, route);
            //   } ,
            // )
          ],
        ),
      ),
    ));
  }

2 个答案:

答案 0 :(得分:1)

我在DartPad上进行了测试,一切都很好。这是示例代码

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Card(
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(20),
          ),
          child: Container(
            width: 200,
            height: 200,
          ),
          elevation: 5,
        ),
      );
   }

card border radius

答案 1 :(得分:0)

删除

color: Colors.blue[300]

来自Container 并将其添加到Card小部件

  Widget build(BuildContext context) {
    return Card(
        color: Colors.blue[300],
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(10),
        ),
        elevation: 25,
        child: InkWell(
          onTap: () {
            Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => SecondPage(routenum: routenum, from: from, to: to, via: via, )
                )
            );
          },
          child: Container(
            padding: const EdgeInsets.all(10.0),
            child: Column(
              children: <Widget>[
                //Text(name),
                Text("Route Number :" +" " + routenum, style: TextStyle(color: Colors.white,)),
                Text(from, style: TextStyle(color: Colors.white,)),
                Text("via" + " " + via , style: TextStyle(color: Colors.white,)),
                Text(to, style: TextStyle(color: Colors.white,)),
                Text("(or Vice Versa)", style: TextStyle(color: Colors.white,)),
                // FlatButton(
                //   child: Text("See More"),
                //   onPressed:() {
                //     //Navigator.push(context, route);
                //   } ,
                // )
              ],
            ),
          ),
        ));
  }