How create an arrow-tab-like design in flutter - flutter

anyone who knows how to do a design like this when clicking the first arrow,
one screen appears and after completing that screen the tab color changes to green ,
then clicking on the second arrow second screen appears ,
then after clicking on third arrow third screen appears ,
just working like a tab screen , how can I achieve this in flutter?
class MainUiPage extends StatefulWidget {
const MainUiPage({Key? key}) : super(key: key);
#override
_MainUiPageState createState() => _MainUiPageState();
}
class _MainUiPageState extends State<MainUiPage> with SingleTickerProviderStateMixin{
TabController? _tabController;
#override
void initState() {
_tabController = TabController(length: 3, vsync: this);
super.initState();
}
#override
void dispose() {
super.dispose();
_tabController?.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: /*Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
// give the tab bar a height [can change hheight to preferred height]
Container(
height: 45,
decoration: BoxDecoration(
color: Colors.grey[300],
// borderRadius: BorderRadius.circular(
// 25.0,
// ),
),
child: TabBar(
controller: _tabController,
// give the indicator a decoration (color and border radius)
indicator: BoxDecoration(
borderRadius: BorderRadius.circular(
25.0,
),
color: Colors.green,
),
labelColor: Colors.white,
unselectedLabelColor: Colors.black,
tabs: [
// first tab [you can add an icon using the icon property]
Tab(
text: 'Place Bid',
),
// second tab [you can add an icon using the icon property]
Tab(
text: 'Buy Now',
),
Tab(
text: 'Buy Now',
),
],
),
),
// tab bar view here
Expanded(
child: TabBarView(
controller: _tabController,
children: [
// first tab bar view widget
Center(
child: Text(
'Place Bid',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.w600,
),
),
),
// second tab bar view widget
Center(
child: Text(
'Buy Now',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.w600,
),
),
),
// second tab bar view widget
Center(
child: Text(
'Buy Now',
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.w600,
),
),
),
],
),
),
],
),
),*/
Row(
children: [
SizedBox(width: 15.w,),
SizedBox(
height: 250.h,
width: 70.w,
child: CustomPaint (
painter: RPSCustomPainter1(),
child: Align(
alignment: Alignment(-.2, -0.1), //litle left
child: Text(
"machines",
style: TextStyle(
fontSize: 18.sp,
),
),
),
),
),
SizedBox(
height: 250.h,
width: 70.w,
child: CustomPaint(
painter: RPSCustomPainter2(),
child: Align(
alignment: const Alignment(-.2, -0.1), //litle left
child: Text(
"materials",
style: TextStyle(
fontSize: 18.sp,
),
),
),
),
),
SizedBox(
// Size(WIDTH,(WIDTH*0.58).toDouble())
// Size(WIDTH, (WIDTH*0.14901960784313725).toDouble()),
// Size(WIDTH,(WIDTH*0.8125).toDouble()),
height: 250.h,
width: 70.w,
child: CustomPaint(
painter: RPSCustomPainter3(),
child: Align(
alignment: const Alignment(-.2, -0.1), //litle left
child: Text(
"component",
style: TextStyle(
fontSize: 18.sp,
),
),
),
),
),
SizedBox(
// Size(WIDTH,(WIDTH*0.58).toDouble())
// Size(WIDTH, (WIDTH*0.14901960784313725).toDouble()),
// Size(WIDTH,(WIDTH*0.8125).toDouble()),
height: 250.h,
width: 70.w,
child: CustomPaint(
painter: RPSCustomPainter3(),
child: Align(
alignment: const Alignment(-.2, -0.1), //litle left
child: Text(
"component",
style: TextStyle(
fontSize: 18.sp,
),
),
),
),
),
],
),
),
);
}
}
here is the sample code I had done, but it doesn't work correctly , anyone how to do this please help , I'm new to this.

