From d56b1eb7d114f237963ca4841f8e68057dc619fc Mon Sep 17 00:00:00 2001 From: Hazni Gulec Date: Wed, 20 Sep 2023 12:44:42 +0300 Subject: [PATCH 1/2] added reverseAnimationDuration --- example/android/build.gradle | 2 +- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Runner.xcodeproj/project.pbxproj | 13 +- .../contents.xcworkspacedata | 2 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- example/ios/Runner/Info.plist | 4 + example/lib/main.dart | 26 +- .../Flutter/GeneratedPluginRegistrant.swift | 2 - example/pubspec.lock | 239 +++++------------- example/pubspec.yaml | 7 +- lib/src/animated_button.dart | 34 ++- pubspec.lock | 112 ++++---- 12 files changed, 181 insertions(+), 264 deletions(-) diff --git a/example/android/build.gradle b/example/android/build.gradle index 8c40237..f87c952 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f7..4f8d4d2 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 11.0 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index d3a59b6..6782b23 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -156,7 +156,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -200,10 +200,12 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( @@ -253,6 +255,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -340,7 +343,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -422,7 +425,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -471,7 +474,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a1..919434a 100644 --- a/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140c..b52b2e6 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/example/lib/main.dart b/example/lib/main.dart index 956f5b5..ad250b3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_animated_button/flutter_animated_button.dart'; -import 'package:google_fonts/google_fonts.dart'; void main() { runApp(MyApp()); @@ -36,11 +35,6 @@ class _AnimatedButtonDemoState extends State { @override Widget build(BuildContext context) { - var submitTextStyle = GoogleFonts.nunito( - fontSize: 28, - letterSpacing: 5, - color: Colors.white, - fontWeight: FontWeight.w300); return Scaffold( backgroundColor: Colors.black, body: Center( @@ -52,12 +46,12 @@ class _AnimatedButtonDemoState extends State { onPress: () {}, onChanges: (change) {}, height: 70, + reverseAnimation: Duration(milliseconds: 500), width: 200, text: 'SUBMIT', isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.LEFT_TOP_ROUNDER, - textStyle: submitTextStyle, backgroundColor: Colors.black, selectedBackgroundColor: Colors.lightGreen, borderColor: Colors.white, @@ -71,13 +65,12 @@ class _AnimatedButtonDemoState extends State { height: 70, width: 200, text: 'SUBMIT', + reverseAnimation: Duration(milliseconds: 500), gradient: LinearGradient(colors: [Colors.red, Colors.orange]), - selectedGradientColor: LinearGradient( - colors: [Colors.pinkAccent, Colors.purpleAccent]), + selectedGradientColor: LinearGradient(colors: [Colors.pinkAccent, Colors.purpleAccent]), isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.LEFT_CENTER_ROUNDER, - textStyle: submitTextStyle, borderColor: Colors.white, borderWidth: 1, ), @@ -91,8 +84,8 @@ class _AnimatedButtonDemoState extends State { text: 'SUBMIT', isReverse: true, selectedTextColor: Colors.black, + reverseAnimation: Duration(milliseconds: 500), transitionType: TransitionType.LEFT_BOTTOM_ROUNDER, - textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -104,11 +97,11 @@ class _AnimatedButtonDemoState extends State { onPress: () {}, height: 70, width: 200, - text: 'SUBMIT', + text: 'SUBMItT', + reverseAnimation: Duration(milliseconds: 5000), isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.RIGHT_TOP_ROUNDER, - textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -124,7 +117,6 @@ class _AnimatedButtonDemoState extends State { isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.RIGHT_CENTER_ROUNDER, - textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -140,7 +132,6 @@ class _AnimatedButtonDemoState extends State { isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.RIGHT_BOTTOM_ROUNDER, - textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -156,7 +147,6 @@ class _AnimatedButtonDemoState extends State { isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.TOP_CENTER_ROUNDER, - textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -172,7 +162,6 @@ class _AnimatedButtonDemoState extends State { isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.BOTTOM_CENTER_ROUNDER, - textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -188,7 +177,6 @@ class _AnimatedButtonDemoState extends State { isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.CENTER_ROUNDER, - textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -203,8 +191,8 @@ class _AnimatedButtonDemoState extends State { text: 'SUBMIT', isReverse: true, selectedTextColor: Colors.black, - textStyle: submitTextStyle, backgroundColor: Colors.black, + onPress: () {}, ), ], ), diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift index 0d56f51..cccf817 100644 --- a/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,8 +5,6 @@ import FlutterMacOS import Foundation -import path_provider_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) } diff --git a/example/pubspec.lock b/example/pubspec.lock index 3314808..2e24174 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,86 +5,58 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.8.2" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.16.0" - convert: - dependency: transitive - description: - name: convert - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "1.17.2" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.dev" source: hosted - version: "0.1.3" + version: "1.0.6" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" - ffi: - dependency: transitive - description: - name: ffi - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.1.2" - file: - dependency: transitive - description: - name: file - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.2" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -96,131 +68,60 @@ packages: path: ".." relative: true source: path - version: "2.0.0" + version: "2.0.2" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" - google_fonts: - dependency: "direct main" - description: - name: google_fonts - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - http: - dependency: transitive - description: - name: http - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.2" - http_parser: - dependency: transitive - description: - name: http_parser - url: "https://pub.dartlang.org" - source: hosted - version: "3.1.4" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" source: hosted - version: "0.12.11" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - url: "https://pub.dartlang.org" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" source: hosted - version: "0.1.4" + version: "0.5.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.7.0" + version: "1.9.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.1" - path_provider: - dependency: transitive - description: - name: path_provider - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.28" - path_provider_linux: - dependency: transitive - description: - name: path_provider_linux - url: "https://pub.dartlang.org" - source: hosted - version: "0.0.1+2" - path_provider_macos: - dependency: transitive - description: - name: path_provider_macos - url: "https://pub.dartlang.org" - source: hosted - version: "0.0.4+8" - path_provider_platform_interface: - dependency: transitive - description: - name: path_provider_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" - path_provider_windows: - dependency: transitive - description: - name: path_provider_windows - url: "https://pub.dartlang.org" - source: hosted - version: "0.0.5" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.1" + version: "1.8.3" percent_indicator: dependency: "direct main" description: name: percent_indicator - url: "https://pub.dartlang.org" + sha256: c37099ad833a883c9d71782321cb65c3a848c21b6939b6185f0ff6640d05814c + url: "https://pub.dev" source: hosted - version: "2.1.9+1" + version: "4.2.3" platform: dependency: "direct main" description: name: platform - url: "https://pub.dartlang.org" + sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + url: "https://pub.dev" source: hosted version: "3.1.0" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" - process: - dependency: transitive - description: - name: process - url: "https://pub.dartlang.org" - source: hosted - version: "4.2.3" sky_engine: dependency: transitive description: flutter @@ -230,72 +131,66 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.9" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "0.6.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.2" - win32: - dependency: transitive - description: - name: win32 - url: "https://pub.dartlang.org" + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "2.2.5" - xdg_directories: + version: "2.1.4" + web: dependency: transitive description: - name: xdg_directories - url: "https://pub.dartlang.org" + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" source: hosted - version: "0.1.2" + version: "0.1.4-beta" sdks: - dart: ">=2.17.0-0 <3.0.0" - flutter: ">=1.20.0" + dart: ">=3.1.0-185.0.dev <4.0.0" + flutter: ">=2.12.0" diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 1d66ed1..890e62a 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -18,19 +18,18 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: - sdk: ">=2.7.0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: sdk: flutter - google_fonts: 1.1.0 - percent_indicator: ^2.1.7+2 + percent_indicator: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^0.1.3 + cupertino_icons: platform: ^3.1.0 flutter_animated_button: path: ../ diff --git a/lib/src/animated_button.dart b/lib/src/animated_button.dart index 14605aa..ffd115f 100644 --- a/lib/src/animated_button.dart +++ b/lib/src/animated_button.dart @@ -31,6 +31,10 @@ class AnimatedButton extends StatefulWidget { /// by Default is [false] final bool isReverse; + /// You can enter Duration for the animation to be retriggered after a certain time + /// after the button is pressed + /// + final Duration? reverseAnimation; // An optional maximum number of lines for the text to span, wrapping if necessary. /// If the text exceeds the given number of lines, it will be truncated according /// to [overflow]. @@ -142,6 +146,7 @@ class AnimatedButton extends StatefulWidget { this.selectedBackgroundColor = Colors.white, this.backgroundColor = Colors.white60, this.isReverse = false, + this.reverseAnimation, this.textMaxLine = 1, this.textOverflow = TextOverflow.clip, this.textAlignment = Alignment.center, @@ -168,6 +173,7 @@ class AnimatedButton extends StatefulWidget { required this.text, required this.onPress, this.isReverse = false, + this.reverseAnimation, this.height = 50, this.width = double.infinity, this.stripTransitionType = StripTransitionType.LEFT_TO_RIGHT, @@ -197,8 +203,7 @@ class AnimatedButton extends StatefulWidget { _AnimatedButtonState createState() => _AnimatedButtonState(); } -class _AnimatedButtonState extends State - with TickerProviderStateMixin { +class _AnimatedButtonState extends State with TickerProviderStateMixin { late AnimationController _controller; late Animation slideAnimation; Animation? scaleAnimation; @@ -211,8 +216,7 @@ class _AnimatedButtonState extends State @override void initState() { super.initState(); - _controller = - AnimationController(duration: widget.animationDuration, vsync: this); + _controller = AnimationController(duration: widget.animationDuration, vsync: this); if (widget.isStrip) { if (widget.stripTransitionType == StripTransitionType.RIGHT_TO_LEFT || widget.stripTransitionType == StripTransitionType.BOTTOM_TO_TOP) { @@ -233,8 +237,8 @@ class _AnimatedButtonState extends State } } - slideAnimation = Tween(begin: slideBegin, end: slideEnd).animate( - CurvedAnimation(parent: _controller, curve: Curves.easeInOutCubic)); + slideAnimation = Tween(begin: slideBegin, end: slideEnd) + .animate(CurvedAnimation(parent: _controller, curve: Curves.easeInOutCubic)); widget.isSelected ? _controller.forward() : _controller.reverse(); } @@ -299,8 +303,7 @@ class _AnimatedButtonState extends State decoration: BoxDecoration( gradient: widget.selectedGradientColor, color: widget.selectedBackgroundColor, - border: Border.all( - color: widget.borderColor, width: widget.borderWidth), + border: Border.all(color: widget.borderColor, width: widget.borderWidth), borderRadius: BorderRadius.circular(widget.borderRadius), ), child: widget.isStrip @@ -318,8 +321,7 @@ class _AnimatedButtonState extends State builder: (context, child) { return ClipPath( clipper: widget.isStrip - ? RectStripClipper( - slideAnimation.value, widget.stripTransitionType) + ? RectStripClipper(slideAnimation.value, widget.stripTransitionType) : RectClipper(slideAnimation.value, widget.transitionType), child: child, ); @@ -345,7 +347,7 @@ class _AnimatedButtonState extends State animationController?.dispose(); } - onPressed() { + onPressed() async { if (widget.animatedOn == AnimatedOn.onTap) { if (widget.isReverse && _controller.isCompleted) { _controller.reverse(); @@ -356,6 +358,16 @@ class _AnimatedButtonState extends State } } widget.onPress?.call(); + if (widget.reverseAnimation != null) { + await Future.delayed(widget.reverseAnimation!); + if (widget.isReverse && _controller.isCompleted) { + _controller.reverse(); + widget.onChanges?.call(false); + } else { + _controller.forward(); + widget.onChanges?.call(true); + } + } } onHover(bool enter) { diff --git a/pubspec.lock b/pubspec.lock index 58937f9..5ccaba6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,51 +5,50 @@ packages: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.11.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.1" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" source: hosted - version: "1.1.0-nullsafety.3" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0-nullsafety.1" + version: "1.3.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.1" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + url: "https://pub.dev" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.17.2" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.3.1" flutter: dependency: "direct main" description: flutter @@ -64,23 +63,34 @@ packages: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.5.0" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + url: "https://pub.dev" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.9.1" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.3" sky_engine: dependency: transitive description: flutter @@ -90,58 +100,66 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.1" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.1" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + url: "https://pub.dev" source: hosted - version: "0.2.19-nullsafety.2" - typed_data: + version: "0.6.0" + vector_math: dependency: transitive description: - name: typed_data - url: "https://pub.dartlang.org" + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" source: hosted - version: "1.3.0-nullsafety.3" - vector_math: + version: "2.1.4" + web: dependency: transitive description: - name: vector_math - url: "https://pub.dartlang.org" + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" source: hosted - version: "2.1.0-nullsafety.3" + version: "0.1.4-beta" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.17.0 <2.0.0" + dart: ">=3.1.0-185.0.dev <4.0.0" + flutter: ">=1.17.0" From 1b2f3ef6fec04afada09d7aac0541cca16b95151 Mon Sep 17 00:00:00 2001 From: Hazni Gulec Date: Wed, 20 Sep 2023 12:49:05 +0300 Subject: [PATCH 2/2] back to original --- example/lib/main.dart | 19 ++++++++++++++----- pubspec.lock | 2 +- pubspec.yaml | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index ad250b3..af36e1f 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_animated_button/flutter_animated_button.dart'; +import 'package:google_fonts/google_fonts.dart'; void main() { runApp(MyApp()); @@ -35,6 +36,8 @@ class _AnimatedButtonDemoState extends State { @override Widget build(BuildContext context) { + var submitTextStyle = + GoogleFonts.nunito(fontSize: 28, letterSpacing: 5, color: Colors.white, fontWeight: FontWeight.w300); return Scaffold( backgroundColor: Colors.black, body: Center( @@ -46,12 +49,12 @@ class _AnimatedButtonDemoState extends State { onPress: () {}, onChanges: (change) {}, height: 70, - reverseAnimation: Duration(milliseconds: 500), width: 200, text: 'SUBMIT', isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.LEFT_TOP_ROUNDER, + textStyle: submitTextStyle, backgroundColor: Colors.black, selectedBackgroundColor: Colors.lightGreen, borderColor: Colors.white, @@ -65,12 +68,12 @@ class _AnimatedButtonDemoState extends State { height: 70, width: 200, text: 'SUBMIT', - reverseAnimation: Duration(milliseconds: 500), gradient: LinearGradient(colors: [Colors.red, Colors.orange]), selectedGradientColor: LinearGradient(colors: [Colors.pinkAccent, Colors.purpleAccent]), isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.LEFT_CENTER_ROUNDER, + textStyle: submitTextStyle, borderColor: Colors.white, borderWidth: 1, ), @@ -84,8 +87,8 @@ class _AnimatedButtonDemoState extends State { text: 'SUBMIT', isReverse: true, selectedTextColor: Colors.black, - reverseAnimation: Duration(milliseconds: 500), transitionType: TransitionType.LEFT_BOTTOM_ROUNDER, + textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -97,11 +100,11 @@ class _AnimatedButtonDemoState extends State { onPress: () {}, height: 70, width: 200, - text: 'SUBMItT', - reverseAnimation: Duration(milliseconds: 5000), + text: 'SUBMIT', isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.RIGHT_TOP_ROUNDER, + textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -117,6 +120,7 @@ class _AnimatedButtonDemoState extends State { isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.RIGHT_CENTER_ROUNDER, + textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -132,6 +136,7 @@ class _AnimatedButtonDemoState extends State { isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.RIGHT_BOTTOM_ROUNDER, + textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -147,6 +152,7 @@ class _AnimatedButtonDemoState extends State { isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.TOP_CENTER_ROUNDER, + textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -162,6 +168,7 @@ class _AnimatedButtonDemoState extends State { isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.BOTTOM_CENTER_ROUNDER, + textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -177,6 +184,7 @@ class _AnimatedButtonDemoState extends State { isReverse: true, selectedTextColor: Colors.black, transitionType: TransitionType.CENTER_ROUNDER, + textStyle: submitTextStyle, backgroundColor: Colors.black, borderColor: Colors.white, borderWidth: 1, @@ -191,6 +199,7 @@ class _AnimatedButtonDemoState extends State { text: 'SUBMIT', isReverse: true, selectedTextColor: Colors.black, + textStyle: submitTextStyle, backgroundColor: Colors.black, onPress: () {}, ), diff --git a/pubspec.lock b/pubspec.lock index 5ccaba6..9577426 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -50,7 +50,7 @@ packages: source: hosted version: "1.3.1" flutter: - dependency: "direct main" + dependency: transitive description: flutter source: sdk version: "0.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 7788f7a..d9d3a70 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,6 +8,7 @@ environment: flutter: ">=1.17.0" dependencies: +google_fonts: flutter: sdk: flutter