Reputation: 375
I'm trying to clip two of the appbars corners. I unfortunately can't find anything and I was wondering if there's a work around. Or, possibly if somebody would be kind enough to help me by breaking into Appbar's original code and modifying in some way to clip it.
Upvotes: 3
Views: 3123
Reputation: 51206
For those who don't want to use Master channel
& are on stable channel
- other workaround is using - ClipRRect
Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(kToolbarHeight),
child: ClipRRect(
clipBehavior: Clip.antiAlias,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(20.0),
bottomRight: Radius.circular(20.0)),
child: AppBar(
centerTitle: true,
title: Text(title),
),
),
),
Upvotes: 6
Reputation: 657406
You might look for the shapeBorder
option added with https://github.com/flutter/flutter/pull/21834
const RoundedRectangleBorder roundedRectangleBorder = RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(15.0)));
MaterialApp(
home: AppBar(
leading: const Text('L'),
title: const Text('No Scaffold'),
shape: roundedRectangleBorder,
actions: const <Widget>[Text('A1'), Text('A2')],
),
),
It seems this is only available in master
yet and not shown in the docs.
flutter channel master
flutter doctor
Upvotes: 4