Skip to content

Commit

Permalink
+ 4 patterns + code View - Not that good
Browse files Browse the repository at this point in the history
  • Loading branch information
yc-codes committed Feb 27, 2020
1 parent 18ae5fe commit 8b2522b
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 3 deletions.
91 changes: 91 additions & 0 deletions lib/patterns/patterns.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,94 @@ class Pattern21 extends StatelessWidget {
);
}
}

class Pattern24 extends StatelessWidget {
@override
Widget build(BuildContext context) {
var space = 4;
var result = "";
for (int i = 1; i <= 5; i++) {
result = result + "_" * space;
for (var j = 1; j <= 5; j++) {
result = result + ((j == 1 || j == 5 || i == 1 || i == 5) ? "*" : "_");
}
result = result + "\n";
space--;
}
return PrintPattern(
result: result,
);
}
}

class Pattern26 extends StatelessWidget {
@override
Widget build(BuildContext context) {
var result = "";
var count = 5;
for (var i = 1; i <= count; i++) {
for (int j = 1; j <= i; j++) {
result = result + "*";
}
for (int k = i * 2; k <= count * 2 - 1; k++) {
result = result + "_";
}
for (int l = 1; l <= i; l++) {
result = result + "*";
}
result = result + "\n";
}
for (int i = 1; i <= count - 1; i++) {
for (int j = count - 1; j >= i; j--) {
result = result + "*";
}
for (int k = 1; k <= i * 2; k++) {
result = result + "_";
}
for (int l = count - 1; l >= i; l--) {
result = result + "*";
}
result = result + "\n";
}
return PrintPattern(
result: result,
);
}
}

class Pattern27 extends StatelessWidget {
@override
Widget build(BuildContext context) {
var count = 5;
var result = "";
for (int i = 1; i <= count; i++) {
for (int j = i; j <= count; j++) {
result = result + "*";
}
for (int k = 1; k <= i * 2 - 2; k++) {
result = result + "_";
}
for (int l = i; l <= count; l++) {
result = result + "*";
}
result = result + "\n";
}

for (int i = 1; i <= count; i++) {
for (int j = 1; j <= i; j++) {
result = result + "*";
}
for (int k = i * 2 - 2; k < count * 2 - 2; k++) {
result = result + "_";
}
for (int l = 1; l <= i; l++) {
result = result + "*";
}

result = result + "\n";
}
return PrintPattern(
result: result,
);
}
}
11 changes: 10 additions & 1 deletion lib/widgets/detailView.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:widget_with_codeview/widget_with_codeview.dart';

class DetailView extends StatelessWidget {
DetailView({
Expand All @@ -8,7 +9,15 @@ class DetailView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: view,
appBar: AppBar(
elevation: 0,
),
body: WidgetWithCodeView(
child: Center(
child: view,
),
sourceFilePath: "lib/patterns/patterns.dart",
),
);
}
}
3 changes: 3 additions & 0 deletions lib/widgets/homePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@ class _HomePageState extends State<HomePage> {
Pattern14(),
Pattern15(),
Pattern21(),
Pattern24(),
Pattern26(),
Pattern27(),
];
}
55 changes: 55 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
animated_floatactionbuttons:
dependency: transitive
description:
name: animated_floatactionbuttons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.0"
animations:
dependency: "direct main"
description:
Expand Down Expand Up @@ -81,6 +88,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
Expand Down Expand Up @@ -123,6 +135,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
quiver:
dependency: transitive
description:
Expand Down Expand Up @@ -184,13 +203,48 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
url_launcher:
dependency: transitive
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "5.4.2"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+4"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.6"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+1"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
widget_with_codeview:
dependency: "direct main"
description:
name: widget_with_codeview
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
xml:
dependency: transitive
description:
Expand All @@ -200,3 +254,4 @@ packages:
version: "3.5.0"
sdks:
dart: ">=2.4.0 <3.0.0"
flutter: ">=1.12.8 <2.0.0"
5 changes: 3 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
animations: ^1.0.0+5
widget_with_codeview: ^1.0.3

dev_dependencies:
flutter_test:
Expand All @@ -39,8 +40,8 @@ flutter:
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
assets:
- lib/patterns/patterns.dart
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
Expand Down

0 comments on commit 8b2522b

Please sign in to comment.