Tutorial and code of Animated AppBar in Flutter. Copy and paste the below code as per your requirements.
appbar_animated: ^0.0.3
import 'package:flutter/material.dart';
import 'package:appbar_animated/appbar_animated.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: DetailPage(),
);
}
}
class DetailPage extends StatelessWidget {
const DetailPage({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: ScaffoldLayoutBuilder(
backgroundColorAppBar:
const ColorBuilder(Colors.transparent, Colors.blue),
textColorAppBar: const ColorBuilder(Colors.white),
appBarBuilder: _appBar,
child: SingleChildScrollView(
child: Stack(
children: [
Image.network(
"https://scontent.fstv5-1.fna.fbcdn.net/v/t1.6435-1/103996008_111874850563152_9134752688804599384_n.jpg?stp=dst-jpg_p320x320&_nc_cat=107&ccb=1-5&_nc_sid=1eb0c7&_nc_ohc=2minhGTtP9EAX8BCgpb&_nc_ht=scontent.fstv5-1.fna&oh=00_AT--Ohzzd5xDD48JnMJkRji2UQhlWUMVu8QjRF-VsgOBYw&oe=627B2114",
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height * 0.4,
fit: BoxFit.cover,
),
Container(
margin: EdgeInsets.only(
top: MediaQuery.of(context).size.height * 0.36,
),
height: 900,
decoration: const BoxDecoration(
borderRadius: BorderRadius.vertical(
top: Radius.circular(40),
),
color: Colors.white,
),
),
],
),
),
),
);
}
Widget _appBar(BuildContext context, ColorAnimated colorAnimated) {
return AppBar(
backgroundColor: colorAnimated.background,
elevation: 0,
title: Center(child: Text(
"AppBar Animate",
style: TextStyle(
color: colorAnimated.color,
),
),),
);
}
}