You need to do something like that.... wrap all your Container in a Stack and set Positioned of every Container.
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(
appBar: AppBar(
title: const Text('Welcome to Flutter'),
),
body: Container(
width: double.infinity,
child: Stack(
children: [
Positioned(
left: 0,
child: ClipPath(
clipper: CustomClipPathTopContainerOne(),
child: Container(
height: 50,
width: 200,
color: Colors.green,
),
),
),
Positioned(
left: 175,
child: ClipPath(
clipper: CustomClipPathTopContainerSecond(),
child: Container(
height: 50,
width: 200,
color: Colors.red,
),
),
),
Positioned(
left: 350,
child: ClipPath(
clipper: CustomClipPathTopContainerSecond(),
child: Container(
height: 50,
width: 200,
color: Colors.pink,
),
),
),
],
)
),
),
);
}
}
class CustomClipPathTopContainerOne extends CustomClipper<Path> {
#override
Path getClip(Size size) {
double w = size.width;
double h = size.height;
Paint paint = Paint()
..style = PaintingStyle.stroke
..strokeWidth=10.0
..color = Colors.black;
Path path0 = Path();
path0.moveTo(0,size.height);
path0.lineTo(0,size.height*0.4890143);
path0.lineTo(0,0);
path0.lineTo(size.width*0.8545167,0);
path0.lineTo(size.width,size.height*0.4991714);
path0.lineTo(size.width*0.8551250,size.height);
path0.lineTo(0,size.height);
path0.lineTo(size.width*0.0013417,size.height);
path0.lineTo(0,size.height);
path0.close();
return path0;
}
#override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
class CustomClipPathTopContainerSecond extends CustomClipper<Path> {
#override
Path getClip(Size size) {
double w = size.width;
double h = size.height;
Paint paint = Paint()
..style = PaintingStyle.stroke
..strokeWidth=10.0
..color = Colors.black;
Path path0 = Path();
path0.moveTo(0,size.height);
path0.lineTo(size.width*0.1459833,size.height*0.5012000);
path0.lineTo(0,0);
path0.lineTo(size.width*0.8545167,0);
path0.lineTo(size.width,size.height*0.4991714);
path0.lineTo(size.width*0.8551250,size.height);
path0.lineTo(0,size.height);
path0.lineTo(size.width*0.0013417,size.height);
path0.lineTo(0,size.height);
path0.close();
return path0;
}
#override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}

Related

dynamic progress bar in flutter

I want to create a progress bar in flutter which is like this
I get the data of week from backend but I have to create it this way.
and the icon on weeks or survey should be touchable.
thanks in advance.
Still a lot of things to change, but i thing it should be enough for the beginning
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: 'Example',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({super.key});
#override
Widget build(BuildContext context) {
List<String> points = [
'Survey',
'Week 1',
'Week 2',
'Week 3',
'Week 4',
];
var lineWidth =
MediaQuery.of(context).size.width - 16.0; // screen width - 2 * padding
var space = lineWidth / points.length; //space between dots
var currentSteps = 3; // <---- change this one
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: SizedBox(
height: 60.0,
child: Stack(
children: [
//grey line
Positioned(
top: 15,
left: 0,
right: 0,
child: Container(
height: 2.0,
width: double.infinity,
color: Colors.grey,
),
),
//red line
Positioned(
top: 15,
left: 0,
child: Container(
height: 2.0,
width: space * (currentSteps - 1) + space / 2,
color: Colors.orange,
),
),
//circles
Row(
children: points
.asMap()
.map((i, point) => MapEntry(
i,
SizedBox(
width: space,
child: Column(
children: [
Stack(
children: [
Container(
height: 30.0,
width: 30.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
width: 1.5,
color: i == currentSteps - 1
? Colors.orange
: Colors.transparent,
),
),
child: Center(
child: Container(
height: 20.0,
width: 20.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: i < currentSteps
? Colors.orange
: Colors.grey,
),
),
),
),
if (i < currentSteps - 1)
const SizedBox(
height: 30.0,
width: 30.0,
child: Center(
child: Icon(
Icons.check,
size: 16.0,
color: Colors.white,
),
),
),
],
),
const SizedBox(height: 4.0),
Text(
point,
textAlign: TextAlign.left,
style: TextStyle(
color: i < currentSteps
? Colors.orange
: Colors.grey,
),
),
],
),
),
))
.values
.toList(),
),
],
),
),
),
),
);
}
}
You can try basic Stepper widget with type: StepperType.horizontal. As for the UI you like im_stepper package. If it fails to satisfy you can create custom widget with Stack and Row.
Try basic Stepper widget of flutter. if its not working properly then you need to create custom widget.

How to create This Ui in - Flutter

