Image not showing Stack Widget in Flutter - flutter

I Want show Image above the Container Using Stack Widget but I don't Know how to do
I'm Tried Position and Align Widget it's Work but image half Image Not visible
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:navami/Controller/FirebaseController.dart';
import 'package:navami/env.dart';
import '../DatabaseServices/dbServices.dart';
import 'wallet.dart';
class DetailScreen extends StatelessWidget {
final String imageId;
final Map data;
DetailScreen(this.imageId, this.data);
final FirebaseController controller = Get.find();
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
alignment: Alignment.center,
children: [
Hero(
tag: imageId,
child: Center(
child: Container(
alignment: Alignment.center,
height: 250,
width: 350,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
image: DecorationImage(
image: NetworkImage(
data['image'],
),
fit: BoxFit.cover),
),
),
),
),
Text(
data['title'],
style: Theme.of(context).textTheme.displaySmall,
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: MediaQuery.of(context).size.height / 1.5,
decoration: BoxDecoration(
color: Colors.blue[600],
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(25),
topRight: Radius.circular(25))),
),
),
],
),
}));
}
}
This is Emulator ScreenShot
Screen Top 30 Padding after image and above the container then center of the container text
So I want this type of Screen

class WelcomeScreen extends StatelessWidget {
#override
Widget build(BuildContext context) {
double h = MediaQuery.of(context).size.height;
double w = MediaQuery.of(context).size.width;
return Scaffold(
body: Container(
height: h,
width: w,
child: Stack(
children: [
Container(
child: Image.asset(
'assets/images/welcome.png',
),
),
Positioned(
bottom: 10.0,
child: Container(
// height: h * 0.4,
width: w,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0),
)),
child: Column(
children: [
Container(
height: 140,
width: 200,
child: SvgPicture.asset(
'assets/images/Logoforstaicimage.svg',
),
),
SizedBox(
height: 10.0,
),
Container(
padding: EdgeInsets.only(left: 24, right: 24.0),
child: Text(
"Fitness is POWERFUL!! My mission is to bring people together, from all walks of life, with varying goals and abilities.",
textScaleFactor: 0.85,
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'Raleway',
color: Color(0xff76767c),
fontSize: 17,
fontWeight: FontWeight.w500,
fontStyle: FontStyle.normal,
letterSpacing: 0,
),
),
),
],
),
),
),
],
),
),
);
}
}

Related

Half circle with some text Flutter

I'm new to flutter, but I would like to know if it's possible to do something like this in flutter? the drawing of half a circle inside two texts, I will use it inside a login form.
You can use Stack widget for customizable overlay.
home: Scaffold(
body: LayoutBuilder(
builder: (context, constraints) {
final width = constraints.maxWidth;
return SizedBox(
width: width,
height: constraints.maxHeight,
child: Stack(
children: [
// background 1st
Positioned(
top: 10,
left: -width * .4,
bottom: 10,
right: 10,
child: Container(
decoration: const ShapeDecoration(
shape: CircleBorder(),
color: Colors.grey,
),
),
),
Align(
alignment: Alignment(-.4, .2),
child: Text("Some Text"),
),
Align(
alignment: Alignment(-.4, -.2),
child: Text("Some Text"),
),
],
),
);
},
),
),
Check more about Stack widget and /ui/layout.
you can create container with the color grey and make some changes in the box decoration. like the border radius. here is the code.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
body: Center(
child: SizedBox(
height: 200,
width: 125,
child: Container(
decoration: const BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(200),
topRight: Radius.circular(200),
bottomLeft: Radius.circular(0),
topLeft: Radius.circular(0)),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("SOME TEXT", style: TextStyle(fontSize: 15)),
SizedBox(
height: 50,
),
Text("SOME TEXT", style: TextStyle(fontSize: 15)),
],
),
),
),
),
),
);
}
}

Flutter - Problem about container with Network Image aligned to right and text aligned to left

