Question:
I am working on a Flutter project and aiming to replicate the design shown in the following image:
How can I achieve a similar layout and design in Flutter? Below is the code I have tried so far:
CODE I TRIED:
import 'package:flutter/material.dart';
class OnboardingScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
ClipPath(
clipper: InverseWaveClipper(),
child: Container(
color: Colors.green,
height: MediaQuery.of(context).size.height *
0.5,
width: double.infinity,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"أهلاً",
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold,
),
),
Text(
"مرحباً بك في فيت بوكس",
style: TextStyle(
color: Colors.white,
fontSize: 20,
),
),
],
),
),
),
),
Expanded(
child: Container(
color: Colors.white,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"قبل أن نبدأ الرحله،",
style: TextStyle(
color: Colors.black,
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
Text(
"دعونا نتحدث",
style: TextStyle(
color: Colors.black,
fontSize: 20,
),
),
SizedBox(height: 20),
TextField(
decoration: InputDecoration(
hintText: "أدخل اسمك",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
),
),
),
SizedBox(height: 20),
ElevatedButton(
onPressed: () {},
child: Text("التالي"),
),
],
),
),
),
),
],
),
);
}
}
class InverseWaveClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
var path = Path();
path.lineTo(0, size.height - 60);
var controlPoint1 = Offset(size.width / 4, size.height - 100);
var endPoint1 = Offset(size.width / 2, size.height - 60);
path.quadraticBezierTo(
controlPoint1.dx, controlPoint1.dy, endPoint1.dx, endPoint1.dy);
var controlPoint2 = Offset(size.width * 3 / 4, size.height - 20);
var endPoint2 = Offset(size.width, size.height - 60);
path.quadraticBezierTo(
controlPoint2.dx, controlPoint2.dy, endPoint2.dx, endPoint2.dy);
path.lineTo(size.width, 0);
path.close();
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return false;
}
}
I’m stucked in this problem, Any guidance or suggestions would be greatly appreciated!
2
Answers
take a container with green backgroud
then add column and 2 more containers
make first container’s radius only on right bottom
and make 2nd contaienr’s radius only on top left.
this will work.
I have created a custom layout by trying below code
Change height, width and border radius as your requirement.