diff --git a/lib/patterns/patterns.dart b/lib/patterns/patterns.dart index fdbd7e0..981660a 100644 --- a/lib/patterns/patterns.dart +++ b/lib/patterns/patterns.dart @@ -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, + ); + } +} diff --git a/lib/widgets/detailView.dart b/lib/widgets/detailView.dart index 594d9b9..61b6224 100644 --- a/lib/widgets/detailView.dart +++ b/lib/widgets/detailView.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:widget_with_codeview/widget_with_codeview.dart'; class DetailView extends StatelessWidget { DetailView({ @@ -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", + ), ); } } diff --git a/lib/widgets/homePage.dart b/lib/widgets/homePage.dart index 50baae6..53a8d1e 100644 --- a/lib/widgets/homePage.dart +++ b/lib/widgets/homePage.dart @@ -69,5 +69,8 @@ class _HomePageState extends State { Pattern14(), Pattern15(), Pattern21(), + Pattern24(), + Pattern26(), + Pattern27(), ]; } diff --git a/pubspec.lock b/pubspec.lock index 9add687..ce00769 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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: @@ -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: @@ -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: @@ -184,6 +203,34 @@ 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: @@ -191,6 +238,13 @@ packages: 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: @@ -200,3 +254,4 @@ packages: version: "3.5.0" sdks: dart: ">=2.4.0 <3.0.0" + flutter: ">=1.12.8 <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 737d354..a1132cc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: @@ -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.