I'm trying to create a simple Container includes;
A text aligned to center left (that text can include 50 characters)
A network image which is aligned to bottom right, rotated a bit, and rounded.
I've written a code like this:
import 'package:flutter/material.dart';
class MyScreen extends StatefulWidget {
static const String idScreen = "myScreen";
#override
_MyScreenState createState() => _MyScreenState();
}
class _MyScreenState extends State<MyScreen> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("My Screen")),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 200,
height: 100,
alignment: Alignment.bottomRight,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadiusDirectional.circular(16.0),
color: Colors.yellow),
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Flexible(
child: Text(
"Baby",
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
),
),
Transform(
child: Image.network(
"https://target.scene7.com/is/image/Target/Baby-210913-1631564062108?wid=315&hei=315&qlt=60&fmt=webp",
fit: BoxFit.contain,
),
transform: Matrix4.rotationZ(-0.2),
alignment: FractionalOffset.centerRight,
),
],
),
),
),
);
}
}
and the output is;
My output has some problems.
I want the container to be wide left-right and has 8 padding from the right and left.
I want the network picture to be bottom right with only its rounded picture, not as white square.
-- EDIT --
I've changed my code like;
import 'package:flutter/material.dart';
class MyScreen extends StatefulWidget {
static const String idScreen = "myScreen";
#override
_MyScreenState createState() => _MyScreenState();
}
class _MyScreenState extends State<MyScreen> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("My Screen")),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: MediaQuery.of(context).size.width,
height: 100,
alignment: Alignment.center,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadiusDirectional.circular(16.0),
color: Colors.yellow),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Baby",
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
),
Container(
width: 50,
height: 50,
decoration: const BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
fit: BoxFit.contain,
image: NetworkImage(
"https://target.scene7.com/is/image/Target/Baby-210913-1631564062108?wid=315&hei=315&qlt=60&fmt=png"
)
)
),
),
],
),
),
),
);
}
}
But now there is no rotation on picture, and it is not aligned to bottom right. Output:
To get the container wide you should change its width from 200 to width of your screen using Mediaquery.
eg : MediaQuery.of(context).size.width
That image has a white background also its square. You should use an image with transparent background.
Add this to your row : mainAxisAlignment: MainAxisAlignment.spaceBetween this will move the image to right end and text to left.
Hope that is what you meant and this helps.
Edit
I made some changes and now your code looks like this :
Container(
color: Colors.yellow,
height: 100,
width: Constants(context).scrnWidth,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Baby",
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
),
),
),
Container(
height: 100,
child: Align(
alignment: Alignment.bottomCenter,
child: Transform.rotate(
angle: -0.3,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
width: 50,
height: 50,
decoration: const BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
fit: BoxFit.contain,
image: NetworkImage(
"https://target.scene7.com/is/image/Target/Baby-210913-1631564062108?wid=315&hei=315&qlt=60&fmt=png"))),
),
),
),
),
),
],
),
),

flutter : Text on image in flutter

