import 'package:flutter/material.dart'; /// create by 张风捷特烈 on 2020-03-26 /// contact me by email 1981462002@qq.com /// 说明: // { // "widgetId": 160, // "name": 'Material基本使用', // "priority": 1, // "subtitle": // "【child】 : 子组件 【Widget】\n" // "【type】 : 类型 【MaterialType】\n" // "【elevation】 : 影深 【double】\n" // "【shadowColor】 : 阴影颜色 【Color】\n" // "【color】 : 颜色 【Color】", // } class CustomMaterial extends StatelessWidget { @override Widget build(BuildContext context) { return Wrap( spacing: 10, runSpacing: 10, children: MaterialType.values.map((e) => _buildMaterial(e)).toList()); } Material _buildMaterial(MaterialType type) => Material( shadowColor: Colors.blue, type: type, color: Colors.orange, elevation: 3, child: Container( alignment: Alignment.center, width: 100, height: 60, child: Text( type.toString().split('.')[1], style: TextStyle(color: Colors.black), ), ), ); } // { // "widgetId": 160, // "name": 'Material的shape属性', // "priority": 2, // "subtitle": // "【shape】 : 形状 【ShapeBorder】\n", // } class ShapeMaterial extends StatelessWidget { final shapeMap = { 'BorderDirectional': BorderDirectional( top: BorderSide( color: Colors.white, ), start: BorderSide(color: Colors.black, width: 15), bottom: BorderSide( color: Colors.white, )), 'Border': Border( top: BorderSide(width: 5.0, color: Color(0xFFFFDFDFDF)), left: BorderSide(width: 5.0, color: Color(0xFFFFDFDFDF)), right: BorderSide(width: 5.0, color: Color(0xFFFF7F7F7F)), bottom: BorderSide(width: 5.0, color: Color(0xFFFF7F7F7F)), ), 'Circle': CircleBorder( side: BorderSide(width: 2.0, color: Color(0xFFFFDFDFDF)), ), 'RoundedRectangleBorder': RoundedRectangleBorder( side: BorderSide(width: 1.0, color: Colors.black), borderRadius: BorderRadius.all(Radius.circular(15))), 'ContinuousRectangleBorder': ContinuousRectangleBorder( side: BorderSide.none, borderRadius: BorderRadius.circular(40.0), ) }; @override Widget build(BuildContext context) { return Wrap( spacing: 10, runSpacing: 10, children: shapeMap.keys.map((e) => _buildMaterial(e)).toList()); } Material _buildMaterial(String type) => Material( shadowColor: Colors.blue, shape: shapeMap[type], color: Colors.orange, elevation: 3, textStyle: TextStyle(color: Colors.white), child: Container( alignment: Alignment.center, width: 300, height: 60, child: Text( type, ), ), ); }