├── LICENSE ├── CHANGELOG.md ├── Ekran Resmi 2019-10-03 11.16.10.png ├── Ekran Resmi 2019-10-03 11.16.21.png ├── Ekran Resmi 2019-10-03 11.16.31.png ├── Ekran Resmi 2019-10-03 11.16.40.png ├── lib ├── src │ ├── constants.dart │ └── animation_transition.dart └── alertify.dart ├── test └── alertify_test.dart ├── .metadata ├── README.md ├── .gitignore ├── pubspec.yaml └── pubspec.lock /LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [0.0.1] - TODO: Add release date. 2 | 3 | * TODO: Describe initial release. 4 | -------------------------------------------------------------------------------- /Ekran Resmi 2019-10-03 11.16.10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/right7ctrl/flutter-alertify/HEAD/Ekran Resmi 2019-10-03 11.16.10.png -------------------------------------------------------------------------------- /Ekran Resmi 2019-10-03 11.16.21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/right7ctrl/flutter-alertify/HEAD/Ekran Resmi 2019-10-03 11.16.21.png -------------------------------------------------------------------------------- /Ekran Resmi 2019-10-03 11.16.31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/right7ctrl/flutter-alertify/HEAD/Ekran Resmi 2019-10-03 11.16.31.png -------------------------------------------------------------------------------- /Ekran Resmi 2019-10-03 11.16.40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/right7ctrl/flutter-alertify/HEAD/Ekran Resmi 2019-10-03 11.16.40.png -------------------------------------------------------------------------------- /lib/src/constants.dart: -------------------------------------------------------------------------------- 1 | enum AlertifyType { success, error, info, warning, none } 2 | 3 | enum AnimationType { leftToRight, rightToLeft, topToBottom, bottomToTop, inToOut, outToIn } -------------------------------------------------------------------------------- /test/alertify_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | 4 | void main() { 5 | test('adds one to input values', () { 6 | //final calculator = Alertify(isDismissible: true, context: context, ); 7 | }); 8 | } 9 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 7a4c33425ddd78c54aba07d86f3f9a4a0051769b 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ✨ Flutter Alertify 2 | 3 | [![pub package]](https://pub.dartlang.org/packages/alertify) 4 | 5 | A collection of beautiful animated dialogs. 6 | 7 | ## 🎖 Installing 8 | 9 | ```yaml 10 | dependencies: 11 | alertify: "^0.0.2" 12 | ``` 13 | 14 | ### ⚡️ Import 15 | 16 | ```dart 17 | import 'package:alertify/alertify.dart'; 18 | ``` 19 | 20 | ## 🎮 How To Use 21 | 22 | ```dart 23 | Alertify( 24 | content: 'Some content here', 25 | context: context, 26 | isDismissible: true, 27 | title: 'Alertify', 28 | alertType: AlertifyType.success, 29 | buttonText: 'OK', 30 | animationType: AnimationType.outToIn, 31 | barrierColor: Colors.black.withOpacity(0.5), 32 | onDismiss: () { 33 | // Your code here 34 | }, 35 | ).show(); 36 | ``` 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | ### ❗️ Note 45 | 46 | - Pull requests are welcomed 47 | 48 | ## ⭐️ License 49 | 50 | MIT License 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # Visual Studio Code related 19 | .vscode/ 20 | 21 | # Flutter/Dart/Pub related 22 | **/doc/api/ 23 | .dart_tool/ 24 | .flutter-plugins 25 | .packages 26 | .pub-cache/ 27 | .pub/ 28 | build/ 29 | 30 | # Android related 31 | **/android/**/gradle-wrapper.jar 32 | **/android/.gradle 33 | **/android/captures/ 34 | **/android/gradlew 35 | **/android/gradlew.bat 36 | **/android/local.properties 37 | **/android/**/GeneratedPluginRegistrant.java 38 | 39 | # iOS/XCode related 40 | **/ios/**/*.mode1v3 41 | **/ios/**/*.mode2v3 42 | **/ios/**/*.moved-aside 43 | **/ios/**/*.pbxuser 44 | **/ios/**/*.perspectivev3 45 | **/ios/**/*sync/ 46 | **/ios/**/.sconsign.dblite 47 | **/ios/**/.tags* 48 | **/ios/**/.vagrant/ 49 | **/ios/**/DerivedData/ 50 | **/ios/**/Icon? 51 | **/ios/**/Pods/ 52 | **/ios/**/.symlinks/ 53 | **/ios/**/profile 54 | **/ios/**/xcuserdata 55 | **/ios/.generated/ 56 | **/ios/Flutter/App.framework 57 | **/ios/Flutter/Flutter.framework 58 | **/ios/Flutter/Generated.xcconfig 59 | **/ios/Flutter/app.flx 60 | **/ios/Flutter/app.zip 61 | **/ios/Flutter/flutter_assets/ 62 | **/ios/ServiceDefinitions.json 63 | **/ios/Runner/GeneratedPluginRegistrant.* 64 | 65 | # Exceptions to above rules. 66 | !**/ios/**/default.mode1v3 67 | !**/ios/**/default.mode2v3 68 | !**/ios/**/default.pbxuser 69 | !**/ios/**/default.perspectivev3 70 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 71 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: alertify 2 | description: A Flutter package that shows beautiful alert with 5 different styles. 3 | version: 0.0.1 4 | author: Murat Aslan 5 | homepage: http://github.com/godlessturtle 6 | 7 | environment: 8 | sdk: ">=2.12.0 <3.0.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | 18 | # For information on the generic Dart part of this file, see the 19 | # following page: https://www.dartlang.org/tools/pub/pubspec 20 | 21 | # The following section is specific to Flutter. 22 | flutter: 23 | 24 | # To add assets to your package, add an assets section, like this: 25 | # assets: 26 | # - images/a_dot_burr.jpeg 27 | # - images/a_dot_ham.jpeg 28 | # 29 | # For details regarding assets in packages, see 30 | # https://flutter.dev/assets-and-images/#from-packages 31 | # 32 | # An image asset can refer to one or more resolution-specific "variants", see 33 | # https://flutter.dev/assets-and-images/#resolution-aware. 34 | 35 | # To add custom fonts to your package, add a fonts section here, 36 | # in this "flutter" section. Each entry in this list should have a 37 | # "family" key with the font family name, and a "fonts" key with a 38 | # list giving the asset and other descriptors for the font. For 39 | # example: 40 | # fonts: 41 | # - family: Schyler 42 | # fonts: 43 | # - asset: fonts/Schyler-Regular.ttf 44 | # - asset: fonts/Schyler-Italic.ttf 45 | # style: italic 46 | # - family: Trajan Pro 47 | # fonts: 48 | # - asset: fonts/TrajanPro.ttf 49 | # - asset: fonts/TrajanPro_Bold.ttf 50 | # weight: 700 51 | # 52 | # For details regarding fonts in packages, see 53 | # https://flutter.dev/custom-fonts/#from-packages 54 | -------------------------------------------------------------------------------- /lib/src/animation_transition.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | class AnimationTransition { 3 | /// Slide animation, from right to left (SlideTransition) 4 | static fromRight(Animation animation, Animation secondaryAnimation, Widget child) { 5 | return SlideTransition( 6 | position: Tween( 7 | begin: const Offset(1.0, 0.0), 8 | end: Offset.zero, 9 | ).animate(animation), 10 | child: child, 11 | ); 12 | } 13 | 14 | /// Slide animation, from left to right (SlideTransition) 15 | static fromLeft(Animation animation, Animation secondaryAnimation, Widget child) { 16 | return SlideTransition( 17 | position: Tween( 18 | begin: const Offset(-1.0, 0.0), 19 | end: Offset.zero, 20 | ).animate(animation), 21 | child: child, 22 | ); 23 | } 24 | 25 | /// Slide animation, from top to bottom (SlideTransition) 26 | static fromTop(Animation animation, Animation secondaryAnimation, Widget child) { 27 | return SlideTransition( 28 | position: Tween( 29 | begin: const Offset(0.0, -1.0), 30 | end: Offset.zero, 31 | ).animate(animation), 32 | child: child, 33 | ); 34 | } 35 | 36 | /// Slide animation, from top to bottom (SlideTransition) 37 | static fromBottom(Animation animation, Animation secondaryAnimation, Widget child) { 38 | return SlideTransition( 39 | position: Tween( 40 | begin: const Offset(0.0, 1.0), 41 | end: Offset.zero, 42 | ).animate(animation), 43 | child: child, 44 | ); 45 | } 46 | 47 | /// Scale animation, from in to out (ScaleTransition) 48 | static grow(Animation animation, Animation secondaryAnimation, Widget child) { 49 | return ScaleTransition( 50 | scale: Tween( 51 | begin: 0.0, 52 | end: 1.0, 53 | ).animate( 54 | CurvedAnimation( 55 | parent: animation, 56 | curve: Interval( 57 | 0.00, 58 | 0.50, 59 | curve: Curves.linear, 60 | ), 61 | ), 62 | ), 63 | child: child, 64 | ); 65 | } 66 | 67 | /// Scale animation, from out to in (ScaleTransition) 68 | static shrink(Animation animation, Animation secondaryAnimation, Widget child) { 69 | return ScaleTransition( 70 | scale: Tween( 71 | begin: 1.2, 72 | end: 1.0, 73 | ).animate( 74 | CurvedAnimation( 75 | parent: animation, 76 | curve: Interval( 77 | 0.50, 78 | 1.00, 79 | curve: Curves.linear, 80 | ), 81 | ), 82 | ), 83 | child: child, 84 | ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.5.0" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.1.0" 25 | charcode: 26 | dependency: transitive 27 | description: 28 | name: charcode 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.2.0" 32 | clock: 33 | dependency: transitive 34 | description: 35 | name: clock 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.1.0" 39 | collection: 40 | dependency: transitive 41 | description: 42 | name: collection 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "1.15.0" 46 | fake_async: 47 | dependency: transitive 48 | description: 49 | name: fake_async 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.2.0" 53 | flutter: 54 | dependency: "direct main" 55 | description: flutter 56 | source: sdk 57 | version: "0.0.0" 58 | flutter_test: 59 | dependency: "direct dev" 60 | description: flutter 61 | source: sdk 62 | version: "0.0.0" 63 | matcher: 64 | dependency: transitive 65 | description: 66 | name: matcher 67 | url: "https://pub.dartlang.org" 68 | source: hosted 69 | version: "0.12.10" 70 | meta: 71 | dependency: transitive 72 | description: 73 | name: meta 74 | url: "https://pub.dartlang.org" 75 | source: hosted 76 | version: "1.3.0" 77 | path: 78 | dependency: transitive 79 | description: 80 | name: path 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "1.8.0" 84 | sky_engine: 85 | dependency: transitive 86 | description: flutter 87 | source: sdk 88 | version: "0.0.99" 89 | source_span: 90 | dependency: transitive 91 | description: 92 | name: source_span 93 | url: "https://pub.dartlang.org" 94 | source: hosted 95 | version: "1.8.0" 96 | stack_trace: 97 | dependency: transitive 98 | description: 99 | name: stack_trace 100 | url: "https://pub.dartlang.org" 101 | source: hosted 102 | version: "1.10.0" 103 | stream_channel: 104 | dependency: transitive 105 | description: 106 | name: stream_channel 107 | url: "https://pub.dartlang.org" 108 | source: hosted 109 | version: "2.1.0" 110 | string_scanner: 111 | dependency: transitive 112 | description: 113 | name: string_scanner 114 | url: "https://pub.dartlang.org" 115 | source: hosted 116 | version: "1.1.0" 117 | term_glyph: 118 | dependency: transitive 119 | description: 120 | name: term_glyph 121 | url: "https://pub.dartlang.org" 122 | source: hosted 123 | version: "1.2.0" 124 | test_api: 125 | dependency: transitive 126 | description: 127 | name: test_api 128 | url: "https://pub.dartlang.org" 129 | source: hosted 130 | version: "0.2.19" 131 | typed_data: 132 | dependency: transitive 133 | description: 134 | name: typed_data 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "1.3.0" 138 | vector_math: 139 | dependency: transitive 140 | description: 141 | name: vector_math 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "2.1.0" 145 | sdks: 146 | dart: ">=2.12.0 <3.0.0" 147 | -------------------------------------------------------------------------------- /lib/alertify.dart: -------------------------------------------------------------------------------- 1 | library alertify; 2 | 3 | import 'package:flutter/material.dart'; 4 | import './src/animation_transition.dart'; 5 | import './src/constants.dart'; 6 | 7 | export './src/constants.dart'; 8 | 9 | class Alertify { 10 | final BuildContext context; 11 | final bool isDismissible; 12 | final AlertifyType alertType; 13 | final String content; 14 | final String title; 15 | final String buttonText; 16 | final AnimationType animationType; 17 | final Color? barrierColor; 18 | final Function? onDismiss; 19 | 20 | Alertify({ 21 | required this.context, 22 | required this.isDismissible, 23 | required this.alertType, 24 | required this.content, 25 | required this.title, 26 | required this.buttonText, 27 | this.animationType = AnimationType.outToIn, 28 | this.barrierColor, 29 | this.onDismiss, 30 | }); 31 | 32 | void show() async { 33 | await showGeneralDialog( 34 | barrierDismissible: isDismissible, 35 | context: context, 36 | pageBuilder: (BuildContext buildContext, Animation animation, Animation secondaryAnimation) { 37 | return _buildDialog(); 38 | }, 39 | barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, 40 | barrierColor: barrierColor == null ? Colors.grey.withOpacity(0.2) : barrierColor!, 41 | transitionDuration: Duration(milliseconds: 250), 42 | transitionBuilder: ( 43 | BuildContext context, 44 | Animation animation, 45 | Animation secondaryAnimation, 46 | Widget child, 47 | ) => 48 | _buildAnimation(animation,secondaryAnimation, child) 49 | ); 50 | if (onDismiss != null) onDismiss!(); 51 | } 52 | 53 | Widget _buildDialog() { 54 | return Dialog( 55 | shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(8.0))), 56 | insetAnimationCurve: Curves.easeInOutCubic, 57 | child: Column( 58 | mainAxisSize: MainAxisSize.min, 59 | mainAxisAlignment: MainAxisAlignment.end, 60 | children: [ 61 | Padding( 62 | padding: const EdgeInsets.only(top: 12, left: 8, right: 8), 63 | child: Column( 64 | mainAxisSize: MainAxisSize.min, 65 | children: [ 66 | _buildIcon(), 67 | SizedBox( 68 | height: 4, 69 | ), 70 | Text( 71 | '${this.title}', 72 | style: TextStyle(fontWeight: FontWeight.bold, fontFamily: 'Muli', fontSize: 22, color: Colors.black87), 73 | ), 74 | SizedBox( 75 | height: 8, 76 | ), 77 | Text( 78 | '${this.content}', 79 | style: TextStyle(fontSize: 16, fontFamily: 'Muli'), 80 | textAlign: TextAlign.center, 81 | ), 82 | SizedBox( 83 | height: 20, 84 | ), 85 | ], 86 | ), 87 | ), 88 | _buildButton() 89 | ], 90 | ), 91 | ); 92 | } 93 | 94 | Widget _buildIcon() { 95 | Widget icon = Icon(Icons.check_circle_outline, size: 72, color: Colors.green); 96 | 97 | switch (this.alertType) { 98 | case AlertifyType.success: 99 | icon = Icon(Icons.check_circle_outline, size: 72, color: Colors.green); 100 | break; 101 | case AlertifyType.error: 102 | icon = Icon(Icons.error_outline, size: 72, color: Colors.redAccent); 103 | break; 104 | case AlertifyType.info: 105 | icon = Icon(Icons.info_outline, size: 72, color: Colors.blue); 106 | break; 107 | case AlertifyType.warning: 108 | icon = Icon(Icons.warning, size: 72, color: Colors.orange); 109 | break; 110 | case AlertifyType.none: 111 | icon = Container(); 112 | break; 113 | default: 114 | icon = Icon(Icons.check_circle_outline, size: 72, color: Colors.green); 115 | break; 116 | } 117 | return icon; 118 | } 119 | 120 | Widget _buildButton() { 121 | Color buttonColor = Colors.green; 122 | switch (this.alertType) { 123 | case AlertifyType.success: 124 | buttonColor = Colors.green; 125 | break; 126 | case AlertifyType.error: 127 | buttonColor = Colors.red; 128 | break; 129 | case AlertifyType.info: 130 | buttonColor = Colors.blue; 131 | break; 132 | case AlertifyType.warning: 133 | buttonColor = Colors.orange; 134 | break; 135 | case AlertifyType.none: 136 | buttonColor = Colors.grey; 137 | break; 138 | } 139 | 140 | return Align( 141 | alignment: Alignment.bottomCenter, 142 | child: Row( 143 | children: [ 144 | Expanded( 145 | child: Material( 146 | borderRadius: BorderRadius.only( 147 | bottomRight: Radius.circular(8), 148 | bottomLeft: Radius.circular(8), 149 | ), 150 | color: buttonColor, 151 | child: InkWell( 152 | borderRadius: BorderRadius.only( 153 | bottomRight: Radius.circular(8), 154 | bottomLeft: Radius.circular(8), 155 | ), 156 | onTap: () { 157 | Navigator.pop(context); 158 | }, 159 | child: Container( 160 | padding: EdgeInsets.only(top: 20, bottom: 20), 161 | child: Center( 162 | child: Text( 163 | '${this.buttonText}', 164 | style: TextStyle(color: Colors.white, fontSize: 18, fontFamily: 'Muli'), 165 | )), 166 | ), 167 | ), 168 | ), 169 | ), 170 | ], 171 | ), 172 | ); 173 | } 174 | 175 | _buildAnimation(Animation animation, Animation secondaryAnimation, Widget child){ 176 | var anim; 177 | switch(this.animationType){ 178 | case AnimationType.leftToRight: 179 | anim = AnimationTransition.fromLeft(animation, secondaryAnimation, child); 180 | break; 181 | case AnimationType.rightToLeft: 182 | anim = AnimationTransition.fromRight(animation, secondaryAnimation, child); 183 | break; 184 | case AnimationType.topToBottom: 185 | anim = AnimationTransition.fromTop(animation, secondaryAnimation, child); 186 | break; 187 | case AnimationType.bottomToTop: 188 | anim = AnimationTransition.fromBottom(animation, secondaryAnimation, child); 189 | break; 190 | case AnimationType.inToOut: 191 | anim = AnimationTransition.grow(animation, secondaryAnimation, child); 192 | break; 193 | case AnimationType.outToIn: 194 | anim = AnimationTransition.shrink(animation, secondaryAnimation, child); 195 | break; 196 | default: 197 | AnimationTransition.grow(animation, secondaryAnimation, child); 198 | break; 199 | } 200 | return anim; 201 | } 202 | 203 | } 204 | 205 | 206 | 207 | --------------------------------------------------------------------------------