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),
      ),

 

posted on 2018-10-16 22:47  --LP--  阅读(441)  评论(0)    收藏  举报

导航