Created
January 4, 2021 22:28
-
-
Save mingsai/290ed7d0a5fccd5ca5ac48543aaedf8c to your computer and use it in GitHub Desktop.
Flutter vertical curtain raising animation
This file contains 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 characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp(home: CurtainScaffold()); | |
} | |
} | |
class CurtainScaffold extends StatefulWidget { | |
@override | |
_CurtainScaffoldState createState() => _CurtainScaffoldState(); | |
} | |
class _CurtainScaffoldState extends State<CurtainScaffold> { | |
double curtain = 0.0; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
backgroundColor: Colors.black, | |
body: SafeArea( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
Slider( | |
onChanged: (double val) { | |
setState(() { | |
this.curtain = val; | |
}); | |
}, | |
value: curtain, | |
min: 0.0, | |
max: 1.0, | |
), | |
ClipRect( | |
child: Align( | |
alignment: Alignment.bottomCenter, | |
heightFactor: curtain, | |
child: Image.network( | |
'https://upload.wikimedia.org/wikipedia/commons/b/bd/Dts_news_bill_gates_wikipedia.JPG'), | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment