From b7eb4696c383c078eb83bc1d9c873da088cba126 Mon Sep 17 00:00:00 2001 From: ibrahim <44411366+ibrahim99000@users.noreply.github.com> Date: Sun, 26 Sep 2021 00:10:44 +0300 Subject: [PATCH] solution the dart task --- dart_application_1.dart | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 dart_application_1.dart diff --git a/dart_application_1.dart b/dart_application_1.dart new file mode 100644 index 0000000..33677ca --- /dev/null +++ b/dart_application_1.dart @@ -0,0 +1,50 @@ +import 'dart:math'; + +class Color { + Color(this.value); + final int value; +} + +void main() { + var helloText; + /*ؤم + 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(, content: 'Hello' ) + */ + + int id = Random().nextInt(10000); + helloText = Text(id, content: 'Hello'); + print('hello: $helloText'); + task2(); +} + +void task2() { + List numbers = List.generate(75, (index) => Random().nextInt(10000)); + List evenNumbers = []; + for (final n in numbers) { + if (n.isEven) { + evenNumbers.add(n); + } + } + + print('evenNumbers: $evenNumbers'); +} + +class Text extends View { + Text(int id, {String? content}) : super(id); +} + +class View { + int id; + Color? color; + View(this.id, {this.color}); + + @override + String toString() { + return '$id' ; + } +}