Hello there I'm new to flutter and I want to achieve this certain UI. from the UI I can see -
At the top it has a custom search bar I don't know if it's an appbar or not.
It has a SizedBox or something similar below the searchbar.
It has A listview.builder (I already Know how to achieve this)
So I would like to ask how to achieve the first two contents of the app
here is a screenshot of the app
You can take this as an example. a similar design.
import 'package:flutter/material.dart';
class FirstScreen extends StatefulWidget {
const FirstScreen({Key? key}) : super(key: key);
#override
State<FirstScreen> createState() => _FirstScreenState();
}
class _FirstScreenState extends State<FirstScreen> {
#override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: Column(
children: [
const SizedBox(
height: 30,
),
buildTitleText(context),
const SizedBox(
height: 30,
),
buildSearchBar(context),
const SizedBox(
height: 30,
),
buildSecondTitle(context),
const SizedBox(
height: 10,
),
buildContent(context)
],
),
),
);
}
SizedBox buildSecondTitle(BuildContext context) {
return SizedBox(
width: MediaQuery.of(context).size.width - 65,
child: Row(
children: const [
Text(
'Favorite Places',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
TextButton(
onPressed: null,
child: Text(
'See All',
style: TextStyle(color: Colors.blue, fontSize: 18),
)),
],
),
);
}
Container buildTitleText(BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width - 50,
child: const Text(
"What you would like to find?",
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 30,
),
),
);
}
SingleChildScrollView buildContent(BuildContext context) {
return SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
const SizedBox(
width: 25,
),
buildCityCard(context,
photoName: 'img_istanbul.jpg',
cityName: 'İstanbul',
cityActivity: '98 Aktivite',
cityScore: '4.8'),
const SizedBox(
width: 25,
),
buildCityCard(context,
photoName: 'img_mugla.jpg',
cityName: 'Muğla',
cityActivity: '102 Aktivite',
cityScore: '4.7'),
const SizedBox(
width: 25,
),
buildCityCard(context,
photoName: 'img_antalya.jpg',
cityName: 'Antalya',
cityActivity: '98 Aktivite',
cityScore: '4.5'),
const SizedBox(
width: 25,
),
],
),
);
}
Container buildSearchBar(BuildContext context) {
return Container(
width: MediaQuery.of(context).size.width - 65,
child: TextField(
decoration: InputDecoration(
prefixIcon: const Icon(
Icons.search,
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(360),
borderSide: const BorderSide(
color: Colors.blueAccent,
width: 2,
)),
labelText: "Locaiton",
),
),
);
}
Container buildCityCard(BuildContext context,
{required String photoName,
required String cityName,
required String cityActivity,
required String cityScore}) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.white,
),
height: MediaQuery.of(context).size.height / 2.5,
width: MediaQuery.of(context).size.height / 3.7,
child: Column(
children: [
Expanded(
flex: 5,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
color: Colors.blue,
image: DecorationImage(
image: AssetImage("assets/images/${photoName}"),
fit: BoxFit.fill,
),
),
),
),
const SizedBox(
height: 10,
),
Expanded(
flex: 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(
width: 20,
),
Icon(Icons.location_on, color: Colors.blue),
Text(
"${cityName}",
style: const TextStyle(
fontSize: 16, fontWeight: FontWeight.bold),
),
],
),
),
Expanded(
flex: 1,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(
width: 20,
),
const Icon(
Icons.star,
color: Colors.yellow,
),
Text(
"${cityScore}",
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
const Padding(
padding: EdgeInsets.fromLTRB(95, 0, 0, 0),
child: Icon(Icons.arrow_forward_ios),
),
],
),
),
const SizedBox(
height: 10,
),
],
),
);
}
}
This is the home. If you want to use tabbar.
import 'package:circle_bottom_navigation_bar/circle_bottom_navigation_bar.dart';
import 'package:circle_bottom_navigation_bar/widgets/tab_data.dart';
import 'package:flutter/material.dart';
import 'package:inovatif/third_screen.dart';
import 'first_screen.dart';
import 'second_screen.dart';
class HomeView extends StatefulWidget {
HomeView({Key? key}) : super(key: key);
static String routeName = 'home';
#override
State<HomeView> createState() => _HomeViewState();
}
class _HomeViewState extends State<HomeView> {
int currentPage = 0;
final List<Widget> _pages = [
FirstScreen(),
SecondScreen(),
ThirdScreen(),
];
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final viewPadding = MediaQuery.of(context).viewPadding;
double barHeight;
double barHeightWithNotch = 67;
double arcHeightWithNotch = 67;
if (size.height > 700) {
barHeight = 70;
} else {
barHeight = size.height * 0.1;
}
if (viewPadding.bottom > 0) {
barHeightWithNotch = (size.height * 0.07) + viewPadding.bottom;
arcHeightWithNotch = (size.height * 0.075) + viewPadding.bottom;
}
return Scaffold(
appBar: AppBar(backgroundColor: Colors.transparent, elevation: 0),
body: _pages[currentPage],
bottomNavigationBar: buildCircleBottomNavigationBar(
viewPadding, barHeightWithNotch, barHeight, arcHeightWithNotch),
);
}
CircleBottomNavigationBar buildCircleBottomNavigationBar(
EdgeInsets viewPadding,
double barHeightWithNotch,
double barHeight,
double arcHeightWithNotch) {
return CircleBottomNavigationBar(
initialSelection: currentPage,
barHeight: viewPadding.bottom > 0 ? barHeightWithNotch : barHeight,
arcHeight: viewPadding.bottom > 0 ? arcHeightWithNotch : barHeight,
itemTextOff: viewPadding.bottom > 0 ? 0 : 1,
itemTextOn: viewPadding.bottom > 0 ? 0 : 1,
circleOutline: 15.0,
shadowAllowance: 0.0,
circleSize: 50.0,
blurShadowRadius: 50.0,
circleColor: Colors.purple,
activeIconColor: Colors.white,
inactiveIconColor: Colors.grey,
tabs: getTabsData(),
onTabChangedListener: (index) => setState(() => currentPage = index),
);
}
List<TabData> getTabsData() {
return [
TabData(
icon: Icons.home,
iconSize: 25.0,
title: 'Home',
fontSize: 12,
fontWeight: FontWeight.bold,
),
TabData(
icon: Icons.phone,
iconSize: 25,
title: 'Emergency',
fontSize: 12,
fontWeight: FontWeight.bold,
),
TabData(
icon: Icons.search,
iconSize: 25,
title: 'Search Place',
fontSize: 12,
fontWeight: FontWeight.bold,
),
// TabData(
// icon: Icons.alarm,
// iconSize: 25,
// title: 'Alarm',
// fontSize: 12,
// fontWeight: FontWeight.bold,
// ),
];
}
}
To create an page like this you will need to know about Text,SingleChildScrollView set scroll direction to horizontal,Bottom Navigation bar,Banner etc.

