像往常一样,我们使用dp for Android和pt(point)for ios作为度量单位.
1磅= 1/72英寸
1 dp = 1/160英寸
但我不知道颤动的测量单位是什么
例:
SizedBox(高度:16.0)
要么
TextStyle(fontSize:23.0)
它只是一个双数,多少dp或pt等于1.0(颤动)?它是如何计算的?
我做了一个功能来发布一个主题的通知。它在正常情况下运行良好,然后我将其放入计算功能并希望它可以在后台发布通知。但它不起作用。这是我的代码:
void onSendMessageInBackGround(String message) {
Future.delayed(Duration(milliseconds: 3000)).then((_) async{
Client client = Client();
final requestHeader = {'Authorization': 'key=my_server_key', 'Content-Type': 'application/json'};
var data = json.encode({
'notification': {
'body': 'tester',
'title': '$message',
},
'priority': 'high',
'data': {
'click_action': 'FLUTTER_NOTIFICATION_CLICK',
'dataMessage': 'test',
'time': "${DateTime.now()}",
},
'to': '/topics/uat'
});
await client.post('https://fcm.googleapis.com/fcm/send', headers: requestHeader, body: data);
});
}
Run Code Online (Sandbox Code Playgroud)
调用计算:
compute(onSendMessageInBackGround, 'abc');
Run Code Online (Sandbox Code Playgroud)
注意:正如库所说,我已将 onSendMessageInBackGround 函数放在我的应用程序的顶层
是不是缺少了什么?或者我们不能这样做?
我正在按照教程building-a-social-network-with-flutter在 flutter 中编写一个基本的 loadmore 列表视图:
定义一个 typedef 函数作为列表视图适配器,它为每个项目返回一个小部件:
typedef Widget WidgetAdapter<T>(T t);
Run Code Online (Sandbox Code Playgroud)我的基本列表视图小部件:
class LoadingListView<T> extends StatefulWidget{
...
final WidgetAdapter<T> widgetAdapter;
...
@override createState() => new _LoadingListViewState();
}
Run Code Online (Sandbox Code Playgroud)我的基本列表视图状态:
class _LoadingListViewState<T> extends State<LoadingListView<T>> {
...
List<T> objects = [];
...
Widget itemBuilder(BuildContext context, int index) {
return widget.widgetAdapter != null ? widget.widgetAdapter(objects[index]);
: new Container();
}
}
Run Code Online (Sandbox Code Playgroud)在我的 UserList 小部件中:
@override
Widget build(BuildContext context) {
Widget w;
w = new LoadingListView<User>(
request, widgetAdapter: adapt, pageSize: widget.pageSize, pageThreshold: widget.pageThreshold); …Run Code Online (Sandbox Code Playgroud)