Flutter rounded appbar with color line - flutter

i have a rounded Appbar with a color line. Here is a Screenshot.
I want the color line to follow the rounding. Is this possible, since I have not found anything about it?
This is my code so far:
class LoginPage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"Test",
style: TextStyle(fontStyle: FontStyle.italic),
),
centerTitle: true,
elevation: 10,
backgroundColor: Colors.cyan[900],
bottom: PreferredSize(
preferredSize: Size.fromHeight(4.0),
child: SizedBox(
height: 5,
child: Container(
color: Colors.orange,
),
)),
shadowColor: Colors.cyan[900],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30),
),
),
),
);
}
}

you can create your own custom Appbar by implementing PreferredSizeWidget
and the curved border can be achieved through nesting two containers where the space between them (padding in this case represents the stroke width) and the color of the parent container represents the color of the border.
here is full example
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
const CustomAppBar({Key key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Container(
height: 80.0,
padding: EdgeInsets.only(bottom: 6.0),
decoration: BoxDecoration(
color: Colors.amber,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(16.0),
bottomRight: Radius.circular(16.0),
),
),
child: Container(
height: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 8.0),
decoration: BoxDecoration(
color: AppTheme.primaryColor,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(16.0),
bottomRight: Radius.circular(16.0),
),
boxShadow: [BoxShadow(color: AppTheme.primaryColor.withOpacity(.4), spreadRadius: 2.0, blurRadius: 12.0)]),
child: Center(
child: Text("Hello Custom Appbar"),
),
),
);
}
#override
Size get preferredSize => Size(double.infinity, 150.0);
}
then use it like
Scaffold(
appBar: CustomAppBar() ,

border will cover whole appbar, is this what you want?
Scaffold(
extendBody: true,
appBar: AppBar(
title: Text(
"Test",
style: TextStyle(fontStyle: FontStyle.italic),
),
centerTitle: true,
elevation: 10,
backgroundColor: Colors.cyan[900],
shadowColor: Colors.cyan[900],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30),
),
side: BorderSide(width: 3.0, color: Colors.orange),
),
),

Related

I'm trying to get my CircleAvatar widget to position as in the following image but I can't seem to make that happen

1Here is my code. I tried using the bottom constructor from the appbar and I tried using the CircleAvatar in the body but I can't seem to make it so that it would position at the middle of the appbar and the body. Any tips maybe? Since I'm new to the mobile development world.
import 'package:flutter/material.dart';
class SignInPage extends StatelessWidget {
const SignInPage({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
elevation: 0,
backgroundColor: Color(0xFFf65d46),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(100), bottomLeft: Radius.circular(100)
// bottomLeft: Radius.circular(-1000),
),
),
bottom: PreferredSize(
preferredSize: Size.fromHeight(250),
child: Container(),
),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: const [
CircleAvatar(
backgroundImage: AssetImage('assets/images/logo_2.png'),
radius: 75,
),
],
),
);
}
}
Instead of put that in body, try this:
Scaffold(
appBar: PreferredSize(
preferredSize: Size.fromHeight(250),
child: Stack(
alignment: Alignment.center,
clipBehavior: Clip.none,
children: [
AppBar(
centerTitle: true,
elevation: 0,
backgroundColor: Color(0xFFf65d46),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(100),
bottomLeft: Radius.circular(100)
// bottomLeft: Radius.circular(-1000),
),
),
),
Positioned(
bottom: -75 ,
child: CircleAvatar(
backgroundImage: AssetImage('assets/images/logo_2.png'),
radius: 75,
),
),
],
),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: const [],
),
)

How to implement Round Shaped AppBar with Gradient Background in Flutter?

