mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-19 00:04:22 +01:00
refactors (#539)
This commit is contained in:
20
lib/data/provider/base.dart
Normal file
20
lib/data/provider/base.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
abstract class Provider<T> {
|
||||
const Provider();
|
||||
|
||||
/// (Re)Load data from store / network / etc.
|
||||
@mustCallSuper
|
||||
FutureOr<void> load() {
|
||||
all.add(this);
|
||||
debugPrint('$runtimeType added');
|
||||
}
|
||||
|
||||
static final all = <Provider>[];
|
||||
|
||||
static Future<void> reload() {
|
||||
return Future.wait(all.map((e) async => await e.load()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user