Skip to content

Commit c9a063c

Browse files
authored
Merge pull request #26 from gonuit/v1.1.0
Version 1.1.0
2 parents 87a1581 + b4fb8f4 commit c9a063c

File tree

119 files changed

+2635
-885
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+2635
-885
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v2
10-
- uses: subosito/flutter-action@v1.4.0
10+
- uses: subosito/flutter-action@v2.3.0
11+
with:
12+
channel: 'stable'
1113
- name: Getting packages
1214
run: flutter pub get
1315
- name: analyzis

CHANGELOG.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1+
## 1.1.0
2+
3+
### Fixes:
4+
5+
- Handle errors thrown from the `onRefresh` method.
6+
7+
### Improvements:
8+
9+
- Updated example app
10+
- Added support for the Android embedding v2
11+
- Added web support
12+
- Added windows support.
13+
- Added a web based demo app (url in the readme file).
14+
- Replaced the deprecated `disallowGlow` method calls with `disallowIndicator`.
15+
- Added `onStateChanged` function argument that allows tracking indicator state changes.
16+
- The `IndicatorStateHelper` class is now deprecated in favor of `onStateChange` function and `IndicatorStateChange` class.
17+
- Initial support for programmatically-controlled indicators has been added. Added the `show`,` hide` and `refresh` methods to the` CustomRefreshIndicatorState` class. It can be accessed via GlobalKey. Take a look at an [programmatically-controlled screen example](/example/lib/screens/programmatically_controlled_indicator_screen.dart).
18+
- Use the `flutter_lints` package for analysis.
19+
- Deprecate `leadingGlowVisible` and `trailingGlowVisible` in favor of `leadingScrollIndicatorVisible` and `trailingScrollIndicatorVisible` arguments.
20+
- Added `reversed` argument that allows you to trigger a refresh indicator from the end of the list.
21+
- Added `envelope` example.
22+
- Added `pull to fetch more` example.
23+
124
## 1.0.0
25+
226
- Stable nullsafety release.
327
- **BREAKING**: opt into null safety
428
- Dart SDK constraints: >=2.12.0-0 <3.0.0
@@ -28,7 +52,7 @@
2852
- Added `wasArmed`, `wasDragging`, `wasLoading`, `wasHiding` and `wasIdle` properties.
2953
- Added `notificationPredicate` property to the `CustomRefreshIndicator` widget.
3054
- Example app:
31-
- Added initial version of `check_mark_indicator`. Example that shows how to make use of `complete` state.
55+
- Added initial version of `check_mark_indicator`. Example that shows how to make use of `complete` state.
3256

3357
## 0.8.0+1
3458

README.md

Lines changed: 48 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
1-
# Flutter Custom Refresh Indicator
1+
![Cover image](/readme/cover.png)
2+
# Custom Refresh Indicator
23

