plugin_framework, test install plugin

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-05-10 18:58:45 +08:00
parent b06fad0e43
commit 4ee0fd9676
12 changed files with 271 additions and 166 deletions

View File

@@ -22,16 +22,18 @@ class PluginModel with ChangeNotifier {
final List<UiType> uiList = [];
final Map<String, String> opts = {};
void add(UiType ui) {
void add(List<UiType> uiList) {
bool found = false;
for (int i = 0; i < uiList.length; i++) {
if (uiList[i].key == ui.key) {
uiList[i] = ui;
found = true;
for (var ui in uiList) {
for (int i = 0; i < this.uiList.length; i++) {
if (this.uiList[i].key == ui.key) {
this.uiList[i] = ui;
found = true;
}
}
if (!found) {
this.uiList.add(ui);
}
}
if (!found) {
uiList.add(ui);
}
notifyListeners();
}
@@ -44,12 +46,12 @@ class PluginModel with ChangeNotifier {
class LocationModel with ChangeNotifier {
final Map<PluginId, PluginModel> pluginModels = {};
void add(PluginId id, UiType ui) {
void add(PluginId id, List<UiType> uiList) {
if (pluginModels[id] != null) {
pluginModels[id]!.add(ui);
pluginModels[id]!.add(uiList);
} else {
var model = PluginModel();
model.add(ui);
model.add(uiList);
pluginModels[id] = model;
notifyListeners();
}
@@ -68,11 +70,11 @@ class LocationModel with ChangeNotifier {
bool get isEmpty => pluginModels.isEmpty;
}
void addLocationUi(String location, PluginId id, UiType ui) {
void addLocationUi(String location, PluginId id, List<UiType> uiList) {
if (_locationModels[location] == null) {
_locationModels[location] = LocationModel();
}
_locationModels[location]?.add(id, ui);
_locationModels[location]?.add(id, uiList);
}
LocationModel? getLocationModel(String location) => _locationModels[location];