I want to write text with transparent color on image. like this.
I want to write text over the image but I am not able to do it properly.
This is my code.
I want to write text over the image but I am not able to do it properly.
And I also want transparent color for text.
Please help me.
import 'package:card_example/color_filters.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
static final String title = 'Card Example';
#override
Widget build(BuildContext context) => MaterialApp(
debugShowCheckedModeBanner: false,
title: title,
theme: ThemeData(primarySwatch: Colors.deepOrange),
home: MainPage(title: title),
);
}
class MainPage extends StatefulWidget {
final String title;
const MainPage({
#required this.title,
});
#override
_MainPageState createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
#override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: ListView(
padding: EdgeInsets.all(16),
children: [
Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
child: Stack(
alignment: Alignment.center,
children: [
Ink.image(
image: NetworkImage(
'https://resources.pulse.icc-cricket.com/ICC/photo/2018/04/22/c19486c2-4e5b-48c4-82af-c6d0eebb7bd2/Main.jpg',
),
colorFilter: ColorFilters.greyscale,
child: InkWell(
onTap: () {},
),
height: 240,
fit: BoxFit.cover,
),
Text(
'Sachin Tendulkar',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 24,
),
),
],
),
)
],
),
);
}}
I want to write text over the image but I am not able to do it properly.
And I also want transparent color for text.
Please help me.
If want to use for that container and I use decoration for image text widget for text then how to make exact that thing like is in image.
If you consider splashColor, there are multiple ways to handle this:
using Ink.image() inside Stack will not provide circular borderRadius. Check this GitHub issue. is still open.
ClipRRect(
borderRadius: BorderRadius.circular(12),
child: SizedBox(
width: 300,
height: 300,
child: Stack(
fit: StackFit.expand,
children: [
Align(
alignment: Alignment.bottomCenter,
child: Container(
width: double.infinity,
padding: EdgeInsets.all(8),
color: Colors.blue.withOpacity(.5),
child: Text(
'Sachin Tendulkar',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 24,
),
),
),
),
Ink.image(
image: NetworkImage(
'https://resources.pulse.icc-cricket.com/ICC/photo/2018/04/22/c19486c2-4e5b-48c4-82af-c6d0eebb7bd2/Main.jpg',
),
fit: BoxFit.cover,
child: InkWell(
borderRadius: BorderRadius.circular(12),
onTap: () {},
),
),
],
)),
);
1: Using GridTile
Container(
width: 300,
height: 300,
color: Colors.transparent,
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: InkWell(
onTap: () {},
child: GridTile(
child: Image.network(
'https://resources.pulse.icc-cricket.com/ICC/photo/2018/04/22/c19486c2-4e5b-48c4-82af-c6d0eebb7bd2/Main.jpg',
fit: BoxFit.cover,
),
footer: Container(
padding: EdgeInsets.all(8),
color: Colors.blue.withOpacity(.5),
child: Text(
'Sachin Tendulkar',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 24,
),
),
),
),
),
),
);
2: Using decoration of Container
InkWell(
onTap: () {},
splashColor: Colors.red,
child: Container(
width: 300,
height: 300,
alignment: Alignment.bottomCenter,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
image: DecorationImage(
image: NetworkImage(
'https://resources.pulse.icc-cricket.com/ICC/photo/2018/04/22/c19486c2-4e5b-48c4-82af-c6d0eebb7bd2/Main.jpg',
),
fit: BoxFit.cover,
),
),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.blue.withOpacity(.5),
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(12),
bottomRight: Radius.circular(12),
),
),
padding: EdgeInsets.all(8),
child: Text(
'Sachin Tendulkar',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 24,
),
),
),
),
);
Try adding bottomCenter to alignment
Stack(
alignment: Alignment.bottomCenter, //Here
children: [
Ink.image(
image: NetworkImage(
'https://static.remove.bg/remove-bg-web/3661dd45c31a4ff23941855a7e4cedbbf6973643/assets/start_remove-79a4598a05a77ca999df1dcb434160994b6fde2c3e9101984fb1be0f16d0a74e.png',
),
child: InkWell(
onTap: () {},
),
height: 240,
fit: BoxFit.cover,
),
Text(
'Sachin Tendulkar',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 24,
),
),
],
);
Result:

How can I create this UI in flutter? please help me out :

https://i.stack.imgur.com/rQYu0.png
I'm new to flutter, and I've been trying to build this ui but it's way out of my league !
Here's my code so far:
(by the way I didn't use any specific package...)
My biggest challenge are the angles of that circle !
How can I create that circle? Is there a package for it ?
class NowPlaying extends StatefulWidget {
#override
_NowPlayingState createState() => _NowPlayingState();
}
class _NowPlayingState extends State<NowPlaying> {
#override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Scaffold(
backgroundColor: Colors.white,
body: Column(
children: <Widget>[
Container(
color: btmGreen,
height: 60,
width: size.width,
child: Row(
children: <Widget>[
GestureDetector(
child:
cbutton(back),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>NowPlaying()));
},
),
Spacer(),
Container(
height: 35,
width: 300,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
// topLeft: Radius.circular(30),
bottomLeft: Radius.circular(260)),
color : PrimaryGreen,
),
)
],
),
),
Container(
// color: Colors.white,
child: Row(
children: <Widget>[
buildVerticalMenu(size),
ClipRRect(
borderRadius: BorderRadius.circular(370),
child: Container(
color: Orange,
height: 400,
width: 400,
child: ClipRRect(
borderRadius: BorderRadius.circular(370),
child: Container(
// padding: EdgeInsets.fromLTRB(110, 110, 0.0, 110),
height: 360,
width: 360,
decoration: BoxDecoration(
color: PrimaryGreen,
borderRadius: BorderRadius.all(Radius.circular(200)),
image: DecorationImage(
alignment: Alignment.bottomCenter,
fit: BoxFit.fill,
image: AssetImage("assets/images/hiphop.jpg"),
),
),),
),
),
),
],
),
)
],
),
);
}
Widget buildVerticalMenu(Size size){
return Container(alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(topRight: Radius.circular(60)),
color: Colors.white,
),
height: size.height*0.3,
width: 70,
child: RotatedBox(
quarterTurns: -1,
child: Text('Now Playing', style: TextStyle(fontSize: 20 , fontWeight: FontWeight.w700,color: PrimaryGreen),)),
);
}
}

