fliggy-mobile / frefresh Goto Github PK
View Code? Open in Web Editor NEWHelp you to build pull-down refresh and pull-up loading in the simplest way.
License: Other
Help you to build pull-down refresh and pull-up loading in the simplest way.
License: Other
如题,在一些非常简单的场景中我不希望声明和控制controller,只希望由一个简单的回调方法来加载数据并自动停止,就像RefreshIndicator那样
import 'dart:async';
import 'package:flutter/material.dart' hide NestedScrollView;
import 'package:frefresh/frefresh.dart';
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
import '../commons/index.dart' show Util;
class CustomScrollViewPage extends StatefulWidget {
@override
_CustomScrollViewPageState createState() => _CustomScrollViewPageState();
}
class _CustomScrollViewPageState extends State<CustomScrollViewPage> {
FRefreshController _fRefreshController;
List<String> _tabs = ['111', '222', '333', '444', '555', '666'];
String _appID = '';
@override
void initState() {
super.initState();
_getAppID();
_fRefreshController = FRefreshController();
_fRefreshController.setOnStateChangedCallback((state) {
print('state = $state');
});
}
_getAppID() async {
_appID = await Util.appID();
setState(() {});
}
@override
Widget build(BuildContext context) {
final double statusBarHeight = MediaQuery.of(context).padding.top;
double pinnedHeaderHeight = statusBarHeight + kToolbarHeight;
List<Widget> _silverBuilder(BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverToBoxAdapter(
child: Container(
height: 368.0,
color: Colors.yellow,
child: Center(
child: Text(
_appID,
style: TextStyle(color: Colors.red),
),
),
),
),
];
}
return FRefresh(
controller: _fRefreshController,
header: Image.asset(
"assets/icon_refresh4.gif",
height: 80.0,
fit: BoxFit.fitHeight,
),
headerHeight: 80.0,
onRefresh: () {
Timer(Duration(milliseconds: 3000), () {
_fRefreshController.finishRefresh();
});
},
child: Scaffold(
body: Stack(
children: <Widget>[
DefaultTabController(
length: _tabs.length, // This is the number of tabs.
child: NestedScrollView(
headerSliverBuilder: _silverBuilder,
pinnedHeaderSliverHeightBuilder: () {
return pinnedHeaderHeight;
},
body: Column(
children: <Widget>[
TabBar(
labelColor: Theme.of(context).accentColor,
unselectedLabelColor: Theme.of(context).hintColor,
indicatorSize: TabBarIndicatorSize.label,
isScrollable: true,
tabs:
_tabs.map((String name) => Tab(text: name)).toList(),
),
Divider(
height: 0,
),
Expanded(
child: TabBarView(
children: _tabs.map((String name) {
return MediaQuery.removePadding(
context: context,
removeTop: true,
removeBottom: false,
child: ListView.separated(
key: PageStorageKey<String>(name),
itemCount: 100,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text('title: ' + index.toString()));
},
separatorBuilder:
(BuildContext context, int index) {
return Divider(
height: 0,
);
},
),
);
}).toList(),
),
)
],
),
),
),
Positioned(
left: 0,
top: 0,
right: 0,
child: Container(
padding: EdgeInsets.only(top: statusBarHeight),
color: Theme.of(context).accentColor,
height: pinnedHeaderHeight,
child: Container(
height: kToolbarHeight,
color: Colors.red,
child: Row(
children: <Widget>[
Text('data'),
Icon(Icons.home),
],
),
),
),
),
],
),
),
);
}
}
[✓] Flutter (Channel stable, v1.17.3, on Mac OS X 10.15.5 19F101, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.45.1)
[✓] Connected device (1 available)
• No issues found!
直接渲染和FutureBuilder渲染长列表数据都是一样的掉帧
换成 flutter_easyrefresh就不卡了,一样的数据和逻辑
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 1.21.0-5.0.pre, on Mac OS X 10.15.4 19E287, locale zh-Hans)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit
https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.48.0)
[✓] Connected device (1 available)
❯ dart --version
Dart SDK version: 2.9.0-21.0.dev.flutter-9dca49e71e (be) (Fri Jul 17 13:26:08 2020 +0000) on "macos_x64"
frefresh: ^1.1.0
补充一点 真机上卡顿一样的存在和明显,而真机flutter_easyrefresh
已经变成一条直线了,流畅丝滑
[✓] Flutter (Channel stable, v1.17.3, on Mac OS X 10.15.5 19F101, locale
zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Android Studio (version 3.6)
pull up or pull down,Overall refresh is not supported,
如題:NotificationListener
设备从竖屏切换至横屏报错
Another exception was thrown: RenderBox.size accessed beyond the scope of resize, layout, or permitted parent access. RenderBox can always access its own size, otherwise, the only object that is allowed to read RenderBox.size is its parent, if they have said they will. It you hit this assert trying to access a child's size, pass "parentUsesSize: true" to that child's layout().
════════ Exception caught by rendering library ═════════════════════════════════
RenderBox.size accessed beyond the scope of resize, layout, or permitted parent access. RenderBox can always access its own size, otherwise, the only object that is allowed to read RenderBox.size is its parent, if they have said they will. It you hit this assert trying to access a child's size, pass "parentUsesSize: true" to that child's layout().
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1709 pos 13: 'debugDoingThisResize || debugDoingThisLayout ||
(RenderObject.debugActiveLayout == parent && _size._canBeUsedByParent)'
The relevant error-causing widget was
FRefresh
希望可以尽快支持 null-safety 版本
取消star了
代码设计上child包装了一个CustomScrollView,其实是不可取的。 如果是Scrollable的widget,按照scrollable的逻辑处理,如果不是则再考虑包装到CustomScrollView里。不过仔细阅读了源代码也给我自己设计下拉刷新上拉加载提供了很大帮助。Thanks.
一个页面有TabController,里面有一个listview。在第一个tab内下拉刷新之后到另一个tab内再次刷新的时候,出现No FRefresh is bound!
希望可以加入淘宝二楼功能
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.