'Simple Flutter Slide Left Animation?
I want some nested UI widgets to slide into a Column, from left (off screen) to right (on screen). The Column has an Expanded with a "flex: 4" and a Container... Basically, I want to animate this interior Container, with all that it contains.)
Can someone show me some dead simple code, or a link to code, that does this animation? My googling is returning some very big and complicated examples. I need a "Hello World," not 500 lines of code!
(I come from the HTML/CSS/Javascript world, and I know using Jquery I could pull this with pretty lightweight code. Maybe I got spoiled? Though I am loving Flutter!)
Solution 1:[1]
Here is sample code for horizontal scroll with bouncing physics
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
const title = 'Horizontal List';
return MaterialApp(
title: title,
home: Scaffold(
appBar: AppBar(
title: const Text(title),
),
body: Container(
margin: const EdgeInsets.symmetric(vertical: 20.0),
height: 200.0,
child: ListView(
physics: const BouncingScrollPhysics(),
// This next line does the trick.
scrollDirection: Axis.horizontal,
children: <Widget>[
Container(
width: 160.0,
color: Colors.red,
),
Container(
width: 160.0,
color: Colors.blue,
),
Container(
width: 160.0,
color: Colors.green,
),
Container(
width: 160.0,
color: Colors.yellow,
),
Container(
width: 160.0,
color: Colors.orange,
),
],
),
),
),
);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Behzod Faiziev |
