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

Format code #12

Merged
merged 6 commits into from
Sep 4, 2023
Merged
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
29 changes: 29 additions & 0 deletions .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Flutter

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
channel: 'stable'

- name: Install dependencies
run: flutter pub get

- name: Analyze project source
run: dart analyze

- name: Install pana
run: dart pub global activate pana

- name: Analyze project source with pana
run: pana
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Flutter Scroll Shadow

## [1.2.3] - 2023-09-04
#### [@RichiB20](https://github.com/RichiB20)/[@rickypid](https://github.com/rickypid)
- Format code, add GitHub Actions

## [1.2.2] - 2023-08-31
#### [@darkstarx](https://github.com/darkstarx)
- Get rid of the need for the scroll controller - (#8)
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_scroll_shadow_example
description: A demonstration of the ScrollShadow widget for a scrollable child.
version: 1.2.2
version: 1.2.3
publish_to: 'none'

environment:
Expand Down
75 changes: 34 additions & 41 deletions lib/src/scroll_shadow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ library flutter_scroll_shadow;

import 'package:flutter/material.dart';


/// Wraps a scrollable child in `ScrollShadow`s.
class ScrollShadow extends StatefulWidget
{
class ScrollShadow extends StatefulWidget {
/// Wraps a scrollable child in `ScrollShadow`s.
const ScrollShadow({
super.key,
Expand Down Expand Up @@ -60,28 +58,23 @@ class ScrollShadow extends StatefulWidget
State<ScrollShadow> createState() => _ScrollShadowState();
}


class _ScrollShadowState extends State<ScrollShadow>
{
class _ScrollShadowState extends State<ScrollShadow> {
bool get reachedStart => _reachedStart;

set reachedStart(final bool value)
{
set reachedStart(final bool value) {
if (_reachedStart == value) return;
setState(() => _reachedStart = value);
}

bool get reachedEnd => _reachedEnd;

set reachedEnd(final bool value)
{
set reachedEnd(final bool value) {
if (_reachedEnd == value) return;
setState(() => _reachedEnd = value);
}

@override
Widget build(final BuildContext context)
{
Widget build(final BuildContext context) {
LinearGradient? startGradient, endGradient;
switch (_axis) {
case null:
Expand All @@ -90,23 +83,23 @@ class _ScrollShadowState extends State<ScrollShadow>
startGradient = LinearGradient(
begin: Alignment.centerRight,
end: Alignment.centerLeft,
colors: [ widget.color.withOpacity(0.0), widget.color ],
colors: [widget.color.withOpacity(0.0), widget.color],
);
endGradient = LinearGradient(
begin: Alignment.centerRight,
end: Alignment.centerLeft,
colors: [ widget.color, widget.color.withOpacity(0.0) ],
colors: [widget.color, widget.color.withOpacity(0.0)],
);
case Axis.vertical:
startGradient = LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [ widget.color.withOpacity(0.0), widget.color ],
colors: [widget.color.withOpacity(0.0), widget.color],
);
endGradient = LinearGradient(
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
colors: [ widget.color, widget.color.withOpacity(0.0) ],
colors: [widget.color, widget.color.withOpacity(0.0)],
);
}
var startShadow = _getShadow(startGradient);
Expand Down Expand Up @@ -138,35 +131,36 @@ class _ScrollShadowState extends State<ScrollShadow>
]);
}

Widget? _getShadow(final LinearGradient? gradient)
{
return gradient == null ? null : Container(
width: widget.size,
height: widget.size,
decoration: BoxDecoration(gradient: gradient)
);
Widget? _getShadow(final LinearGradient? gradient) {
return gradient == null
? null
: Container(
width: widget.size,
height: widget.size,
decoration: BoxDecoration(gradient: gradient));
}

Widget? _getAnimatedShadow(final Widget? shadow, final bool reachedEdge)
{
return shadow == null ? null : AnimatedOpacity(
opacity: reachedEdge ? 0.0 : 1.0,
duration: widget.duration,
curve: reachedEdge ? widget.fadeOutCurve : widget.fadeInCurve,
child: shadow,
);
Widget? _getAnimatedShadow(final Widget? shadow, final bool reachedEdge) {
return shadow == null
? null
: AnimatedOpacity(
opacity: reachedEdge ? 0.0 : 1.0,
duration: widget.duration,
curve: reachedEdge ? widget.fadeOutCurve : widget.fadeInCurve,
child: shadow,
);
}

Widget? _getNoninteractive(final Widget? shadow)
{
return shadow == null ? null : IgnorePointer(
ignoring: true,
child: shadow,
);
Widget? _getNoninteractive(final Widget? shadow) {
return shadow == null
? null
: IgnorePointer(
ignoring: true,
child: shadow,
);
}

Widget? _getPositioned(final Widget? shadow, final bool start)
{
Widget? _getPositioned(final Widget? shadow, final bool start) {
if (shadow == null) return null;
switch (_axis) {
case null:
Expand All @@ -190,8 +184,7 @@ class _ScrollShadowState extends State<ScrollShadow>
}
}

bool _handleNewMetrics(final ScrollMetrics metrics)
{
bool _handleNewMetrics(final ScrollMetrics metrics) {
if (_axis != metrics.axis) {
setState(() => _axis = metrics.axis);
}
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_scroll_shadow
description: ScrollShadow adds shadows to a scrollable child. Supports
ScrollController and vertical or horizontal orientation.
version: 1.2.2
version: 1.2.3
repository: https://github.com/rickypid/flutter_scroll_shadow
issue_tracker: https://github.com/rickypid/flutter_scroll_shadow/issues
homepage: https://github.com/rickypid/flutter_scroll_shadow
Expand All @@ -19,4 +19,4 @@ dev_dependencies:
flutter_test:
sdk: flutter

flutter: null
flutter: null