画卡的一面-颤振

时间:2020-03-09 17:21:02

标签: flutter

图片:Card

我正在尝试将我的Card小部件绘制为 那(如图所示)我该怎么做?

BoxDecoration(
    border: Border(
      left: BorderSide( 
        color: Colors.black,
        width: 3.0,
      ),
    ),
    borderRadius: BorderRadius.all(
        Radius.circular(5.0) 
    ),
  ); 

我尝试了这个,但是borderside和borderadiusall彼此冲突,所以我得到一个错误

1 个答案:

答案 0 :(得分:0)

您可以在下面复制粘贴运行完整代码
您可以将两个ContainersClipRRect一起使用
代码段

    ClipRRect(
              borderRadius: BorderRadius.circular(20),
              child: Container(
                decoration: BoxDecoration(                      
                    border: Border.all(color: Colors.grey, width: 4)),
                child: Container(
                  width: 300,
                  height: 200,
                  decoration: const BoxDecoration(
                    //color: Colors.grey,
                    border: Border(
                      left: BorderSide(width: 3.0, color: Colors.green),
                    ),
                  ),
                ),
              ),
            )

工作演示

enter image description here

完整代码

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            ClipRRect(
              borderRadius: BorderRadius.circular(20),
              child: Container(
                decoration: BoxDecoration(
                    //color: Colors.grey,
                    border: Border.all(color: Colors.grey, width: 4)),
                child: Container(
                  width: 300,
                  height: 200,
                  decoration: const BoxDecoration(
                    //color: Colors.grey,
                    border: Border(
                      left: BorderSide(width: 3.0, color: Colors.green),
                    ),
                  ),
                ),
              ),
            ),
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}
相关问题