图片:Card
我正在尝试将我的Card小部件绘制为 那(如图所示)我该怎么做?
BoxDecoration(
border: Border(
left: BorderSide(
color: Colors.black,
width: 3.0,
),
),
borderRadius: BorderRadius.all(
Radius.circular(5.0)
),
);
我尝试了这个,但是borderside和borderadiusall彼此冲突,所以我得到一个错误
答案 0 :(得分:0)
您可以在下面复制粘贴运行完整代码
您可以将两个Containers
与ClipRRect
一起使用
代码段
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),
),
),
),
),
)
工作演示
完整代码
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),
),
);
}
}