how to overlap items on Appbar flutter

I want to achieve have a round icon for the profile image like in this example:
But is not working for me, this is what I achieved so far:
Widget build(BuildContext context) {
return Stack(
children: <Widget>[
ClipPath(
clipper: _AppBarProfileClipper(childHeight),
child: Container(
padding: const EdgeInsets.only(top: 48.0),
color: TheBaseColors.lightBlue,
height: height,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
leading,
FlatButton(
onPressed: null,
child: Text(
title,
style: TextStyle(
fontWeight: FontWeight.w600,
fontSize: 18.0,
color: Colors.white,
),
),
),
trailing,
],
),
),
),
Positioned(
bottom: childHeight / 2, //50
left: 0,
right: 0,
child: Align(
alignment: Alignment.bottomCenter,
child: child,
),
),
],
);
}
}
All the parameters are represented in the constructor and used in the code. But I cant figure out how to make that nice effect with the rounded icon.
Someone knows why is not working?
You can achieve given example like this:
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final double appBarHeight = 100.0;
final double spaceAroundRoundButton = 4.0;
final double roundedButtonSize = 64.0;
#override
Widget build(BuildContext context) {
var size = MediaQuery.of(context).size;
return SafeArea(
child: Stack(
children: <Widget>[
Scaffold(
backgroundColor: Colors.white,
appBar: PreferredSize(
preferredSize:
Size(MediaQuery.of(context).size.width, appBarHeight),
child: ClipPath(
clipper: BottomClipper(),
child: Container(
alignment: Alignment.topLeft,
height: appBarHeight,
color: Colors.black,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
icon: Icon(
Icons.menu,
color: Colors.white,
),
onPressed: () {}),
Text(
'User Profile',
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
IconButton(
icon: Icon(
Icons.settings,
color: Colors.white,
),
onPressed: () {})
],
),
),
)),
body: Container(
alignment: Alignment.topCenter,
margin: EdgeInsets.only(
top:
roundedButtonSize * 0.75 + spaceAroundRoundButton + 16.0),
child: Text('Body'),
),
),
Positioned(
child: Container(
padding: EdgeInsets.all(spaceAroundRoundButton),
decoration: BoxDecoration(
color: Colors.white,
shape: BoxShape.circle,
),
child: RawMaterialButton(
elevation: 0,
constraints: BoxConstraints.tightFor(
width: roundedButtonSize, height: roundedButtonSize),
shape: StadiumBorder(
side: BorderSide(width: 4, color: Colors.grey)),
child: Icon(Icons.person),
onPressed: () {},
fillColor: Colors.white,
),
),
left: (size.width / 2) -
(roundedButtonSize / 2) -
spaceAroundRoundButton,
top: appBarHeight -
(roundedButtonSize * 0.25) -
spaceAroundRoundButton,
)
],
),
);
}
}
class BottomClipper extends CustomClipper<Path> {
#override
Path getClip(Size size) {
var path = Path();
path.lineTo(0.0, size.height * 0.75);
var firstControlPoint = Offset(size.width * 0.25, size.height);
var firstEndPoint = Offset(size.width * 0.5, size.height);
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstEndPoint.dx, firstEndPoint.dy);
var secondControlPoint = Offset(size.width * 0.75, size.height);
var secondEndPoint = Offset(size.width, size.height * 0.75);
path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
secondEndPoint.dx, secondEndPoint.dy);
path.lineTo(size.width, 0.0);
path.close();
return path;
}
#override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
Screenshot:

