Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@red-star25
Created September 13, 2021 05:31
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/5f6abc853c457ca6f1593d1d597c36d8 to your computer and use it in GitHub Desktop.
Save red-star25/5f6abc853c457ca6f1593d1d597c36d8 to your computer and use it in GitHub Desktop.
class MyApp2 extends StatefulWidget {
const MyApp2({Key? key}) : super(key: key);
@override
State<MyApp2> createState() => _MyApp2State();
}
class _MyApp2State extends State<MyApp2> {
bool _isVisible = true;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("SliverOpacity"),
),
body: CustomScrollView(
slivers: [
SliverOpacity(
opacity: _isVisible ? 1.0 : 0.0,
sliver: SliverList(
delegate: SliverChildListDelegate(
[
Container(
height: 50,
color: Colors.green,
child: Center(
child: Text(
"Welcome to Sliver in Flutter Series",
style: TextStyle(fontSize: 20, color: Colors.white),
),
),
),
Container(
height: 50,
color: Colors.orange,
child: Center(
child: Text(
"This is SliverOpacity",
style: TextStyle(fontSize: 25),
),
),
),
],
),
),
),
SliverPadding(
padding: EdgeInsets.only(top: 18),
sliver: SliverToBoxAdapter(
child: FloatingActionButton(
child: Icon(Icons.flip),
onPressed: () {
setState(() {
_isVisible = !_isVisible;
});
},
),
),
)
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment