Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:ScrollController not attached to any scroll views #37

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ List<Page> getRoutes(){
),
Page("PullRefresh", const PullRefreshRoute(), padding: false),

Page("Quick Scrollbar", const QuickScrollbarRoute(),padding: false),
Page("Quick Scrollbar", QuickScrollbarRoute(),padding: false),
Page("Swiper", const SwiperRoute()),
Page("Swiper Style", const SwiperStyleRoute()),
Page("ScaleView", const ScaleViewRoute(), padding: false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class GradientCircularProgressRouteState
void initState() {
super.initState();
_animationController =
AnimationController(vsync: this, duration: Duration(seconds: 3));
AnimationController(vsync: this, duration: const Duration(seconds: 3));
_animationController.forward();
}

Expand Down
9 changes: 8 additions & 1 deletion package_src/lib/example/routes/quick_scrollbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ import 'package:flutter/material.dart';
import 'package:flukit/flukit.dart';

class QuickScrollbarRoute extends StatelessWidget {
const QuickScrollbarRoute({Key? key}) : super(key: key);
QuickScrollbarRoute({Key? key}) : super(key: key);

///If you are using a ListView, GridView,
/// or any other scrollable widget, you need to create a ScrollController
/// and pass it to the controller parameter of the QuickScrollbar widget:
final ScrollController _scrollController = ScrollController();

@override
Widget build(BuildContext context) {
return QuickScrollbar(
controller: _scrollController,
child: ListView.builder(
controller: _scrollController,
itemCount: 1000,
// Specifying an [itemExtent] or [prototypeItem] is more efficient
// than letting the children determine their own extent when use QuickScrollbar.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flukit/flukit.dart';
import '../common/index.dart';

Expand Down
4 changes: 3 additions & 1 deletion package_src/lib/example/routes/turn_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import 'package:flutter/material.dart';
import 'package:flukit/flukit.dart';

class TurnBoxRoute extends StatefulWidget {
const TurnBoxRoute({Key? key}) : super(key: key);

@override
_TurnBoxRouteState createState() => new _TurnBoxRouteState();
_TurnBoxRouteState createState() => _TurnBoxRouteState();
}

class _TurnBoxRouteState extends State<TurnBoxRoute> {
Expand Down
2 changes: 1 addition & 1 deletion package_src/lib/src/extra_info_constraints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ class ExtraInfoBoxConstraints<T> extends BoxConstraints {

@override
int get hashCode {
return hashValues(super.hashCode, extra);
return Object.hash(super.hashCode, extra);
}
}
2 changes: 1 addition & 1 deletion package_src/lib/src/gradient_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class GradientButton extends StatelessWidget {
style: const TextStyle(fontWeight: FontWeight.bold),
child: Center(
child: DefaultTextStyle(
style: theme.textTheme.button!.copyWith(
style: theme.textTheme.labelLarge!.copyWith(
color: disabled
? disabledTextColor ?? Colors.black38
: textColor ?? Colors.white,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class _GradientCircularProgressPainter extends CustomPainter {
this.radius,
this.total = 2 * pi,
required this.colors,
this.stops,
this.value,
this.fullColor,
});
Expand All @@ -117,7 +116,6 @@ class _GradientCircularProgressPainter extends CustomPainter {
final List<Color> colors;
final double total;
final double? radius;
final List<double>? stops;
final Color? fullColor;

@override
Expand Down Expand Up @@ -158,7 +156,6 @@ class _GradientCircularProgressPainter extends CustomPainter {
startAngle: 0.0,
endAngle: _value,
colors: colors,
stops: stops,
).createShader(rect);
canvas.drawArc(rect, _start, _value, false, paint);
}
Expand All @@ -172,7 +169,6 @@ class _GradientCircularProgressPainter extends CustomPainter {
old.radius != radius ||
old.value != value ||
old.fullColor != fullColor ||
old.colors.toString() != colors.toString() ||
old.stops.toString() != stops.toString();
old.colors.toString() != colors.toString();
}
}
13 changes: 7 additions & 6 deletions package_src/lib/src/quick_scrollbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ class _QuickScrollBarState extends State<QuickScrollbar>
late AnimationController _animationController;
late Animation<double> _animation;
Timer? _timer;
late ScrollController _scrollController;

@override
void initState() {
super.initState();

_scrollController = widget.controller!;

_animationController = AnimationController(
vsync: this,
duration: const Duration(milliseconds: 200),
Expand All @@ -70,16 +74,13 @@ class _QuickScrollBarState extends State<QuickScrollbar>
@override
void dispose() {
_animationController.dispose();
_scrollController.dispose();
_timer?.cancel();
super.dispose();
}

@override
Widget build(BuildContext context) {
ScrollController scrollController = widget.controller ??
PrimaryScrollController.of(context) ??
ScrollController();

Widget stack = Stack(
children: <Widget>[
RepaintBoundary(
Expand Down Expand Up @@ -110,13 +111,13 @@ class _QuickScrollBarState extends State<QuickScrollbar>
),
onVerticalDragStart: (details) => _timer?.cancel(),
onVerticalDragUpdate: (DragUpdateDetails details) {
final position = scrollController.position;
final position = _scrollController.position;

double pixels = (position.extentBefore + position.extentAfter) *
details.delta.dy /
(position.extentInside - _barHeight);
pixels += position.pixels;
scrollController.jumpTo(pixels.clamp(
_scrollController.jumpTo(pixels.clamp(
0.0,
position.maxScrollExtent,
));
Expand Down
4 changes: 2 additions & 2 deletions package_src/lib/src/sliver_header_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SliverHeaderDelegate extends SliverPersistentHeaderDelegate {
double get minExtent => minHeight;

@override
bool shouldRebuild(SliverHeaderDelegate old) {
return old.maxExtent != maxExtent || old.minExtent != minExtent;
bool shouldRebuild(SliverHeaderDelegate oldDelegate) {
return oldDelegate.maxExtent != maxExtent || oldDelegate.minExtent != minExtent;
}
}
4 changes: 1 addition & 3 deletions package_src/lib/src/watermark.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'dart:ui' as ui;
import 'dart:math' as math;
Expand Down Expand Up @@ -79,7 +77,7 @@ class _WaterMarkState extends State<WaterMark> {
// 绘制单元水印并获取其大小
final size = widget.painter.paintUnit(
canvas,
MediaQueryData.fromWindow(ui.window).devicePixelRatio,
MediaQueryData.fromView(ui.window).devicePixelRatio,
);
final picture = recorder.endRecording();
//将单元水印导为图片并缓存起来
Expand Down
17 changes: 17 additions & 0 deletions windows/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
flutter/ephemeral/

# Visual Studio user-specific files.
*.suo
*.user
*.userosscache
*.sln.docstates

# Visual Studio build-related files.
x64/
x86/

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
102 changes: 102 additions & 0 deletions windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Project-level configuration.
cmake_minimum_required(VERSION 3.14)
project(flukit LANGUAGES CXX)

# The name of the executable created for the application. Change this to change
# the on-disk name of your application.
set(BINARY_NAME "flukit")

# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW)

# Define build configuration option.
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(IS_MULTICONFIG)
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
CACHE STRING "" FORCE)
else()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Debug" CACHE
STRING "Flutter build mode" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Profile" "Release")
endif()
endif()
# Define settings for the Profile build mode.
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")

# Use Unicode for all projects.
add_definitions(-DUNICODE -D_UNICODE)

# Compilation settings that should be applied to most targets.
#
# Be cautious about adding new options here, as plugins use this function by
# default. In most cases, you should add new options to specific targets instead
# of modifying this function.
function(APPLY_STANDARD_SETTINGS TARGET)
target_compile_features(${TARGET} PUBLIC cxx_std_17)
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
target_compile_options(${TARGET} PRIVATE /EHsc)
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
endfunction()

# Flutter library and tool build rules.
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
add_subdirectory(${FLUTTER_MANAGED_DIR})

# Application build; see runner/CMakeLists.txt.
add_subdirectory("runner")


# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)


# === Installation ===
# Support files are copied into place next to the executable, so that it can
# run in place. This is done instead of making a separate bundle (as on Linux)
# so that building and running from within Visual Studio will work.
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
# Make the "install" step default, as it's required to run.
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
endif()

set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")

install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
COMPONENT Runtime)

install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
COMPONENT Runtime)

install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)

if(PLUGIN_BUNDLED_LIBRARIES)
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
endif()

# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
install(CODE "
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
" COMPONENT Runtime)
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)

# Install the AOT library on non-Debug builds only.
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
CONFIGURATIONS Profile;Release
COMPONENT Runtime)
Loading