Flutter logo in dart pattern

 

Image for post

Complete Code:-

void main() {
int row = 8;
int col = 3;
for (int i = 1; i <= row; i++) {
if (i <= 3) {
print(" " * (4 - i) + "* " * col);
}
if (i == 4) {
print("* * * * * * ");
}
if (i == 5) {
print(" * * * * ");
}
if (i >= 6) {
print(" " * (i - 4) + "* " * col);
}
}
}

In the first three rows of the logo, we show a rhombus pattern so we make this rhombus pattern by this code.

if (i <= 3) {
print(" " * (4 - i) + "* " * col);
}

The next two lines do not follow any pattern so we print these patterns directly.

if (i == 4) {
print("* * * * * * ");
}
if (i == 5) {
print(" * * * * ");
}

and in the last other lines, we again show a rhombus pattern so we make this rhombus pattern by this code.

if (i >= 6) {
print(" " * (i - 4) + "* " * col);
}

you can run this code here.

Post a Comment

Previous Post Next Post

Subscribe Us


Get tutorials, Flutter news and other exclusive content delivered to your inbox. Join 1000+ growth-oriented Flutter developers subscribed to the newsletter

100% value, 0% spam. Unsubscribe anytime