Bouncing Button In Flutter :

import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> with SingleTickerProviderStateMixin { double _scale; AnimationController _controller; @override void initState() { _controller = AnimationController( vsync: this, duration: Duration( milliseconds: 200, ), lowerBound: 0.0, upperBound: 0.1, )..addListener(() { setState(() {}); }); super.initState(); } @override void dispose() { super.dispose(); _controller.dispose(); } @override Widget build(BuildContext context) { _scale = 1 - _controller.value; return MaterialApp( debugShowCheckedModeBanner: false, home: Scaffold( body: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text('Tap on the Below Button',style: TextStyle(color: Colors.grey[400],fontSize: 20.0),), SizedBox( height: 20.0, ), Center( child: GestureDetector( onTapDown: _onTapDown, onTapUp: _onTapUp, child: Transform.scale( scale: _scale, child: _animatedButtonUI, ), ), ), ], ), ), ); } Widget get _animatedButtonUI => Container( height: 70, width: 200, decoration: BoxDecoration( borderRadius: BorderRadius.circular(100.0), boxShadow: [ BoxShadow( color: Color(0x80000000), blurRadius: 30.0, offset: Offset(0.0, 5.0), ), ], gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Color(0xFF0000FF), Color(0xFFFF3500), ], )), child: Center( child: Text( 'tap', style: TextStyle( fontSize: 30.0, fontWeight: FontWeight.bold, color: Colors.white), ), ), ); void _onTapDown(TapDownDetails details) { _controller.forward(); } void _onTapUp(TapUpDetails details) { _controller.reverse(); } }
The flutter tutorial is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application
For more information about Flutter. visit www.fluttertutorial.in