Card 属性介绍
Card 就是个容器,用途和 Container 很像,这里就不多赘述了,直接上代码。
import 'package:flutter/material.dart';void main() {runApp(MyApp());
}class MyApp extends StatelessWidget {@overrideWidget build(BuildContext context) {return MaterialApp(home: FMCardVC());}
}class FMCardVC extends StatelessWidget{@overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text("Card"),),body: _listView(),);}ListView _listView(){return ListView(padding: EdgeInsets.all(30),children: [_normalCard(),Padding(padding: EdgeInsets.all(30)),_shapeCard()],);}Card _normalCard(){return Card(color: Colors.red, shadowColor: Colors.yellow, elevation: 20, borderOnForeground: false, margin: EdgeInsets.fromLTRB(0, 50, 0, 30), child: Container(width: 100,height: 100,alignment: Alignment.center,child: Text("Noraml Card", style: TextStyle(color: Colors.white),),),);}Card _shapeCard(){return Card(color: Colors.red, shadowColor: Colors.yellow, elevation: 20, borderOnForeground: false, margin: EdgeInsets.fromLTRB(0, 50, 0, 30), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40),side: BorderSide(color: Colors.yellow,width: 3,),),child: Container(width: 100,height: 100,alignment: Alignment.center,child: Text("Shape Card", style: TextStyle(color: Colors.white),),),);}
}