Skip to content

Instantly share code, notes, and snippets.

@AlexKenbo
Last active March 22, 2020 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexKenbo/d6acc034db5372100718fe6a328f1317 to your computer and use it in GitHub Desktop.
Save AlexKenbo/d6acc034db5372100718fe6a328f1317 to your computer and use it in GitHub Desktop.
Поведение картинки при bottom / top
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
final config = {
'primaryColor': Colors.grey[200],
};
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primaryColor: config['primaryColor'],
floatingActionButtonTheme: FloatingActionButtonThemeData(
elevation: 35,
highlightElevation: 20,
foregroundColor: Colors.grey[800],
),
accentColor: Colors.grey[200],
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
Animation<double> animation;
AnimationController controller;
@override
void initState() {
super.initState();
controller = AnimationController(
duration: const Duration(seconds: 3),
vsync: this,
reverseDuration: Duration(seconds: 5),
);
animation = Tween<double>(begin: -80, end: -40).animate(controller)
..addListener(() {
setState(() {});
})
..addStatusListener((status) {
if (status == AnimationStatus.completed)
controller.reverse();
else if (status == AnimationStatus.dismissed) controller.forward();
});
controller.forward();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
title: Text(widget.title),
),
body: Stack(
children: <Widget>[
Positioned(
bottom: 0,
//bottom: 350,
//bottom: 200, top: 200,
child: Transform.translate(
offset: Offset(animation.value, 15.0),
child: Image.network(
'https://b7.pngbarn.com/png/297/625/sculpture-figurine-michael-fallen-angel-angel-png-clip-art.png'),
),
),
],
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.ac_unit),
onPressed: () {
setState(() {
});
}),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment