提交 3df86699 authored 作者: 张国庆's avatar 张国庆

增加列表滚动方法

上级 fdb15da7
......@@ -11,4 +11,8 @@
## 1.0.6
* 修改ImageWidget 逻辑 增加缓存方法,加载网络图不使用 任何装饰圆角等
## 1.0.7
* 修改列表因为网络问题无法显示异常提示布局问题
\ No newline at end of file
* 修改列表因为网络问题无法显示异常提示布局问题
## 1.0.8
* 列表控件:BaseConroller 增加滚动到某一位置的方法
* 移除获取设备id的git依赖
* 升级dio版本 5.1.3
import 'package:flutter/material.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';
import 'package:flutter_clx_base/utils/device_utils.dart';
import 'package:flutter_clx_base/widget/normal_dialog.dart';
import 'package:flutter_clx_base_example/sample/base_list_widget_test.dart';
import 'package:flutter_clx_base_example/sample/dio_widget_test.dart';
......@@ -36,19 +35,6 @@ class Sample extends StatelessWidget {
permissionList: [Permission.camera], toSettingTip: "请开启相机权限");
},
text: '动态申请权限'),
GFButton(
fullWidthButton: true,
onPressed: () async {
var deviceModel = await DeviceUtils.getDeviceModel();
var versionName = await DeviceUtils.getVersionName();
var versionCode = await DeviceUtils.getVersionCode();
var deviceSerial = await DeviceUtils.getDeviceSerial();
debugPrint("===== deviceModel = $deviceModel "
" versionName = $versionName "
" versionCode = $versionCode "
" deviceSerial = $deviceSerial");
},
text: '获取设备信息'),
GFButton(
fullWidthButton: true,
onPressed: () => Get.to(const ScrollViewPage()),
......
import 'dart:io';
import 'package:device_id_plugin/device_id_plugin.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter_clx_base/flutter_clx_base.dart';
class DeviceUtils {
//uuid
static getDeviceSerial() async {
DeviceIdPlugin deviceInfo = DeviceIdPlugin();
return await deviceInfo.getDeviceId();
}
static getVersionName() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.version;
}
static getVersionCode() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.buildNumber.toInt();
}
static getDeviceModel() async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
if (Platform.isAndroid) {
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
return androidInfo.model;
} else {
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
return iosInfo.name;
}
}
}
......@@ -67,6 +67,7 @@ class _BaseListWidgetState extends State<BaseListWidget> {
final footer = buildFooter();
return EasyRefresh(
controller: _controller.c,
scrollController: _controller.sc,
refreshOnStart: widget.refreshOnStart,
header: header,
footer: footer,
......@@ -268,6 +269,7 @@ class _BaseListWidgetState extends State<BaseListWidget> {
// 列表控制器
class BaseListController {
late EasyRefreshController _controller;
late ScrollController _scrollController;
_BaseListWidgetState? _listState; // listState
/// Binding with BaseListWidget state
......@@ -280,6 +282,7 @@ class BaseListController {
controlFinishRefresh: true,
controlFinishLoad: true,
);
_scrollController = ScrollController();
}
void finishRefresh() {
......@@ -305,7 +308,27 @@ class BaseListController {
_listState?.notifySingleItem(index, item);
}
// 滚动到某个item index 位置
void scrollToIndex(
int index,
double height, {
bool animated = true,
milliseconds = 300,
}) {
if (!animated) {
_scrollController.jumpTo(index * height);
return;
}
_scrollController.animateTo(
index * height,
duration: Duration(milliseconds: milliseconds),
curve: Curves.easeOut,
);
}
get c => _controller;
get sc => _scrollController;
}
typedef SuccessCallback = Function(List? list);
......
......@@ -13,7 +13,7 @@ dependencies:
flutter_localizations:
sdk: flutter
# dio https://pub.dev/packages/dio
dio: ^5.1.1
dio: ^5.3.1
# 时间选择器 https://pub.dev/packages/flutter_cupertino_datetime_picker
flutter_cupertino_datetime_picker: ^3.0.0
# 键盘工具类 https://pub.dev/packages/keyboard_actions
......@@ -60,9 +60,8 @@ dependencies:
unique_identifier: ^0.3.0
# 设备信息 https://pub.dev/packages/device_info_plus
device_info_plus: ^8.1.0
#获取设备id https://t.clxkj:cn/openSourceLibrary/device_id_plugin:git:
device_id_plugin:
git: https://t.clxkj.cn/openSourceLibrary/device_id_plugin.git
#获取设备id https://t.clxkj:cn/openSourceLibrary/device_id_plugin.git
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论