flutter 局部文字更新

 

import 'package:flutter/material.dart';

void main() {
  print("5hahahha");
  runApp(new MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    print("4hahahha");
    return new MaterialApp(
      home: new TestWidget(),
    );
  }
}

class TestWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    print("3hahahha");
    return _TestWidgetState();
  }
}

class _TestWidgetState extends State<TestWidget> {
  int _count=0;
  @override
  Widget build(BuildContext context) {
    print("0hahahha");
    return Center(
      child: Column(
        children: <Widget>[
          Text((_count).toString()),
          RaisedButton(
            onPressed: () {
              setState(() {
                print("1hahahha");
                _count++;
              });
            },
          )
        ],
      ),
    );
  }
}

 

上一篇:并发编程@线程基础知识回顾


下一篇:java接口的多继承