Skip to content

Instantly share code, notes, and snippets.

@red-star25
Created September 13, 2021 05:48
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 red-star25/7f3f61a4964155b33c5b347b90458639 to your computer and use it in GitHub Desktop.
Save red-star25/7f3f61a4964155b33c5b347b90458639 to your computer and use it in GitHub Desktop.
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