34
[![Tests](https://github.com/gonuit/flutter-custom-refresh-indicator/actions/workflows/test.yml/badge.svg)](https://github.com/gonuit/flutter-custom-refresh-indicator/actions/workflows/test.yml)
45

5-
This package provides `CustomRefreshIndicator` widget that make it easy to implement your own custom refresh indicator. It listens for scroll events from scroll widget passed to child argument and parsing it to data easy for custom refresh indicator implementation. Indicator data is provided by IndicatorController (third argument of builder method). Long story short... thats it!
6+
A flutter package that allows you to easily create a custom refresh indicator widget.
67

7-
If there is something that can be improved, fixed or you just have some great idea feel free to open github issue [HERE](https://github.com/gonuit/flutter-custom-refresh-indicator/issues) or open a pull request [HERE](https://github.com/gonuit/flutter-custom-refresh-indicator/pulls).
8+
### **TLDR; [ONLINE DEMO](https://custom-refresh-indicator.klyta.it)**!
89

9-
If you implemented your own custom refresh indicator with this library and you want it to be mentioned here or provided as an example to the eample app, just open a pull request [HERE](https://github.com/gonuit/flutter-custom-refresh-indicator/pulls).
10-
11-
### Table of Contents
12-
13-
- [Flutter Custom Refresh Indicator](#flutter-custom-refresh-indicator)
14-
- [Table of Contents](#table-of-contents)
15-
- [QUICK START](#quick-start)
16-
- [Examples](#examples)
17-
- [Documentation](#documentation)
18-
- [CustomRefreshIndicator widget](#customrefreshindicator-widget)
19-
- [IndicatorController](#indicatorcontroller)
20-
- [Controller state and value changes.](#controller-state-and-value-changes)
21-
- [`didStateChange`](#didstatechange)
10+
---
2211

2312
# QUICK START
2413

@@ -67,31 +56,55 @@ CustomRefreshIndicator(
6756

6857
Almost all of these examples are available in the example application.
6958

70-
| Plane indicator [[SOURCE CODE](example/lib/indicators/plane_indicator.dart)] | Ice cream indicator [[SOURCE CODE](example/lib/indicators/ice_cream_indicator.dart)] |
71-
| :--------------------------------------------------------------------------: | :----------------------------------------------------------------------------------: |
72-
| ![plane_indicator](readme/plane_indicator.gif) | ![ice_cream_indicator](readme/ice_cream_indicator.gif) |
59+
| Plane indicator [[SOURCE](example/lib/indicators/plane_indicator.dart)][[DEMO](https://custom-refresh-indicator.klyta.it/#/plane)] | Ice cream [[SOURCE](example/lib/indicators/ice_cream_indicator.dart)][[DEMO](https://custom-refresh-indicator.klyta.it/#/ice-cream)] | Warp [[SOURCE](example/lib/indicators/warp_indicator.dart)][[DEMO](https://custom-refresh-indicator.klyta.it/#/warp)] |
60+
| :--------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------: |
61+
| ![plane_indicator](readme/plane_indicator.gif) | ![ice_cream_indicator](readme/ice_cream_indicator.gif) | ![warp_indicator](readme/warp_indicator.gif) |
7362

74-
| Warp indicator [[SOURCE CODE](example/lib/indicators/warp_indicator.dart)] | Envelope indicator |
75-
| :------------------------------------------------------------------------: | :----------------------------------------------: |
76-
| ![warp_indicator](readme/warp_indicator.gif) | ![letter_indicator](readme/letter_indicator.gif) |
63+
| With complete state [[SOURCE](example/lib/indicators/check_mark_indicator.dart)][[DEMO](https://custom-refresh-indicator.klyta.it/#/check-mark)] | Pull to fetch more [[SOURCE](example/lib/indicators/swipe_action.dart)][[DEMO](https://custom-refresh-indicator.klyta.it/#/fetch-more)] | Envelope [[SOURCE](example/lib/indicators/envelope_indicator.dart)][[DEMO](https://custom-refresh-indicator.klyta.it/#/envelope)] |
64+
| :----------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------: |
65+
| ![indicator_with_complete_state](readme/indicator_with_complete_state.gif) | ![fetch_more](readme/fetch_more.gif) | ![Envelope indicator](readme/envelope_indicator.gif) |
7766

78-
| Indicator with complete state [[SOURCE CODE](example/lib/indicators/check_mark_indicator.dart)] | Your indicator |
79-
| :---------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------: |
80-
| ![indicator_with_complete_state](readme/indicator_with_complete_state.gif) | Have you created a fancy refresh indicator? This place is for you. Open PR. |
67+
| Programmatically controlled [[SOURCE](example/lib/screens/programmatically_controlled_indicator_screen.dart)][[DEMO](https://custom-refresh-indicator.klyta.it/#/programmatically-controlled)] | Your indicator | Your indicator |
68+
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------: |
69+
| ![programmatically_controlled](readme/programmatically_controlled.gif) | Have you created a fancy refresh indicator? This place is for you. [Open PR](https://github.com/gonuit/flutter-custom-refresh-indicator/pulls). | Have you created a fancy refresh indicator? This place is for you. [Open PR](https://github.com/gonuit/flutter-custom-refresh-indicator/pulls). |
8170

8271
# Documentation
8372

8473
## CustomRefreshIndicator widget
8574

86-
`CustomRefreshIndicator` widget provides an absolute minimum functionality that allows you to create and set your own custom indicators.
75+
The _CustomRefreshIndicator_ widget provides an absolute minimum functionality that allows you to create and set your own custom indicators.
76+
77+
### onStateChanged
78+
79+
The _onStateChanged_ callback is called everytime _IndicatorState_ has been changed.
80+
This is a convenient place for tracking indicator state changes. For a reference take a look at the [example check mark indicator widget](example/lib/indicators/check_mark_indicator.dart).
81+
82+
Example usage:
83+
84+
```dart
85+
CustomRefreshIndicator(
86+
onRefresh: onRefresh,
87+
// You can track state changes here.
88+
onStateChanged: (IndicatorStateChange change) {
89+
if (change.didChange(from: IndicatorState.dragging, to: IndicatorState.armed)) {
90+
// Do something...
91+
} else if(change.didChange(to: IndicatorState.idle)) {
92+
// Do something...
93+
}
94+
// And so on...
95+
}
96+
// ...
97+
)
98+
```
8799

88100
## IndicatorController
89101

90102
### Controller state and value changes.
91103

92-
The best way to understand how the "CustomRefreshIndicator" widget changes its controller data is to see the example 😉. An example is available in the example application.
104+
The best way to understand how the _CustomRefreshIndicator_ widget changes its controller data is to see the example 😉. An example is available in the example application.
93105

94-
![Controller_Data](readme/controller_data.gif)
106+
[![Controller data example](readme/controller_data.gif)](https://custom-refresh-indicator.klyta.it/#/presentation)
107+
[Online example](https://custom-refresh-indicator.klyta.it/#/presentation)
95108

96109
| state | value | value description | Description |
97110
| ------------ | :------ | :------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -104,50 +117,11 @@ The best way to understand how the "CustomRefreshIndicator" widget changes its c
104117

105118
---
106119

107-
### IndicatorStateHelper
120+
### Support
108121

109-
With the IndicatorStateHelper class, you can easily track indicator's state changes. Example usage can be found [HERE](example/lib/indicators/check_mark_indicator.dart).
110-
111-
All you need to do is to update it's value on every controller update.
112-
```dart
113-
CustomRefreshIndicator(
114-
onRefresh: onRefresh,
115-
child: widget.child,
116-
builder: (
117-
BuildContext context,
118-
Widget child,
119-
IndicatorController controller,
120-
) => AnimatedBuilder(
121-
animation: controller,
122-
builder: (BuildContext context, Widget? _) {
123-
/// Now every state change will be tracked by the helper class.
124-
_helper.update(controller.state);
125-
// ...
126-
```
127-
Then you can simply track state changes:
128-
```dart
129-
/// When the state changes to [idle]
130-
if(_helper.didStateChange(to: IndicatorState.idle)) {
131-
// Code...
132-
}
133-
134-
/// When the state changes from [idle] to [dragging]
135-
if (_helper.didStateChange(
136-
from: IndicatorState.idle,
137-
to: IndicatorState.dragging,
138-
)) {
139-
// Code...
140-
}
141-
142-
/// When the state changes from [idle] to another.
143-
if (_helper.didStateChange(
144-
from: IndicatorState.idle,
145-
)) {
146-
// Code...
147-
}
148-
149-
/// When the state changes.
150-
if (_helper.didStateChange()) {
151-
// Code...
152-
}
153-
```
122+
If you like this package, you have learned something from it, or you just don't know what to do with your money 😅 just buy me a cup of coffee ☕️ and this dose of caffeine will put a smile on my face which in turn will help me improve this package. Also as a thank you, you will be mentioned in this readme as a sponsor.
123+
124+
<div align="center">
125+
<a href="https://www.buymeacoffee.com/kamilklyta" target="_blank"><img height="60px" width="217px" src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
126+
</div>
127+
<p align="center">Have a nice day! 👋</p>

analysis_options.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
linter:
4+
rules:

example/.gitignore

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
# Flutter/Dart/Pub related
2424
**/doc/api/
25+
**/ios/Flutter/.last_build_id
2526
.dart_tool/
2627
.flutter-plugins
2728
.flutter-plugins-dependencies
@@ -33,5 +34,13 @@
3334
# Web related
3435
lib/generated_plugin_registrant.dart
3536

36-
# Exceptions to above rules.
37-
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
37+
# Symbolication related
38+
app.*.symbols
39+
40+
# Obfuscation related
41+
app.*.map.json
42+
43+
# Android Studio will place build artifacts here
44+
/android/app/debug
45+
/android/app/profile
46+
/android/app/release

example/.metadata

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: f139b11009aeb8ed2a3a3aa8b0066e482709dde3
7+
revision: 097d3313d8e2c7f901932d63e537c1acefb87800
88
channel: stable
99

1010
project_type: app

example/README.md

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1 @@
1-
# example
2-
3-
A new Flutter project.
4-
5-
## Getting Started
6-
7-
This project is a starting point for a Flutter application.
8-
9-
A few resources to get you started if this is your first Flutter project:
10-
11-
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12-
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13-
14-
For help getting started with Flutter, view our
15-
[online documentation](https://flutter.dev/docs), which offers tutorials,
16-
samples, guidance on mobile development, and a full API reference.
1+
# Flutter custom refresh indicator example app

example/analysis_options.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
26+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27+
28+
# Additional information about this file can be found at
29+
# https://dart.dev/guides/language/analysis-options

example/android/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ gradle-wrapper.jar
55
/gradlew.bat
66
/local.properties
77
GeneratedPluginRegistrant.java
8+
9+
# Remember to never publicly share your keystore.
10+
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11+
key.properties
12+
**/*.keystore
13+
**/*.jks

example/android/app/build.gradle

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,28 @@ apply plugin: 'kotlin-android'
2626
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2727

2828
android {
29-
compileSdkVersion 28
29+
compileSdkVersion flutter.compileSdkVersion
3030

31-
sourceSets {
32-
main.java.srcDirs += 'src/main/kotlin'
31+
compileOptions {
32+
sourceCompatibility JavaVersion.VERSION_1_8
33+
targetCompatibility JavaVersion.VERSION_1_8
34+
}
35+
36+
kotlinOptions {
37+
jvmTarget = '1.8'
3338
}
3439

35-
lintOptions {
36-
disable 'InvalidPackage'
40+
sourceSets {
41+
main.java.srcDirs += 'src/main/kotlin'
3742
}
3843

3944
defaultConfig {
4045
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
4146
applicationId "com.example.example"
42-
minSdkVersion 16
43-
targetSdkVersion 28
47+
minSdkVersion flutter.minSdkVersion
48+
targetSdkVersion flutter.targetSdkVersion
4449
versionCode flutterVersionCode.toInteger()
4550
versionName flutterVersionName
46-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4751
}
4852

4953
buildTypes {
@@ -61,7 +65,4 @@ flutter {
6165

6266
dependencies {
6367
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64-
testImplementation 'junit:junit:4.12'
65-
androidTestImplementation 'androidx.test:runner:1.1.1'
66-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
6768
}

0 commit comments

Comments
 (0)