zoukankan      html  css  js  c++  java
  • Flutter 在mixin中使用setState

    创建mixin

    import 'package:flutter/material.dart';
    
    mixin JobsMixin<T extends StatefulWidget> on State<T> {
      @override
      void initState() {
        super.initState();
      }
    
      int page = 1;
      bool isLoading = false;
      List<JobData> jobs = [];
    
      Future<List<JobData>> getJobs(String city, [String searchValue = '']) async {
       // ...
      }
    
      loadMoreJobs(String city, [String searchValue = '']) async {
       // ...
      }
    }
    

    使用

    class SearchView extends StatefulWidget {
      @override
      _SearchViewState createState() => _SearchViewState();
    }
    
    class _SearchViewState extends State<SearchView> with JobsMixin<SearchView> {
     // ...
    }
    
    class JobsTab extends StatefulWidget {
      @override
      JobsTabState createState() => JobsTabState();
    }
    
    class JobsTabState extends State<JobsTab> with JobsMixin<JobsTab> {
     // ...
    }
    
  • 相关阅读:
    页面打印
    scala
    IntelliJ Idea 常用快捷键列表
    flume
    spring事务管理方式,aop
    oldboy es和logstash
    elasticsearch视频34季
    elasticsearch视频
    python3
    git
  • 原文地址:https://www.cnblogs.com/ajanuw/p/12751628.html
Copyright © 2011-2022 走看看