Created
September 13, 2021 05:31
-
-
Save red-star25/5f6abc853c457ca6f1593d1d597c36d8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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