I want to achieve an AppBar which has a rounded bottom radius and gradient background. Also, I need to place some other content like cards within AppBar using the bottom property.
Here is my code:
import 'package:flutter/material.dart';
void main() => runApp(const Toddly());
class Toddly extends StatelessWidget {
const Toddly({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Toddly',
home: Scaffold(
appBar: AppBar(
leading: GestureDetector(
onTap: () {},
child: Container(
margin: const EdgeInsets.only(left: 10),
padding: const EdgeInsets.all(2),
decoration: const BoxDecoration(
color: Color.fromARGB(255, 158, 77, 130),
shape: BoxShape.circle,
),
child: const CircleAvatar(
backgroundImage: AssetImage('assets/images/profilePicture.png'),
),
),
),
title: const Text(
'Julia',
style: TextStyle(
fontFamily: 'Nunito',
),
),
centerTitle: true,
actions: [
IconButton(
onPressed: () {},
icon: const Icon(Icons.notifications_outlined),
),
IconButton(
onPressed: () {},
icon: const Icon(Icons.menu),
),
],
bottom: PreferredSize(
preferredSize: const Size.fromHeight(150.0),
child: Container(
height: 100,
width: 100,
color: Colors.white,
alignment: Alignment.center,
child: const Text('Some content'),
),
),
flexibleSpace: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF72326a),
Color(0xFF321c53),
],
),
),
),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30.0),
),
),
),
backgroundColor: const Color(0xFFfef1ee),
),
);
}
}
I used the shape property to implement rounded bottom AppBar.
I did gradient background using flexibleSpace.
And, I used bottom to add my other content under within AppBar.
However when I run all above code. rounded bottom appBar is not working.
image source
And, if I remove flexibleSpace it is showing, but I lost my gradient.
image source
Please, help me to figure it out and is it possible to do that without creating custom AppBars since I saw several approaches.
Thanks
All you just need to add corner radius to gradient container as well attaching you the updated code.
import 'package:flutter/material.dart';
void main() => runApp(const Toddly());
class Toddly extends StatelessWidget {
const Toddly({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Toddly',
home: Scaffold(
appBar: AppBar(
leading: GestureDetector(
onTap: () {},
child: Container(
margin: const EdgeInsets.only(left: 10),
padding: const EdgeInsets.all(2),
decoration: const BoxDecoration(
color: Color.fromARGB(255, 158, 77, 130),
shape: BoxShape.circle,
),
child: const CircleAvatar(
backgroundImage: AssetImage('assets/images/profilePicture.png'),
),
),
),
title: const Text(
'Julia',
style: TextStyle(
fontFamily: 'Nunito',
),
),
centerTitle: true,
actions: [
IconButton(
onPressed: () {},
icon: const Icon(Icons.notifications_outlined),
),
IconButton(
onPressed: () {},
icon: const Icon(Icons.menu),
),
],
bottom: PreferredSize(
preferredSize: const Size.fromHeight(150.0),
child: Container(
height: 100,
width: 100,
color: Colors.white,
alignment: Alignment.center,
child: const Text('Some content'),
),
),
flexibleSpace: Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30.0),
),
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [
Color(0xFF72326a),
Color(0xFF321c53),
],
),
),
),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30.0),
),
),
),
backgroundColor: const Color(0xFFfef1ee),
),
);
}
}

How can I make the text-decoration to none, using the package reactive_dropdown_search v0.9 in Flutter?

i want to remove the text decoration line and make the margin between the country name and down-arrow lower.Thanks for reading this arctile. In the following I will upload the code. https://i.stack.imgur.com/osN9b.png. Screen of the UI.I don't know where to write about the text-decoration or where I can add specific things about the button.
import 'package:reactive_dropdown_search/reactive_dropdown_search.dart';
import 'package:reactive_forms/reactive_forms.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
FormGroup buildForm() => fb.group({
'menu': FormControl<String>(value: 'Tunisia'),
'menuMultiple': FormControl<List<String>>(value: ['Tunisia', 'Brazil']),
'bottomSheet': FormControl<String>(value: 'Brazil'),
});
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
appBar: AppBar(),
body: SafeArea(
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(),
padding: const EdgeInsets.symmetric(
horizontal: 145.0,
vertical: 20.0,
),
child: ReactiveFormBuilder(
form: buildForm,
builder: (context, form, child) {
return Column(
children: [
ReactiveDropdownSearch<String, String>(
formControlName: 'bottomSheet',
popupProps: PopupProps.bottomSheet(
showSearchBox: true,
bottomSheetProps: const BottomSheetProps(
constraints:
BoxConstraints(maxHeight: 420, minHeight: 270),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(24),
topRight: Radius.circular(24),
),
),
),
title: Container(
height: 50,
decoration: BoxDecoration(
color: Theme.of(context).primaryColorDark,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
child: const Center(
child: Text(
'Country',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
),
),
decoration: const InputDecoration(
contentPadding: EdgeInsets.only(left: 14, top: 12),
),
items: const [
"Brazil",
"Italia",
"Tunisia",
'Canada',
'France',
"Deutschland"
],
),
const SizedBox(height: 16),
],
);
},
),
),
),
),
);
}
}

Flutter Web Icon doesn't fit inside Container

I have tried removing all padding and border and put the icon inside a FittedBox but the are still parts of the Container that are visible. How can I remove them? Thank you in advance.
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return CupertinoApp(
title: 'Cupertino App',
debugShowCheckedModeBanner: false,
home: CupertinoPageScaffold(
child: Center(
child: CupertinoButton(
minSize: 15,
padding: EdgeInsets.zero,
onPressed: () {},
child: Container(
width: 40,
padding: EdgeInsets.zero,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.blue,
border: Border.all(
width: 0,
color: Colors.transparent,
),
),
child: const FittedBox(
fit: BoxFit.cover,
child: Icon(
CupertinoIcons.minus_circle_fill,
color: Colors.amber,
),
),
),
),
),
),
);
}
}
The container colors are visible because the Icon assets comes with default padding, You can check this question: How to get rid of a icon padding,
You can use transparent Color on the Container to hide it.
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.transparent, // here
border: Border.all(
you can size
Icon(
CupertinoIcons.minus_circle_fill,
color: Colors.amber,
size:40
)
and you dont need container border default is none
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.blue,
//border: Border.all(
//width: 0,
//color: Colors.transparent,
// ),
),
or here
CupertinoButton(
minSize: 15,
padding: EdgeInsets.zero,
onPressed: () {},
child: Container(
width: 40,
padding: EdgeInsets.zero,
decoration:const BoxDecoration(
shape: BoxShape.circle,
color: Colors.amber,
),
child: const FittedBox(
fit: BoxFit.cover,
child: Icon(
Icons.remove,
color: Colors.blue,
size:40
),
),
),
),

Image not showing up in ListView

I know the code is a little messy, still learning.
I have placed the Image outside of the BoxDecoration but noting is showing up. Nothing shows up in the RUN as an error. I am guessing that it has something to do with the container inside the ListView but haven't been able to find out why its blank.
import 'package:flutter/material.dart';
class Home extends StatefulWidget {
#override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
elevation: 0.0,
title: Text("App"),
),
body: SafeArea(
child: Container(
height: 80,
decoration: new BoxDecoration(
color: Colors.blue,
borderRadius: new BorderRadius.only(
bottomLeft: const Radius.circular(40.0),
bottomRight: const Radius.circular(40.0))
),
child: ListView(
children: <Widget>[
Container(
margin: EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0),
width: 120,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey[300],
offset: Offset(1, 1),
blurRadius: 0
),
], // BoxShadow
borderRadius: BorderRadius.all(Radius.circular(20))
),
child: ListTile(
leading: Icon(Icons.search, color: Colors.red),
title: TextField(
decoration: InputDecoration(
hintText: "What stuff do you want to seach for?",
hintStyle: TextStyle(fontSize: 16, color: Colors.grey),
border: InputBorder.none
),
),
trailing: Icon(Icons.filter_list, color: Colors.red),
),
),
SizedBox(height: 5),
Container(
height: 220,
width: 220,
child: Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.red,
offset: Offset(1, 1),
blurRadius: 4
),
],
),
child: Image.asset("assets/images/1.jpg"),
),
],
),
),
],
),
),
)
);
}
}
This is what I am trying to do.
I updated the structure as a Column with two children:
The blue Container with the TextField
The ListView with the pictures
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
home: Home(),
),
);
}
class Home extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(elevation: 0.0, title: Text("App")),
body: SafeArea(
child: Column(
children: [
Container(
padding: EdgeInsets.all(20.0),
decoration: const BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(40.0),
bottomRight: Radius.circular(40.0),
),
),
child: DecoratedBox(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20.0),
),
child: const ListTile(
leading: Icon(Icons.search),
title: TextField(
decoration: InputDecoration(
hintText: "What stuff do you want to seach for?",
hintStyle: TextStyle(fontSize: 16, color: Colors.grey),
border: InputBorder.none,
),
autofocus: true,
),
trailing: Icon(Icons.filter_list),
),
),
),
SizedBox(
height: 120.0,
child: ListView(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
children: List.generate(
20,
(index) => Padding(
padding: const EdgeInsets.all(16.0),
child: Image.asset("assets/images/cartoon.jpg"),
),
),
),
),
],
),
),
);
}
}