Create curved card with shadow

I really need you because I don't have even start idea how to implement these, and also I am not sure how it is called.
Actually, I want to implement something similar like on image (this little circle in each of cards - that is like chain between two cards).
With help of key I have made image from up with this code:
class InfoPage extends StatefulWidget {
InfoPage();
#override
_InfoPageState createState() => _InfoPageState();
}
class _InfoPageState extends State<InfoPage> {
InfoItemModel infoData = dataSourceInfoUser;
double basicSize = 70;
#override
initState() {
super.initState();
}
#override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text('Example'),
),
body: Container(
color: Colors.white,
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
width: double.infinity,
height: 150,
child: AppCardField(
child: Text('Something'),
),
),
_buildCardWithCircle(
bgCircleX: 0.78,
bgCirceY: -2.0,
innerContainerX: 0.756,
innerContainerY: -1.78,
colorInner: Colors.orange
),
],
),
),
),
);
_buildCardWithCircle({double bgCircleX, double bgCirceY, double innerContainerX, double innerContainerY, Color colorInner}) => Container(
width: double.infinity,
height: 150,
child: Stack(
children: <Widget>[
Container(
width: double.infinity,
height: 150,
child: AppCardField(
child: Text('Something'),
),
),
Align(
alignment: Alignment(bgCircleX, bgCirceY),
child: Container(
height: basicSize,
width: basicSize,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(50.0),
),
),
),
Align(
alignment: Alignment(innerContainerX, innerContainerY),
child: Container(
height: basicSize - 10,
width: basicSize - 10,
decoration: BoxDecoration(
color: colorInner,
borderRadius: BorderRadius.circular(50.0),
),
child: Icon(Icons.vertical_align_center),
),
),
],
),
);
}
class AppCardField extends StatelessWidget {
final Widget child;
final double height;
final double paddingVertical, paddingHorizontal;
final double paddingVerticalChild, paddingHorizontalChild;
AppCardField({
this.child,
this.height,
this.paddingVertical = 8,
this.paddingHorizontal = 16,
this.paddingVerticalChild = 8,
this.paddingHorizontalChild = 16,
Key key})
: super(key: key);
#override
Widget build(BuildContext context) => Padding(
padding: EdgeInsets.symmetric(
vertical: paddingVertical, horizontal: paddingHorizontal),
child: Container(
height: height,
decoration: BoxDecoration(
color: Theme.of(context).primaryColor,
borderRadius: BorderRadius.all(Radius.circular(8)),
boxShadow: [
BoxShadow(
color: Colors.red,
blurRadius: 15.0,
offset: Offset(0.0, 5.0),
),
],
),
child: Padding(
padding: EdgeInsets.symmetric(
vertical: paddingVerticalChild,
horizontal: paddingHorizontalChild),
child: child,
),
));
}
But here, I have problem with shadow of the card and strongly white background of circle, OFC I need this shadow to be also in this white space, question is how to solve this?
Something like this
MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Some Stuff"),
),
body: Column(
children: <Widget>[
Container(
width: double.infinity,
height: 150.0,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.red,
blurRadius: 20.0
)
]
),
child: Card(
elevation: 20.0,
color: Colors.blueGrey,
child: Text('Something'),
),
),
SizedBox(height: 10.0,),
Container(
width: double.infinity,
height: 150.0,
child: Stack(
children: <Widget>[
Container(
width: double.infinity,
height: 150.0,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.red,
blurRadius: 20.0
)
]
),
child: Card(
elevation: 20.0,
color: Colors.blueGrey,
child: Text('Something'),
),
),
Align(
alignment: Alignment(0.9,-1.5),
child: Container(
height: 50.0,
width: 50.0,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(25.0),
),
),
),
Align(
alignment: Alignment(0.88,-1.35),
child: Container(
height: 40.0,
width: 40.0,
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.circular(25.0),
),
),
),
Align(
alignment: Alignment(0.85, -1.2),
child: Icon(Icons.access_alarms, color: Colors.white,)
),
],
),
),
],
),
),
);
then you just reaped the card for the other once with different alignment values.