

import 'package:flutter/material.dart';
import 'package:netrain_flutter_app/jishuaishuai/MVVMDemo/ViewDemo.dart';

class fifthDemo extends StatefulWidget {
  // fifthDemo({Key key}) : super(key: key);

  @override
  _fifthDemoState createState() {
    return _fifthDemoState();
  }
}

class _fifthDemoState extends State<fifthDemo> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("第五个页面"),
      ),
      body: fifthListViewDemo(),
    );
  }
}

class fifthListViewDemo extends StatefulWidget {
  // fifthListViewDemo({Key key}) : super(key: key);

  @override
  _fifthListViewDemoState createState() {
    return _fifthListViewDemoState();
  }
}

class _fifthListViewDemoState extends State<fifthListViewDemo> {

  List<int>listArr = List();

  @override
  void initState() {
    super.initState();
    for(var i = 0; i<100 ;i++){
      listArr.add(i);
    }
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scrollbar(
    child: RefreshIndicator(
      child: ListView.builder(itemBuilder:(BuildContext context, int index){
        if (index == 2) {

        }
        return Container(
          child: Flex(
            direction: Axis.vertical,
            children: [
              Text(listArr[index].toString()),
              ElevatedButton(onPressed: (){
                Navigator.of(context).push(MaterialPageRoute(
                    builder: (context){
                     return MVVMViewDemo();
                    }
                ));
              }, child:Text("点击进入MVVM设计模式页面") ),
              Container(
                width: 100,
                height: 300,
                color: Colors.orange,
              )

            ],
          ),
        );
      }),
      onRefresh: _onRefresh,
    ),
    );

  }

  Future _onRefresh() async {
    await Future.delayed(
      Duration(seconds: 2),
          () {
        print("object");
      },
    );
    return "";
  }
}