A RenderFlex overflowed by 86 pixels on the bottom in Flutter

I am creating an app in flutter and in the portrait mode everything looks fine but when it comes to landscape mode it will be triggered with an error saying A RenderFlex overflowed by 86 pixels on the bottom. Below is my all code that I have tried and also I have shared the images, please refer to the same for more clarification.
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
brightness: Brightness.dark
),
debugShowCheckedModeBanner: false,
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomPadding: false,
body: new Stack(
children: <Widget>[
Container(
decoration: ShapeDecoration(
gradient:LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
colors: [Colors.yellow,Colors.yellow,Colors.orangeAccent,Colors.deepOrange,]
),
// color: Colors.deepOrangeAccent,
shape: CustomShapeBorder(),
),
),
Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 200.0,left: 50.0),
child: Text(
"SET, MATCH AND CHALLENGE",
style: TextStyle(
fontSize: 40.0,
),
),
),
Padding(
padding: const EdgeInsets.only(left: 30.0,right: 30.0, top: 30.0),
child: Text(
"A simple, fun, and a creative way to "
"set the bespoke challenges with "
"either a friend or a group of "
"friends anywhere in the world",
textAlign: TextAlign.justify,
style: TextStyle(
color: Colors.white
),
),
),
Container(
width: 300.0,
height: 60.0,
margin: const EdgeInsets.only(top: 140.0),
child: RaisedButton(
textColor: Colors.white,
color: Colors.grey,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(18.0),
),
child: Text("Sign Up",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.0,
),
),
),
),
],
),
Container(
margin: const EdgeInsets.only(bottom: 0.0, right: 0.0),
child: Align(
alignment: Alignment.bottomRight,
child: Transform.rotate(
angle: pi,
child: Container(
decoration: ShapeDecoration(
gradient:LinearGradient(
begin: Alignment.bottomLeft,
end: Alignment.topRight,
colors: [Colors.yellow,Colors.yellow,Colors.orangeAccent,Colors.deepOrange,]
),
//color: Colors.deepOrangeAccent,
shape: CustomShapeBorder(),
),
),
),
),
),
],
),
);
}
}
class CustomShapeBorder extends ShapeBorder {
final double distanceFromWall = 12;
final double controlPointDistanceFromWall = 5;
#override
// TODO: implement dimensions
EdgeInsetsGeometry get dimensions => null;
#override
Path getInnerPath(Rect rect, {TextDirection textDirection}) {
// TODO: implement getInnerPath
return null;
}
#override
Path getOuterPath(Rect rect, {TextDirection textDirection}) {
// TODO: implement getOuterPath
return getClip(Size(260.0,180.0));
}
#override
void paint(Canvas canvas, Rect rect, {TextDirection textDirection}) {
// TODO: implement paint
}
#override
ShapeBorder scale(double t) {
// TODO: implement scale
return null;
}
Path getClip(Size size) {
Path clippedPath = new Path();
clippedPath.lineTo(0, size.height);
clippedPath.quadraticBezierTo(30, size.height + 10, size.width * 0.20, size.height - 50);
clippedPath.quadraticBezierTo(70, size.height - 120, size.width * 0.40, size.height * 0.35);
clippedPath.quadraticBezierTo(180, (size.height - (size.height* 0.6)), size.width - 40 , 32 );
clippedPath.quadraticBezierTo(250, 0, size.width, 0);
clippedPath.lineTo(size.width, 0);
clippedPath.close();
return clippedPath;
}
}
Refer to below image for Portrait Mode
Refer to below image for Landscape Mode (Where error occurs):
The problem is that you are using hardcode margins in a Column widget, that will give you problems in small devices too. You can fix that changing you Column Widget for a ListView Widget, but that is going to give you a Scroll Effect, I think you don't want that. So you can refactor that Column using Expanded Widget and a Stack can help in the first part of the Column, try the next:
Column(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 50),
child: Stack(
children: <Widget>[
Center(
child: Text(
"SET, MATCH AND CHALLENGE",
style: TextStyle(
fontSize: 40.0,
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: Text(
"A simple, fun, and a creative way to "
"set the bespoke challenges with "
"either a friend or a group of "
"friends anywhere in the world",
textAlign: TextAlign.justify,
style: TextStyle(
color: Colors.white
),
),
)
],
),
),
),
Expanded(
flex: 1,
child: Center(
child: Container(
width: 300.0,
height: 60.0,
child: RaisedButton(
textColor: Colors.white,
color: Colors.grey,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(18.0),
),
child: Text("Sign Up",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 20.0,
),
),
),
),
),
)
],
)

