Created
September 13, 2021 05:48
-
-
Save red-star25/7f3f61a4964155b33c5b347b90458639 to your computer and use it in GitHub Desktop.
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
class MyApp extends StatefulWidget { | |
@override | |
State<MyApp> createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
bool _visible = true; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: CustomScrollView( | |
slivers: <Widget>[ | |
SliverAnimatedOpacity( | |
opacity: _visible ? 1.0 : 0.0, | |
duration: const Duration(milliseconds: 500), | |
sliver: SliverToBoxAdapter( | |
child: Image.network( | |
"https://1gew6o3qn6vx9kp3s42ge0y1-wpengine.netdna-ssl.com/wp-content/uploads/prod/2020/10/HERO-ART-microsoft_azure_1920x1000_nologo.jpg", | |
width: double.infinity, | |
height: 300, | |
fit: BoxFit.cover, | |
), | |
)), | |
SliverPadding( | |
padding: EdgeInsets.only(top: 18), | |
sliver: SliverToBoxAdapter( | |
child: FloatingActionButton( | |
onPressed: () { | |
setState(() { | |
_visible = !_visible; | |
}); | |
}, | |
tooltip: 'Toggle opacity', | |
child: const Icon(Icons.flip), | |
)), | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment