Image selector placement in Flutter Screen - flutter

I have an input screen developed in flutter where i need to get the user image uploaded/selected. for this in the Screen UI i want to have a design like this in the picture.
The code and what i have come up with the screen background is as follows. How can i add this kind of a circle in my code to enable image selection.
final form =
Container(
alignment: Alignment.center,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 32.0, vertical: 4.0),
child: Column(
children: <Widget>[
SizedBox(height: 12.0),
title,
SizedBox(height: 16.0),
email,
SizedBox(height: 12.0),
userName,
SizedBox(height: 12.0),
password,
SizedBox(height: 12.0),
address,
SizedBox(height: 12.0),
country_dropdown,
SizedBox(height: 12.0),
phone,
SizedBox(height: 24.0),
continue_btn,
],
),
), ),
);
final body = Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: [0.5, 1.0],
colors: [
Color(0xFF03B898),
Color(0xFF01816B),
],
),
),
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
flex: 1,
child: Container(
alignment: Alignment.center,
child: Center(
child: Image.asset(
'assets/images/pawfect_logo.png',
height: 150.0,
width: 150.0,
fit: BoxFit.contain,
),
),
),
),
Expanded(
flex: 4,
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.white,
),
borderRadius: BorderRadius.only(
topRight: Radius.circular(50),
topLeft: Radius.circular(50),
),
),
child: form, //Text('this text here'),
),
),
],
),
));
return Scaffold(
body: body,
);```

Check out this example :
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(home: HomePage());
}
}
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
final form = Container(
height: MediaQuery.of(context).size.height*0.75,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 32.0, vertical: 4.0),
child: Column(
children: <Widget>[
SizedBox(height: 90.0),
Text('Name'),
SizedBox(height: 16.0),
Text('email'),
SizedBox(height: 12.0),
Text('username'),
SizedBox(height: 12.0),
Text('password'),
SizedBox(height: 12.0),
Text('Address'),
SizedBox(height: 12.0),
Text('Dropdown'),
SizedBox(height: 12.0),
Text('Phone'),
SizedBox(height: 24.0),
Text('con btn'),
],
),
),
);
final body = Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
stops: [0.5, 1.0],
colors: [
Color(0xFF03B898),
Color(0xFF01816B),
],
),
),
child: Stack(
children: <Widget>[
Column(
children: <Widget>[
Container(
height: MediaQuery.of(context).size.height * 0.25,
),
Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.white,
),
borderRadius: BorderRadius.only(
topRight: Radius.circular(50),
topLeft: Radius.circular(50),
),
),
child: form, //Text('this text here'),
),
],
),
Positioned(
right: 30,
top: 150,
child: Container(
width: 100,
height: 100,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.circular(50)),
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.camera_alt,
color: Colors.white,
),
Text(
'Upload Image',
style: TextStyle(fontSize: 10, color: Colors.white),
)
],
),
),
),
],
));
return Scaffold(
body: SingleChildScrollView(child: body),
);
}
}
Let me know if it works

You can use the following snippet to create a button on click of which the user will be prompted to select an image (either from gallery or camera)
class Layout extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFF03B898),
body: Stack(
children: <Widget>[
Card(
margin: EdgeInsets.only(top: 150),
color: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(50),
topLeft: Radius.circular(50),
),
),
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
),
),
Positioned(
top: 120,
right: 30,
child: RawMaterialButton(
shape: CircleBorder(),
fillColor: Color(0xFF03B898),
onPressed: () async {
final pickedFile = await ImagePicker().getImage(source: ImageSource.gallery);
},
padding: EdgeInsets.all(30.0),
child: Icon(
Icons.camera_alt,
color: Colors.white,
),
),
),
],
),
);
}
}
I have used the Image Picker library to select the image.

Related

List scrolls under SliverAppBar, but shouldn't be visible

As you can see in Picture 1 & 2 the List scrolls under the transparent SliverAppBar. Is there any possibility to let the SliverAppBar stay transparent and don't show the List underneath?
(As you can see in Picture 1 & 2 the List scrolls under the transparent SliverAppBar. Is there any possibility to let the SliverAppBar stay transparent and don't show the List underneath?)
// ignore_for_file: unused_local_variable
import 'dart:ui';
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, this.title = "Hallo"}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
alignment: Alignment.topRight,
image: AssetImage("lib/assets/images/Bg.png"),
),
),
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
alignment: Alignment.topRight,
image: AssetImage(
"lib/assets/images/Bg2.png",
),
scale: 1.05,
),
),
child: NestedScrollView(
headerSliverBuilder: (context, innerBoxISScrolled) => [
SliverAppBar(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30),
),
),
backgroundColor: Colors.transparent,
automaticallyImplyLeading: false,
floating: true,
snap: false,
pinned: true,
title: //Startseite
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Startseite",
style: TextStyle(color: Colors.black),
),
//Notification
Row(
children: [
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromARGB(255, 197, 193, 193),
Color.fromARGB(255, 167, 156, 156)
.withOpacity(0.8),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(12)),
padding: EdgeInsets.all(2),
child: Icon(Icons.notifications),
),
SizedBox(width: 10),
//Profile
ClipOval(
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xFFFFFFFF),
Color(0xFF000000).withOpacity(0),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(16),
),
padding: EdgeInsets.all(10),
child: Container(
width: MediaQuery.of(context).size.width * 0.06,
height: MediaQuery.of(context).size.height * 0.03,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: ExactAssetImage(
'lib/assets/images/baki.jpg'),
fit: BoxFit.fill,
),
),
),
),
),
],
),
],
),
bottom: AppBar(
elevation: 0,
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
title: Container(
decoration:
BoxDecoration(borderRadius: BorderRadius.circular(12)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 10.0),
child: Stack(
children: [
Padding(
padding: const EdgeInsets.only(top: 3.0),
child: Container(
width:
MediaQuery.of(context).size.width * 0.5,
height: MediaQuery.of(context).size.height *
0.025,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xFF4B4646).withOpacity(0.6),
Color(0xFFFFFFFF).withOpacity(0.2),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
borderRadius: BorderRadius.circular(12),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 5.0),
child: Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"Suchen",
textAlign: TextAlign.start,
style: TextStyle(
fontFamily: "Acme-Regular",
color: Colors.grey.shade200,
fontSize: 10),
),
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 170.0,
),
child: Container(
decoration: BoxDecoration(
color:
Colors.grey.shade300.withOpacity(0.4),
borderRadius: BorderRadius.circular(12)),
padding: EdgeInsets.all(5),
child: Icon(Icons.search,
size: 20, color: Colors.green),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Container(
decoration: BoxDecoration(
color: Colors.grey.shade300.withOpacity(0.4),
borderRadius: BorderRadius.circular(12)),
child: Icon(Icons.filter_alt,
size: 22, color: Colors.green),
),
),
],
),
),
),
),
],
body: ListView(
padding: const EdgeInsets.all(8),
children: <Widget>[
Container(
height: 50,
color: Colors.amber[600],
child: const Center(child: Text('Entry A')),
),
Container(
height: 50,
color: Colors.amber[500],
child: const Center(child: Text('Entry B')),
),
Container(
height: 50,
color: Colors.amber[100],
child: const Center(child: Text('Entry C')),
),
],
),
),
),
),
);
}
}
1:
2:

Make custom AppBar in Flutter

I am currently working on my own App and want to make this custom AppBar. Can somebody help me doing this?
MY main Problem is, the transparent Background and my ListView going under it which looks really bad. Is there any possibility to let the background trasnparent but don't show the List at the top?
// ignore_for_file: unused_local_variable
import 'dart:ui';
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, this.title = "Hallo"}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: BoxDecoration(
image: DecorationImage(
alignment: Alignment.topRight,
image: AssetImage("lib/assets/images/Bg.png"),
),
),
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
alignment: Alignment.topRight,
image: AssetImage(
"lib/assets/images/Bg2.png",
),
scale: 1.05,
),
),
child: NestedScrollView(
headerSliverBuilder: (context, innerBoxISScrolled) => [
SliverAppBar(
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30),
),
),
backgroundColor: Colors.transparent,
automaticallyImplyLeading: false,
floating: true,
snap: false,
pinned: true,
title: //Startseite
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Startseite",
style: TextStyle(color: Colors.black),
),
//Notification
Row(
children: [
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromARGB(255, 197, 193, 193),
Color.fromARGB(255, 167, 156, 156)
.withOpacity(0.8),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(12)),
padding: EdgeInsets.all(2),
child: Icon(Icons.notifications),
),
SizedBox(width: 10),
//Profile
ClipOval(
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xFFFFFFFF),
Color(0xFF000000).withOpacity(0),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(16),
),
padding: EdgeInsets.all(10),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: DecorationImage(
image: ExactAssetImage(
'lib/assets/images/baki.jpg'),
fit: BoxFit.fill,
),
),
),
),
),
],
),
],
),
bottom: AppBar(
elevation: 0,
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
title: Container(
decoration:
BoxDecoration(borderRadius: BorderRadius.circular(12)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 10.0),
child: Stack(
children: [
Padding(
padding: const EdgeInsets.only(top: 3.0),
child: Container(
width:
MediaQuery.of(context).size.width * 0.5,
height: MediaQuery.of(context).size.height *
0.025,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
Color(0xFF4B4646).withOpacity(0.6),
Color(0xFFFFFFFF).withOpacity(0.2),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
borderRadius: BorderRadius.circular(12),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 5.0),
child: Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"Suchen",
textAlign: TextAlign.start,
style: TextStyle(
fontFamily: "Acme-Regular",
color: Colors.grey.shade200,
fontSize: 10),
),
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 170.0,
),
child: Container(
decoration: BoxDecoration(
color:
Colors.grey.shade300.withOpacity(0.4),
borderRadius: BorderRadius.circular(12)),
padding: EdgeInsets.all(5),
child: Icon(Icons.search,
size: 20, color: Colors.green),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Container(
decoration: BoxDecoration(
color: Colors.grey.shade300.withOpacity(0.4),
borderRadius: BorderRadius.circular(12)),
child: Icon(Icons.filter_alt,
size: 22, color: Colors.green),
),
),
],
),
),
),
),
],
body: Expanded(
child: ListView(
padding: const EdgeInsets.all(8),
children: <Widget>[
Container(
height: 50,
color: Colors.amber[600],
child: const Center(child: Text('Entry A')),
),
Container(
height: 50,
color: Colors.amber[500],
child: const Center(child: Text('Entry B')),
),
Container(
height: 50,
color: Colors.amber[100],
child: const Center(child: Text('Entry C')),
),
],
),
),
),
),
),
);
}
}
[
This is my Result so far
This is my Result so far
you can add these lines of code to remove the backgroundColor from AppBar widget.
backgroundColor: Colors.transparent,
elevation: 0
If you want to implement it from zero, you can use a Row with 2 children. First child (a Text) for the title and the second one (a Row) for buttons. Don't remember to set mainAxisAlignment to MainAxisAlignment.spaceBetween.
I hope this help you
Here is the code:
import 'dart:ui';
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, this.title = "Hallo"}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
decoration: const BoxDecoration(
// color: Colors.cyan,
image: DecorationImage(
alignment: Alignment.topRight,
image: AssetImage("lib/assets/images/Bg.png"),
),
),
child: Container(
decoration: const BoxDecoration(
image: DecorationImage(
alignment: Alignment.topRight,
image: AssetImage(
"lib/assets/images/Bg2.png",
),
scale: 1.05,
),
),
child: CustomScrollView(
slivers: [
SliverAppBar(
elevation: 0,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
bottom: Radius.circular(30),
),
),
backgroundColor: Colors.transparent,
automaticallyImplyLeading: false,
floating: false,
snap: false,
pinned: true,
stretch: true,
actions: [
Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
const Color.fromARGB(255, 197, 193, 193),
const Color.fromARGB(255, 167, 156, 156)
.withOpacity(0.8),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(12)),
padding: const EdgeInsets.all(2),
child: const Icon(Icons.notifications),
),
const SizedBox(width: 10),
//Profile
ClipOval(
child: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
const Color(0xFFFFFFFF),
const Color(0xFF000000).withOpacity(0),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
borderRadius: BorderRadius.circular(16),
),
padding: const EdgeInsets.all(10),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
image: const DecorationImage(
image:
ExactAssetImage('lib/assets/images/baki.jpg'),
fit: BoxFit.fill,
),
),
),
),
),
],
title: const Text(
"Startseite",
style: TextStyle(color: Colors.black),
),
bottom: AppBar(
elevation: 0,
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
title: Container(
decoration:
BoxDecoration(borderRadius: BorderRadius.circular(12)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 10.0),
child: Stack(
children: [
Padding(
padding: const EdgeInsets.only(top: 3.0),
child: Container(
width:
MediaQuery.of(context).size.width * 0.5,
height: MediaQuery.of(context).size.height *
0.025,
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
const Color(0xFF4B4646)
.withOpacity(0.6),
const Color(0xFFFFFFFF)
.withOpacity(0.2),
],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
borderRadius: BorderRadius.circular(12),
),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 5.0),
child: Padding(
padding: const EdgeInsets.only(left: 4.0),
child: Text(
"Suchen",
textAlign: TextAlign.start,
style: TextStyle(
fontFamily: "Acme-Regular",
color: Colors.grey.shade200,
fontSize: 10),
),
),
),
),
),
Padding(
padding: const EdgeInsets.only(
left: 170.0,
),
child: Container(
decoration: BoxDecoration(
color:
Colors.grey.shade300.withOpacity(0.4),
borderRadius: BorderRadius.circular(12)),
padding: const EdgeInsets.all(5),
child: const Icon(Icons.search,
size: 20, color: Colors.green),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Container(
decoration: BoxDecoration(
color: Colors.grey.shade300.withOpacity(0.4),
borderRadius: BorderRadius.circular(12)),
child: const Icon(Icons.filter_alt,
size: 22, color: Colors.green),
),
),
],
),
),
),
),
SliverFillRemaining(
child: Expanded(
child: ListView(
padding: const EdgeInsets.all(8),
children: <Widget>[
Container(
height: 50,
color: Colors.amber[600],
child: const Center(child: Text('Entry A')),
),
Container(
height: 50,
color: Colors.amber[500],
child: const Center(child: Text('Entry B')),
),
Container(
height: 50,
color: Colors.amber[100],
child: const Center(child: Text('Entry C')),
),
],
),
),
),
],
),
),
),
);
}
}

how to insert a text in a container and padding for an image

I want to insert a text to my container I tried this code segment. but it is not displaying. first image showing how it display now. image two showing how I need it to be implement. also the image icon need to have padding from the corner. how can I do this.
child: Text(
"Activity",
style: TextStyle(color: textWhite, fontSize: 2)),
///////////////// //////////////////////////////////////////////////////////
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
padding: const EdgeInsets.all(20),
height: 45,
width: 180,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.4),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(10),
bottomLeft: Radius.circular(10),
),
image: DecorationImage(
alignment: Alignment.centerLeft,
image: AssetImage(
'assets/images/running.png',
),
),
),
child: Text(
"Activity",
style: TextStyle(color: textWhite, fontSize: 20),
),
),
Container(
height: 45,
width: 180,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.4),
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(10),
topRight: Radius.circular(10),
),
image: DecorationImage(
alignment: Alignment.centerLeft,
image: AssetImage('assets/images/medal.png'),
),
),
)
],
),
)
Use Following Code But You need to edit the style according to you
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
height: 50,
width: 200,
// You can set width of container here
decoration: BoxDecoration(
border: Border.all(),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(15),
bottomLeft: Radius.circular(15),
),
),
child: Padding(
// Following padding to give space around the icon and text
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'assets/running.png',
),
SizedBox(
width: 15,
),
Text(
"Activity",
style: TextStyle(
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
),
),
],
),
),
),
Container(
height: 50,
width: 200,
decoration: BoxDecoration(
border: Border.all(),
borderRadius: BorderRadius.only(
topRight: Radius.circular(15),
bottomRight: Radius.circular(15),
),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'assets/medal.png',
),
SizedBox(
width: 15,
),
Text(
"Achievement",
style: TextStyle(
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
),
),
],
),
),
),
],
),
You will get following response
This image is similar to your goal. run on DartPad.
You can change Image.network to Image.asset
import 'package:flutter/material.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(home: HomePage());
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
// backgroundColor: Colors.blue[700],
body: Container(
height: 45,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.4),
borderRadius: BorderRadius.circular(10),
),
margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
iconRowText('https://picsum.photos/45', 'Activity'),
Container(
height: 45,
width: 0.4,
color: Colors.black,
),
iconRowText('https://picsum.photos/45', 'Achievements'),
],
),
),
);
}
Row iconRowText(String image, String text) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Image.network(image, height: 45, width: 45, fit: BoxFit.cover),
),
Text(text),
],
);
}
}

Cannot get rid of light gray border around Sliver body

Does anyone know why I still have a gray, thin horizontal line at the top and bottom of my body? I'm using SliverAppBar with a SliverFillRemaining below it. I've already set the elevation value of SliverAppBar to be 0.0.
import 'package:flutter/material.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
class AccountPage extends StatefulWidget {
#override
_AccountPageState createState() => _AccountPageState();
}
class _AccountPageState extends State<AccountPage> {
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).primaryColor,
bottomNavigationBar: CurvedNavigationBar(
backgroundColor: Theme.of(context).backgroundColor,
items: <Widget>[
Icon(Icons.add, size: 30),
Icon(Icons.list, size: 30),
Icon(Icons.compare_arrows, size: 30),
],
onTap: (index) {
//Handle button tap
},
),
body: CustomScrollView(
slivers: [
SliverAppBar(
elevation: 0.0,
backgroundColor: Theme.of(context).primaryColor,
expandedHeight: 220.0,
collapsedHeight: 125.0,
pinned: true,
flexibleSpace: Stack(
children: [
Positioned.fill(
child: Image(
image: AssetImage('assets/images/Red_Polygon.jpg'),
fit: BoxFit.cover,
),
),
SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Container(
width: double.infinity,
child: Padding(
padding: EdgeInsets.symmetric(
horizontal: 32.0,
vertical: 16.0,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Hello, \nFIRST_NAME!",
style: TextStyle(
color: Colors.white,
fontSize: 32.0,
),
),
],
),
),
),
Container(
height: 16.0,
width: double.infinity,
decoration: BoxDecoration(
color: Theme.of(context).backgroundColor,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(40.0),
topRight: const Radius.circular(40.0),
),
),
),
],
),
),
],
),
),
SliverFillRemaining(
child: Container(
color: Theme.of(context).backgroundColor,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Column(
children: [
],
),
),
),
),
],
),
);
}
}
make this container to have a decoration color of white
Container(
height: 16.0,
width: double.infinity,
decoration: BoxDecoration(
color:Colors.white,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(40.0),
topRight: const Radius.circular(40.0),
),
),
),
for bottom navigation give it a background color of white too.
By default background color is "greyish", you can edit this in Themes

How to design Custom dialog box using close icon with flutter?

I have an image of the dialog box and trying to design the same as below the image.
I tried but it's not same as above the image
I just want set cross button at the top right corner, like above the image.
i used Stack, and a placed Positioned widget at the top:0.0,right:0.0.
CODE:
customDialogBox(BuildContext context) {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: Colors.red,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(32.0))),
contentPadding: EdgeInsets.only(top: 10.0),
content: Stack(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 20.0,
),
Center(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: new Text("Sorry please try \n again tomorrow", style:TextStyle(fontSize: 30.0,color: Colors.white)),
)//
),
SizedBox(
height: 20.0,
width: 5.0,
),
Divider(
color: Colors.grey,
height: 4.0,
),
InkWell(
child: Container(
padding: EdgeInsets.only(top: 15.0, bottom: 15.0),
decoration: BoxDecoration(
color:Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(32.0),
bottomRight: Radius.circular(32.0)),
),
child: Text(
"OK",
style: TextStyle(color: Colors.blue,fontSize: 25.0),
textAlign: TextAlign.center,
),
),
onTap:(){
Navigator.pop(context);
},
),
],
),
),
Positioned(
top: 0.0,
right: 0.0,
child: FloatingActionButton(
child: Image.asset("assets/red_cross.png"),
onPressed: (){
Navigator.pop(context);
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(80)),
backgroundColor: Colors.white,
mini: true,
elevation: 5.0,
),
),
],
)
);
});
}
here's my Dialog Box:
Try this will work perfect.
import 'package:flutter/material.dart';
import 'custom_dialog.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Center(
child: RaisedButton(
onPressed: () {
showDialog(context: context, builder: (BuildContext context) => CustomDialog());
},
child: Text('show custom dialog'),
),
),
);
}
}
Dialog Widget :
import 'package:flutter/material.dart';
class CustomDialog extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
elevation: 0.0,
backgroundColor: Colors.transparent,
child: dialogContent(context),
);
}
Widget dialogContent(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 0.0,right: 0.0),
child: Stack(
children: <Widget>[
Container(
padding: EdgeInsets.only(
top: 18.0,
),
margin: EdgeInsets.only(top: 13.0,right: 8.0),
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(16.0),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.black26,
blurRadius: 0.0,
offset: Offset(0.0, 0.0),
),
]),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
SizedBox(
height: 20.0,
),
Center(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: new Text("Sorry please try \n again tomorrow", style:TextStyle(fontSize: 30.0,color: Colors.white)),
)//
),
SizedBox(height: 24.0),
InkWell(
child: Container(
padding: EdgeInsets.only(top: 15.0,bottom:15.0),
decoration: BoxDecoration(
color:Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(16.0),
bottomRight: Radius.circular(16.0)),
),
child: Text(
"OK",
style: TextStyle(color: Colors.blue,fontSize: 25.0),
textAlign: TextAlign.center,
),
),
onTap:(){
Navigator.pop(context);
},
)
],
),
),
Positioned(
right: 0.0,
child: GestureDetector(
onTap: (){
Navigator.of(context).pop();
},
child: Align(
alignment: Alignment.topRight,
child: CircleAvatar(
radius: 14.0,
backgroundColor: Colors.white,
child: Icon(Icons.close, color: Colors.red),
),
),
),
),
],
),
);
}
}
Approach 2:
void showFancyCustomDialog(BuildContext context) {
Dialog fancyDialog = Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
),
height: 300.0,
width: 300.0,
child: Stack(
children: <Widget>[
Container(
width: double.infinity,
height: 300,
decoration: BoxDecoration(
color: Colors.grey[100],
borderRadius: BorderRadius.circular(12.0),
),
),
Container(
width: double.infinity,
height: 50,
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(12),
topRight: Radius.circular(12),
),
),
child: Align(
alignment: Alignment.center,
child: Text(
"Dialog Title!",
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.w600),
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
width: double.infinity,
height: 50,
decoration: BoxDecoration(
color: Colors.blue[300],
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(12),
bottomRight: Radius.circular(12),
),
),
child: Align(
alignment: Alignment.center,
child: Text(
"Okay let's go!",
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.w600),
),
),
),
),
),
Align(
// These values are based on trial & error method
alignment: Alignment(1.05, -1.05),
child: InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(12),
),
child: Icon(
Icons.close,
color: Colors.black,
),
),
),
),
],
),
),
);
showDialog(
context: context, builder: (BuildContext context) => fancyDialog);
}
In order to build the custom Dialog box I had to do everything custom.
I still used stack but instead of a inbuilt DialogBox i used a Container, I also replaced the image of the icon with an actual icon, and made the ok bold, as on the expected result.
hope this fits your needs.
Stack(
alignment: Alignment.center,
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.circular(30.0),
),
width: 500.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 20.0,
),
Center(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: new Text("Sorry please try \n again tomorrow", style:TextStyle(fontSize: 30.0,color: Colors.white)),
)//
),
SizedBox(
height: 20.0,
width: 5.0,
),
Divider(
color: Colors.grey,
height: 4.0,
),
InkWell(
child: Container(
padding: EdgeInsets.only(top: 15.0, bottom: 15.0),
decoration: BoxDecoration(
color:Colors.white,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(32.0),
bottomRight: Radius.circular(32.0)),
),
child: Text(
"OK",
style: TextStyle(color: Colors.blue,fontSize: 25.0, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
onTap:(){
Navigator.pop(context);
},
),
],
),
),
Align(
alignment: Alignment(1.05, -0.35),
child: InkWell(
onTap: () {},
child: Container(
width: 40.0,
height: 40.0,
child: Icon(Icons.close, color: Colors.red, size: 40,),
decoration: BoxDecoration(
boxShadow: [
BoxShadow(color: Colors.black,offset: Offset(0, 1), blurRadius: 2),
],
shape: BoxShape.circle,
color: Colors.white
),
),
),
),
],
),