Flutter: How to position a text in front of background?

i'm learning Flutter now. And i have some problem that my text "welcome" is not in front of the background but it . How can i fix it? I think it causes of container but i don't know how to order it correctly. Sorry for my bad code format.
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Login',
home: Scaffold(
body: ListView(
children: <Widget>[
Container(
child: Stack(
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(15, 11, 0, 0),
child: Text('Welcome', style: TextStyle( fontSize: 80, fontWeight: FontWeight.bold)),
)
],
),
),
Container(
color: Colors.orangeAccent[100],
alignment: Alignment.center,
width: 420,
height: 700,
child: CustomPaint(
painter: MyPainter(),
child: Align(
alignment: Alignment(0.0, 0.15),
child: RichText(
text: TextSpan(
style: DefaultTextStyle.of(context).style,
children: <TextSpan>[
TextSpan(
text: ' JUST BECAUSE YOU\n',
style: TextStyle(color: Colors.indigo[700], fontSize: 20, fontWeight: FontWeight.bold),
)
),
],
),
)
),
),
),
]
)
)
);
}
}
And this is my code for customPainter.
class MyPainter extends CustomPainter{
#override
void paint(ui.Canvas canvas, ui.Size size) {
//final width = size.width;
Path pigPath = Path();
Path ovalPath = Path();
pigPath.moveTo(0, size.height * 0.417);
pigPath.quadraticBezierTo(size.width * 0.25, size.height * 0.6,
size.width * 0.5, size.height * 0.37);
pigPath.quadraticBezierTo(size.width * 0.7, size.height * 0.23,
size.width * 1.0, size.height * 0.2);
pigPath.lineTo(size.width, size.height);
pigPath.lineTo(0, size.height);
paint.color = Colors.cyan[100];
canvas.drawPath(pigPath, paint);
}
#override
bool shouldRepaint(CustomPainter oldDelegate) => false;
}
This is my problem
Try this:
class MyApp extends StatelessWidget {
// This widget is the root of your application.
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Login',
home: Scaffold(
body: ListView(
children: <Widget>[
Container(
child: Stack(
children: <Widget>[
Container(
color: Colors.orangeAccent[100],
alignment: Alignment.center,
width: 420,
height: 700,
child: CustomPaint(
painter: MyPainter(),
child: Align(
alignment: Alignment(0.0, 0.15),
child: RichText(
text: TextSpan(
style: DefaultTextStyle.of(context).style,
children: <TextSpan>[
TextSpan(
text: ' JUST BECAUSE YOU\n',
style: TextStyle(color: Colors.indigo[700], fontSize: 20, fontWeight: FontWeight.bold),
)
),
],
),
)
),
),
),
Container(
padding: EdgeInsets.fromLTRB(15, 11, 0, 0),
child: Text('Welcome', style: TextStyle( fontSize: 80, fontWeight: FontWeight.bold)),
)
],
),
),
]
)
)
);
}
}