写了两天的flutter,发现控件样式很多,flutter资源很少,本文在于实用性,可以减少页面代码,复用代码 页面只需引用
child: MyRaisedButton(onPress: onPressFirstBtn, text: "haha"), ); } void onPressFirstBtn() { Navigator.push( context, MaterialPageRoute(builder: (context) => WalkingPad()), // TextPage()), ); }
import 'package:flutter/material.dart'; class MyRaisedButton extends RaisedButton { @required VoidCallback onPress; String text = ""; MyRaisedButton({this.onPress, this.text}); @override // TODO: implement color Color get color => Colors.grey; @override // TODO: implement textColor Color get textColor => Colors.white; @override // TODO: implement child Widget get child => Text( text, style: TextStyle(fontSize: 20, color: Colors.white), ); @override // TODO: implement textTheme Button