Closed galaxybruce closed 4 years ago
用闲鱼flutterboost框架时,EmptyView显示不出来。同样的代码在demo中就可以。 下面是测试代码: `import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
/// 空视图示例 class EmptyPage extends StatefulWidget { @override EmptyPageState createState() { return EmptyPageState(); } } class EmptyPageState extends State { // 总数 int _count = 0; EasyRefreshController _controller; ScrollController _scrollController;
@override void initState() { super.initState(); _controller = EasyRefreshController(); _scrollController = ScrollController(); }
@override void dispose() { super.dispose(); _controller.dispose(); _scrollController.dispose(); }
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('emptyWidget'), backgroundColor: Colors.white, ), body: EasyRefresh.custom( firstRefresh: true, controller: _controller, scrollController: _scrollController, firstRefreshWidget: Container( width: double.infinity, height: double.infinity, child: Center( child: SizedBox( height: 200.0, width: 300.0, child: Card( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( child: Text('loading'), ) ], ), ), ) ), ), emptyWidget: _count == 0 ? Container( height: double.infinity, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( 'noData', style: TextStyle(fontSize: 16.0, color: Colors.grey[400]), ), Expanded(child: SizedBox(), flex: 3,), ], ), ): null, slivers: [ SliverList( delegate: SliverChildBuilderDelegate( (context, index) { return null; }, childCount: _count, ), ), ], onRefresh: () async { setState(() { _count = 0; });
_controller.resetLoadState(); _controller.finishRefresh(); }, onLoad: () async { await Future.delayed(Duration(seconds: 2), () { setState(() { _count += 0; }); }); }, ), );
} }`
empty_widget.dart中size是0.
flutterboost目前可能存在部分不稳定情况,你可以搜集问题到flutterboost反馈,或者通过计算高度实现emptyView
用闲鱼flutterboost框架时,EmptyView显示不出来。同样的代码在demo中就可以。 下面是测试代码: `import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
/// 空视图示例 class EmptyPage extends StatefulWidget { @override EmptyPageState createState() { return EmptyPageState(); } } class EmptyPageState extends State {
// 总数
int _count = 0;
EasyRefreshController _controller;
ScrollController _scrollController;
@override void initState() { super.initState(); _controller = EasyRefreshController(); _scrollController = ScrollController(); }
@override void dispose() { super.dispose(); _controller.dispose(); _scrollController.dispose(); }
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('emptyWidget'), backgroundColor: Colors.white, ), body: EasyRefresh.custom( firstRefresh: true, controller: _controller, scrollController: _scrollController, firstRefreshWidget: Container( width: double.infinity, height: double.infinity, child: Center( child: SizedBox( height: 200.0, width: 300.0, child: Card( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children:[
Container(
child:
Text('loading'),
)
],
),
),
)
),
),
emptyWidget: _count == 0 ? Container(
height: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'noData',
style: TextStyle(fontSize: 16.0, color: Colors.grey[400]),
),
Expanded(child: SizedBox(), flex: 3,),
],
),
): null,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return null;
},
childCount: _count,
),
),
],
onRefresh: () async {
setState(() {
_count = 0;
});
} }`