flutter 在状态类里拿到 (class SnacksPage extends StatefulWidget )SnacksPage 里的变量
import 'package:flutter/material.dart'; class SnacksPage extends StatefulWidget { SnacksPage({Key key, this.title}) : super(key: key); final String title; @override _SnacksPageState createState() => new _SnacksPageState(); } class _SnacksPageState extends State<SnacksPage> { int _counter = 0; void _incrementCounter() { setState(() { _counter++; }); } @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text(widget.title), ),
浙公网安备 33010602011771号