1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | class _MyHomePageState extends State<MyHomePage> { static var _message = "ok."; static var _janken = <String>['グー','チョキ','パー']; @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text('App Name'), ), body: new Center( child: Column( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ Padding( padding: EdgeInsets.all(20.0), child: Text( _message, style: TextStyle( fontSize: 32.0, fontWeight: FontWeight.w400, fontFamily:"Robot" ), ), ), TextButton( onPressed: buttonPressed, child: Padding( padding: EdgeInsets.all(10.0), child: Text( "Push me!", style: TextStyle( fontSize: 32.0, color: const Color(0xff000000), fontWeight: FontWeight.w400, fontFamily: "Robot"), ) ) ) ] ), ), ); } void buttonPressed(){ setState((){ _message = (_janken..shuffle()).first; }); } } |
1 2 3 4 5 6 7 8 9 10 | TextButton( onPressed: buttonPressed, child: Padding( padding: EdgeInsets.all(10.0), child: Icon( Icons.android, size: 50.0, ) ) ) |
elevatedbutton, iconButtonなどがある