diff --git a/lib/Screens/scrollAnimation.dart b/lib/Screens/scrollAnimation.dart new file mode 100644 index 0000000..118c286 --- /dev/null +++ b/lib/Screens/scrollAnimation.dart @@ -0,0 +1,52 @@ +// ignore_for_file: public_member_api_docs, sort_constructors_first +import 'package:flutter/material.dart'; +import 'package:flutter/src/widgets/framework.dart'; +import 'package:flutter/src/widgets/placeholder.dart'; + +class ScrollAnimation extends StatefulWidget { + final String title; + const ScrollAnimation({ + Key? key, + required this.title, + }) : super(key: key); + + @override + State createState() => _ScrollAnimationState(); +} + +class _ScrollAnimationState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.white, + body: CustomScrollView(slivers: [ + SliverAppBar( + leading: const Icon(Icons.menu), + title: const Text("SLIVERAPPBAR"), + expandedHeight: 200, + pinned: true, + backgroundColor: Colors.deepPurpleAccent, + flexibleSpace: FlexibleSpaceBar( + background: Image.network( + "https://static.vecteezy.com/system/resources/thumbnails/008/856/903/small/mountain-road-landscape-illustration-nature-highway-through-trees-and-meadow-cartoon-background-vector.jpg", + fit: BoxFit.cover, + ), + ), + ), + SliverList( + delegate: SliverChildBuilderDelegate((context, index) => Container( + decoration: BoxDecoration( + color: Colors.deepPurple[100], + borderRadius: BorderRadius.circular(10)), + height: 300, + width: 100, + margin: const EdgeInsets.all(10), + child: Center( + child: Text("The index is $index"), + ), + )), + ) + ]), + ); + } +} diff --git a/lib/main.dart b/lib/main.dart index 7705e91..10078ad 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -10,6 +10,7 @@ import 'package:animations/Screens/lecture8.dart'; import 'package:animations/Screens/lecture9.dart'; import 'package:animations/Screens/practice1.dart'; import 'package:animations/Screens/practice2.dart'; +import 'package:animations/Screens/scrollAnimation.dart'; import 'package:flutter/material.dart'; import 'Screens/lecture1.dart'; @@ -53,6 +54,7 @@ class MyApp extends StatelessWidget { title: "Animated Prompt", ), 'practice2/': (context) => const Practice2(title: "Radial Menu"), + 'sliverappbar/': (context) => const ScrollAnimation(title: "Animation"), }, ); } @@ -95,7 +97,8 @@ class _MyHomePageState extends State { Link(link: 'lec7/', title: "CustomPainter & Polygons"), Link(link: 'lec8/', title: "3D Drawer"), Link(link: 'lec9/', title: "Animated Prompt"), - Link(link: 'practice2/', title: "Radial Menu") + Link(link: 'practice2/', title: "Radial Menu"), + Link(link: 'sliverappbar/', title: "SliverAppBar"), ], ), ),