mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 07:44:26 +01:00
结构初始化
This commit is contained in:
22
lib/data/provider/app.dart
Normal file
22
lib/data/provider/app.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:toolbox/core/provider_base.dart';
|
||||
import 'package:toolbox/data/service/app.dart';
|
||||
|
||||
class AppProvider extends BusyProvider {
|
||||
Map? _notify;
|
||||
Map? get notify => _notify;
|
||||
int? _newestBuild;
|
||||
int? get newestBuild => _newestBuild;
|
||||
|
||||
Future<void> loadData() async {
|
||||
setBusyState(true);
|
||||
final service = AppService();
|
||||
_notify = await service.getNotify();
|
||||
setBusyState(false);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setNewestBuild(int build) {
|
||||
_newestBuild = build;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
65
lib/data/provider/debug.dart
Normal file
65
lib/data/provider/debug.dart
Normal file
@@ -0,0 +1,65 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class DebugProvider extends ChangeNotifier {
|
||||
final widgets = <Widget>[];
|
||||
|
||||
void addText(String text) {
|
||||
_addText(text);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _addText(String text) {
|
||||
_addWidget(Text(text));
|
||||
}
|
||||
|
||||
void addError(Object error) {
|
||||
_addError(error);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _addError(Object error) {
|
||||
_addMultiline(error, Colors.red);
|
||||
}
|
||||
|
||||
void addMultiline(Object data, [Color color = Colors.blue]) {
|
||||
_addMultiline(data, color);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _addMultiline(Object data, [Color color = Colors.blue]) {
|
||||
final widget = Text(
|
||||
'$data',
|
||||
style: TextStyle(
|
||||
color: color,
|
||||
),
|
||||
);
|
||||
_addWidget(SingleChildScrollView(
|
||||
child: widget,
|
||||
scrollDirection: Axis.horizontal,
|
||||
));
|
||||
}
|
||||
|
||||
void addWidget(Widget widget) {
|
||||
_addWidget(widget);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void _addWidget(Widget widget) {
|
||||
final outlined = Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.green,
|
||||
),
|
||||
),
|
||||
child: widget,
|
||||
);
|
||||
|
||||
widgets.add(outlined);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
widgets.clear();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user