| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import 'dart:async';
- import 'package:flutter/material.dart';
- import 'package:provide/provide.dart';
- import 'package:rxdart/rxdart.dart';
- /// normal click event
- abstract class Presenter {
- /// 处理点击事件
- ///
- /// 可根据 [action] 进行区分 ,[action] 应是不可变的量
- void onClick(String action);
- }
- /// ListView Item Click
- abstract class ItemPresenter<T> {
- /// 处理列表点击事件
- ///
- /// 可根据 [action] 进行区分 ,[action] 应是不可变的量
- void onItemClick(String action, T item);
- }
- /// BaseProvide
- class BaseProvide with ChangeNotifier {
- CompositeSubscription compositeSubscription = CompositeSubscription();
- /// add [StreamSubscription] to [compositeSubscription]
- ///
- /// 在 [dispose]的时候能进行取消
- addSubscription(StreamSubscription subscription){
- compositeSubscription.add(subscription);
- }
- @override
- void dispose() {
- super.dispose();
- compositeSubscription.dispose();
- }
- }
- /// page的基类 [PageProvideNode]
- ///
- /// 隐藏了 [ProviderNode] 的调用
- abstract class PageProvideNode extends StatelessWidget {
- /// The values made available to the [child].
- final Providers mProviders = Providers();
- Widget buildContent(BuildContext context);
- @override
- Widget build(BuildContext context) {
- return ProviderNode(
- providers: mProviders,
- child: buildContent(context),
- );
- }
- }
|