Last active
May 5, 2022 16:20
-
-
Save valterh4ck3r/c809d64d9c023c9ab087b03320a8baf0 to your computer and use it in GitHub Desktop.
Revisions
-
valterh4ck3r revised this gist
May 5, 2022 . 1 changed file with 42 additions and 38 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; class AnimatedButton extends StatefulWidget { bool Function() validate; Function() onPressed; bool isLoading; @@ -24,44 +23,49 @@ class AnimatedButton extends StatefulWidget { class _AnimatedButtonState extends State<AnimatedButton> { @override Widget build(BuildContext context) { return Center( child: AnimatedContainer( duration: const Duration(milliseconds: 400), curve: Curves.linear, width: widget.isLoading || widget.isSuccess ? 55 : MediaQuery.of(context).size.width, height: widget.isLoading || widget.isSuccess ? 55 : 50, child: ElevatedButton( style: ButtonStyle( backgroundColor: widget.isSuccess ? MaterialStateProperty.all(Colors.green) : MaterialStateProperty.all(Theme.of(context).primaryColor), shape: MaterialStateProperty.all<RoundedRectangleBorder>( RoundedRectangleBorder( borderRadius: BorderRadius.circular( widget.isLoading || widget.isSuccess ? 50 : 14), ))), onPressed: () { if (widget.isLoading || widget.isSuccess) return; widget.onPressed.call(); }, child: widget.isSuccess ? const Icon( Icons.check, size: 25, color: Colors.white, ) : widget.isLoading ? const SizedBox( width: 25, height: 25, child: CircularProgressIndicator( color: Colors.white, )) : const Text( "Enviar", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16), )), ), ); } } -
valterh4ck3r created this gist
Mar 19, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ import 'package:flutter/material.dart'; class AnimatedButton extends StatefulWidget { bool Function() validate; Function() onPressed; bool isLoading; bool isSuccess; String text; AnimatedButton( {Key? key, required this.validate, required this.onPressed, required this.isLoading, required this.isSuccess, required this.text}) : super(key: key); @override _AnimatedButtonState createState() => _AnimatedButtonState(); } class _AnimatedButtonState extends State<AnimatedButton> { @override Widget build(BuildContext context) { return AnimatedContainer( duration: const Duration(milliseconds: 400), curve: Curves.linear, width: widget.isLoading || widget.isSuccess ? 55 : MediaQuery.of(context).size.width, height: widget.isLoading || widget.isSuccess ? 55 : 50, child: ElevatedButton( style: ButtonStyle( backgroundColor: widget.isSuccess ? MaterialStateProperty.all(Colors.green) : MaterialStateProperty.all(Theme.of(context).primaryColor), shape: MaterialStateProperty.all<RoundedRectangleBorder>( RoundedRectangleBorder( borderRadius: BorderRadius.circular( widget.isLoading || widget.isSuccess ? 50 : 14), ))), onPressed: widget.onPressed, child: widget.isSuccess ? const Icon( Icons.check, size: 25, color: Colors.white, ) : widget.isLoading ? const SizedBox( width: 25, height: 25, child: CircularProgressIndicator( color: Colors.white, )) : const Text( "Enviar", style: TextStyle( color: Colors.white, fontWeight: FontWeight.bold, fontSize: 16), )), ); } }