Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Guide

Fork this repo, and add/fix the missing code in [/bin/dart_application_1.dart](/bin/dart_application_1.dart)

<img src="errors_in_dart_application_1.dart.png" width="400" alt="To be fixed errors"/>
Added/fixed the missing code in [/bin/dart_application_1.dart](/bin/dart_application_1.dart)

<img src="fix errors_in_dart_application_1.dart.png" width="600" alt="fixed errors"/>

47 changes: 33 additions & 14 deletions bin/dart_application_1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,53 @@ class View {
Color? color;

View(this.id, {this.color});

@override
@override
String toString() {
return '$id';
}

}
class Text extends View{
String? content;

Text(int id, this.content, {Color? color}) : super(id, color: color);
/* if we want to print the content and id
* we can add this and remove the toString method in the View class
@override
String toString() {
return '$content and $id';
} */
}

void main() {
/*
1) Create class named `Text` that extends/inherits `View` class,
and has a `String content` property.
Here is the Text constuctor:
Text(int id, this.content, {Color? color}) : super(id, color: color)
2) Create new `Text` object with the following:
var helloText = Text(<random id>, content: 'Hello' )
*/

int id = Random().nextInt(10000);

var helloText = Text(id,'Hello');

print('hello: $helloText');
//this will output [hello: "number"] number will be different after every run because it's random number
task2();
/*
this will call the task2()

*/
}

void task2() {
List<int> numbers = List.generate(75, (index) => Random().nextInt(10000));
List<int> evenNumbers=[];

/*
Separate even numbers from the above `numbers` list.
List<int> evenNumbers = ...
Looping through the `numbers` list.
If the number even it will be add to the evenNumbers list
*/
for (final i in numbers) {
if (i.isEven) {
evenNumbers.add(i);

}}
print('evenNumbers: $evenNumbers');
/*
And this will print the even numbers from the list numbers like this
evenNumbers: [3358, 2752, 524, 2528, 736, 4464, 3546, 8026, 2732, 5556, 5042, 746, 1728, 7732, 7952, 2166, 4750, 420, 136, 3280, 6756, 6538, 3618, 6884, 9830, 1796, 618, 7304, 1566, 8920, 9736]
*/
}
Binary file removed errors_in_dart_application_1.dart.png
Binary file not shown.
Binary file added fix errors_in_dart_application_1.dart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.