Curved Shape Background Header in Flutter
I have a list view with "Hero" icons on the left. When I click a list item, it loads the next screen with the article text and the Hero image (which animates nicely/automatically to the correct spot on the 2nd screen).
I would have thought that was the "tough" part, but I'm now trying to get a curved shape as the top background of the 2nd screen. I would love to make it a drawn vector shape, as opposed to a bitmap and even have it drip/bounce onto the page, but at the moment...
I'm just trying to figure out how to:
- draw a vector shape
- have it as the background of a screen with other widgets on top (see purple curve on 2nd screen below)
dart flutter
|
show 4 more comments
I have a list view with "Hero" icons on the left. When I click a list item, it loads the next screen with the article text and the Hero image (which animates nicely/automatically to the correct spot on the 2nd screen).
I would have thought that was the "tough" part, but I'm now trying to get a curved shape as the top background of the 2nd screen. I would love to make it a drawn vector shape, as opposed to a bitmap and even have it drip/bounce onto the page, but at the moment...
I'm just trying to figure out how to:
- draw a vector shape
- have it as the background of a screen with other widgets on top (see purple curve on 2nd screen below)
dart flutter
This might help you.
– Jerome Escalante
Jan 2 at 1:34
@JeromeEscalante I don't think it should require masking off an image or a block of color. (should it?) I think there's a way to create a shape with flutter.
– Dave
Jan 2 at 1:38
Flutter has full blown Canvas, and Path classes if you want a lower level control instead of ClipPath solution
– Ajay Beniwal
Jan 2 at 6:29
1
"I think there's a way to create a shape with flutter."
- seeShapeBorder
class (or useCustomPaint
to have the full control on what you want to draw)
– pskink
Jan 2 at 9:03
@pskink I saw this class, but couldn't find any reasonable examples to follow or learn. :/
– Dave
Jan 2 at 15:52
|
show 4 more comments
I have a list view with "Hero" icons on the left. When I click a list item, it loads the next screen with the article text and the Hero image (which animates nicely/automatically to the correct spot on the 2nd screen).
I would have thought that was the "tough" part, but I'm now trying to get a curved shape as the top background of the 2nd screen. I would love to make it a drawn vector shape, as opposed to a bitmap and even have it drip/bounce onto the page, but at the moment...
I'm just trying to figure out how to:
- draw a vector shape
- have it as the background of a screen with other widgets on top (see purple curve on 2nd screen below)
dart flutter
I have a list view with "Hero" icons on the left. When I click a list item, it loads the next screen with the article text and the Hero image (which animates nicely/automatically to the correct spot on the 2nd screen).
I would have thought that was the "tough" part, but I'm now trying to get a curved shape as the top background of the 2nd screen. I would love to make it a drawn vector shape, as opposed to a bitmap and even have it drip/bounce onto the page, but at the moment...
I'm just trying to figure out how to:
- draw a vector shape
- have it as the background of a screen with other widgets on top (see purple curve on 2nd screen below)
dart flutter
dart flutter
asked Jan 2 at 0:59
DaveDave
22.8k1487151
22.8k1487151
This might help you.
– Jerome Escalante
Jan 2 at 1:34
@JeromeEscalante I don't think it should require masking off an image or a block of color. (should it?) I think there's a way to create a shape with flutter.
– Dave
Jan 2 at 1:38
Flutter has full blown Canvas, and Path classes if you want a lower level control instead of ClipPath solution
– Ajay Beniwal
Jan 2 at 6:29
1
"I think there's a way to create a shape with flutter."
- seeShapeBorder
class (or useCustomPaint
to have the full control on what you want to draw)
– pskink
Jan 2 at 9:03
@pskink I saw this class, but couldn't find any reasonable examples to follow or learn. :/
– Dave
Jan 2 at 15:52
|
show 4 more comments
This might help you.
– Jerome Escalante
Jan 2 at 1:34
@JeromeEscalante I don't think it should require masking off an image or a block of color. (should it?) I think there's a way to create a shape with flutter.
– Dave
Jan 2 at 1:38
Flutter has full blown Canvas, and Path classes if you want a lower level control instead of ClipPath solution
– Ajay Beniwal
Jan 2 at 6:29
1
"I think there's a way to create a shape with flutter."
- seeShapeBorder
class (or useCustomPaint
to have the full control on what you want to draw)
– pskink
Jan 2 at 9:03
@pskink I saw this class, but couldn't find any reasonable examples to follow or learn. :/
– Dave
Jan 2 at 15:52
This might help you.
– Jerome Escalante
Jan 2 at 1:34
This might help you.
– Jerome Escalante
Jan 2 at 1:34
@JeromeEscalante I don't think it should require masking off an image or a block of color. (should it?) I think there's a way to create a shape with flutter.
– Dave
Jan 2 at 1:38
@JeromeEscalante I don't think it should require masking off an image or a block of color. (should it?) I think there's a way to create a shape with flutter.
– Dave
Jan 2 at 1:38
Flutter has full blown Canvas, and Path classes if you want a lower level control instead of ClipPath solution
– Ajay Beniwal
Jan 2 at 6:29
Flutter has full blown Canvas, and Path classes if you want a lower level control instead of ClipPath solution
– Ajay Beniwal
Jan 2 at 6:29
1
1
"I think there's a way to create a shape with flutter."
- see ShapeBorder
class (or use CustomPaint
to have the full control on what you want to draw)– pskink
Jan 2 at 9:03
"I think there's a way to create a shape with flutter."
- see ShapeBorder
class (or use CustomPaint
to have the full control on what you want to draw)– pskink
Jan 2 at 9:03
@pskink I saw this class, but couldn't find any reasonable examples to follow or learn. :/
– Dave
Jan 2 at 15:52
@pskink I saw this class, but couldn't find any reasonable examples to follow or learn. :/
– Dave
Jan 2 at 15:52
|
show 4 more comments
1 Answer
1
active
oldest
votes
I made a full sample for your curved shape in a gist here
I used CustomPainter to draw on a canvas then, with some geometric calculations, I achieved the curved shape.
Final result
How I draw it?
Before coding and on a Whiteboard I determined somethings:
My Canvas Area:
- The canvas dimensions I need to draw that shape (which equals to Flutter widget's dimensions).
How and where my brush will move?
- how means: what are the APIs I need to draw that shape on the canvas using the Path class.
e.g. lineTo() for a straight line, quadraticBezierTo() for a curve. - where means: Where are the points (coordinates) I need to draw the whole shape. (see yellow and green dots in the image above)
- how means: what are the APIs I need to draw that shape on the canvas using the Path class.
Points (coordinates) Calculations:
- I used some geometric equations to calculate the coordinates. e.g. Point on a circle’s circumference
- All of my calculations depend on the canvas size, that gives me a responsive shape.
- I used some geometric equations to calculate the coordinates. e.g. Point on a circle’s circumference
Full sample here!
1
Works wonderfully AND serves as a great example as a learning exercise! Thanks!
– Dave
Jan 3 at 1:35
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000161%2fcurved-shape-background-header-in-flutter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I made a full sample for your curved shape in a gist here
I used CustomPainter to draw on a canvas then, with some geometric calculations, I achieved the curved shape.
Final result
How I draw it?
Before coding and on a Whiteboard I determined somethings:
My Canvas Area:
- The canvas dimensions I need to draw that shape (which equals to Flutter widget's dimensions).
How and where my brush will move?
- how means: what are the APIs I need to draw that shape on the canvas using the Path class.
e.g. lineTo() for a straight line, quadraticBezierTo() for a curve. - where means: Where are the points (coordinates) I need to draw the whole shape. (see yellow and green dots in the image above)
- how means: what are the APIs I need to draw that shape on the canvas using the Path class.
Points (coordinates) Calculations:
- I used some geometric equations to calculate the coordinates. e.g. Point on a circle’s circumference
- All of my calculations depend on the canvas size, that gives me a responsive shape.
- I used some geometric equations to calculate the coordinates. e.g. Point on a circle’s circumference
Full sample here!
1
Works wonderfully AND serves as a great example as a learning exercise! Thanks!
– Dave
Jan 3 at 1:35
add a comment |
I made a full sample for your curved shape in a gist here
I used CustomPainter to draw on a canvas then, with some geometric calculations, I achieved the curved shape.
Final result
How I draw it?
Before coding and on a Whiteboard I determined somethings:
My Canvas Area:
- The canvas dimensions I need to draw that shape (which equals to Flutter widget's dimensions).
How and where my brush will move?
- how means: what are the APIs I need to draw that shape on the canvas using the Path class.
e.g. lineTo() for a straight line, quadraticBezierTo() for a curve. - where means: Where are the points (coordinates) I need to draw the whole shape. (see yellow and green dots in the image above)
- how means: what are the APIs I need to draw that shape on the canvas using the Path class.
Points (coordinates) Calculations:
- I used some geometric equations to calculate the coordinates. e.g. Point on a circle’s circumference
- All of my calculations depend on the canvas size, that gives me a responsive shape.
- I used some geometric equations to calculate the coordinates. e.g. Point on a circle’s circumference
Full sample here!
1
Works wonderfully AND serves as a great example as a learning exercise! Thanks!
– Dave
Jan 3 at 1:35
add a comment |
I made a full sample for your curved shape in a gist here
I used CustomPainter to draw on a canvas then, with some geometric calculations, I achieved the curved shape.
Final result
How I draw it?
Before coding and on a Whiteboard I determined somethings:
My Canvas Area:
- The canvas dimensions I need to draw that shape (which equals to Flutter widget's dimensions).
How and where my brush will move?
- how means: what are the APIs I need to draw that shape on the canvas using the Path class.
e.g. lineTo() for a straight line, quadraticBezierTo() for a curve. - where means: Where are the points (coordinates) I need to draw the whole shape. (see yellow and green dots in the image above)
- how means: what are the APIs I need to draw that shape on the canvas using the Path class.
Points (coordinates) Calculations:
- I used some geometric equations to calculate the coordinates. e.g. Point on a circle’s circumference
- All of my calculations depend on the canvas size, that gives me a responsive shape.
- I used some geometric equations to calculate the coordinates. e.g. Point on a circle’s circumference
Full sample here!
I made a full sample for your curved shape in a gist here
I used CustomPainter to draw on a canvas then, with some geometric calculations, I achieved the curved shape.
Final result
How I draw it?
Before coding and on a Whiteboard I determined somethings:
My Canvas Area:
- The canvas dimensions I need to draw that shape (which equals to Flutter widget's dimensions).
How and where my brush will move?
- how means: what are the APIs I need to draw that shape on the canvas using the Path class.
e.g. lineTo() for a straight line, quadraticBezierTo() for a curve. - where means: Where are the points (coordinates) I need to draw the whole shape. (see yellow and green dots in the image above)
- how means: what are the APIs I need to draw that shape on the canvas using the Path class.
Points (coordinates) Calculations:
- I used some geometric equations to calculate the coordinates. e.g. Point on a circle’s circumference
- All of my calculations depend on the canvas size, that gives me a responsive shape.
- I used some geometric equations to calculate the coordinates. e.g. Point on a circle’s circumference
Full sample here!
edited Jan 3 at 6:22
answered Jan 2 at 10:17
Tarek360Tarek360
379312
379312
1
Works wonderfully AND serves as a great example as a learning exercise! Thanks!
– Dave
Jan 3 at 1:35
add a comment |
1
Works wonderfully AND serves as a great example as a learning exercise! Thanks!
– Dave
Jan 3 at 1:35
1
1
Works wonderfully AND serves as a great example as a learning exercise! Thanks!
– Dave
Jan 3 at 1:35
Works wonderfully AND serves as a great example as a learning exercise! Thanks!
– Dave
Jan 3 at 1:35
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000161%2fcurved-shape-background-header-in-flutter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This might help you.
– Jerome Escalante
Jan 2 at 1:34
@JeromeEscalante I don't think it should require masking off an image or a block of color. (should it?) I think there's a way to create a shape with flutter.
– Dave
Jan 2 at 1:38
Flutter has full blown Canvas, and Path classes if you want a lower level control instead of ClipPath solution
– Ajay Beniwal
Jan 2 at 6:29
1
"I think there's a way to create a shape with flutter."
- seeShapeBorder
class (or useCustomPaint
to have the full control on what you want to draw)– pskink
Jan 2 at 9:03
@pskink I saw this class, but couldn't find any reasonable examples to follow or learn. :/
– Dave
Jan 2 at 15:52