How to make curved bottom appBar in Flutter?
5,460
Solution 1
I think it is not the appBar
's shape.
I think it's the white container below the green-colored appBar
that has the rounded corner.
Here's the example:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.lightBlueAccent,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
padding: EdgeInsets.only(
top: 60.0, left: 30.0, right: 30.0, bottom: 30.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Hello',
style: TextStyle(
color: Colors.white,
fontSize: 50.0,
fontWeight: FontWeight.w700,
),
),
],
),
),
Expanded(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0),
),
),
),
),
],
),
);
}
}
Solution 2
I built something similar with a CustomScrollView and SliverPersistenHeader, to get the curved effect your header can have a maxExtent and minExtent. When not scrolled the header height will show the curve otherwise when you start scrolling it will also shrink to a set height.
You can check out this tutorial from around 2:50 to get an idea of how to implement the header and then design your background containers accordingly.
Author by
ialyzaafan
Iam a mobile application developer and a frontend developer Love to learn new technologies Experience : Flutter , reactJs , IOS
Updated on December 22, 2022Comments
-
ialyzaafan over 1 year