flutter-animation
Flutter: Ticker must be disposed before calling super.dispose()
Override dispose method and dispose the AnimationController instance. @override dispose() { animationController.dispose(); // you need this super.dispose(); }
Error: RenderBox was not laid out, Failed assertion: line 1940 pos 12: ‘hasSize’
This happens when ListView has no constrained height which makes it gets an infinite height, you can solve this using two solutions add shrinkWrap: true as a parameter which will tell the ListView to use a little space as possible, Wrap your ListView with a constrained height widget, such as a SizedBox or a Container, … Read more
How to change speed of a hero animation in flutter
To modify the transition speed, you’ll have to adjust the PageRoute transition duration (as already pointed out by @diegoveloper). If you wanna keep the default transition, you can create a class implementing MaterialPageRoute. If you already have your own transition or want to create one you can use the PageRouteBuilder to easily build your own. … Read more
Flutter – Animate change on height when child of container renders
In the end I just had to use AnimatedSize. It replicates exactly the animation that I want. AnimatedSize( vsync: this, duration: Duration(milliseconds: 150), curve: Curves.fastOutSlowIn, child: Container( child: Container( child: !_isExpanded ? null : FadeTransition(opacity: animationFade, child: widget.child), ), ), );
TextField with animated hint / label
It turns out to be very simple. InputDecoration has a labelText parameter, which does what I wanted. E.g. TextField(decoration: InputDecoration(labelText: ‘Full name’)),
flutter: animate transition to named route
You need to use onGenerateRoute in your MaterialApp widget. onGenerateRoute: (settings) { if (settings.name == “/someRoute”) { return PageRouteBuilder( settings: settings, // Pass this to make popUntil(), pushNamedAndRemoveUntil(), works pageBuilder: (_, __, ___) => SomePage(), transitionsBuilder: (_, a, __, c) => FadeTransition(opacity: a, child: c) ); } // Unknown route return MaterialPageRoute(builder: (_) => UnknownPage()); … Read more
how to display animated gif in flutter?
Place your gif in your images folder of your project and mention it in pubspec.yaml file,just like you do for images. Image.asset( “images/loading.gif”, height: 125.0, width: 125.0, ),
How to rotate an image using Flutter AnimationController and Transform?
Full example (null safe): Press “go” makes the star icon spin until you press “stop”. import ‘package:flutter/material.dart’; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin … Read more
Horizontally scrollable cards with Snap effect in flutter
Use PageView and ListView: import ‘package:flutter/material.dart’; main() => runApp(MaterialApp(home: MyHomePage())); class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(‘Carousel in vertical scrollable’), ), body: ListView.builder( padding: EdgeInsets.symmetric(vertical: 16.0), itemBuilder: (BuildContext context, int index) { if(index % 2 == 0) { return _buildCarousel(context, index ~/ 2); } else { … Read more