This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import "dart:math" as math; | |
| class Point { | |
| /* | |
| Declare a constructor by creating a function with the same name as its class (plus, optionally, an additional identifier as described in Named constructors) | |
| */ | |
| num x, y; | |
| // Constructor | |
| //Point(num x, num y) { | |
| // The "this" keyword refers to the current instance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 導入 dart:html | |
| // 注意每一段可執行的程式敘述句最後要有 ; | |
| import 'dart:html'; | |
| // 每一個 dart 程式都從 main() 主函式開始執行, void 表示此函式沒有傳回值, void 在此可以省略 | |
| void main() { | |
| // 超過一行的程式區段, 以大括號區隔 | |
| // querySelector 函式屬於 dart:html 中的一員, 專門用來取 html 中的特定 Element | |
| // 當 id 為 button 的 Element 被按下後 (onClick 為 Element 的 properties 之一), 會傳回 stream, 交給 listen 方法, 用來啟動 sayHello 函式 | |
| querySelector("#button").onClick.listen(sayHello); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter_web/material.dart'; | |
| import 'package:flutter_web_ui/ui.dart' as ui; | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Hi Kmol', | |
| home: Scaffold( | |
| appBar: AppBar( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter_web/material.dart'; | |
| import 'package:flutter_web_ui/ui.dart' as ui; | |
| Future<void> main() async { | |
| await ui.webOnlyInitializePlatform(); | |
| runApp(MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Copyright 2014 David Kopec | |
| // Created for Dart for Absolute Beginners, an Apress title | |
| // This source code is released under the terms outlined in license.txt in the | |
| // source code respository's root directory. | |
| import 'dart:html'; | |
| bool imperial = true; | |
| const int IMPERIAL_MULTIPLIER = 703; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import "dart:math" as math; | |
| class Point { | |
| // x, y are both final, can not be set to new coordinate | |
| final num x, y; | |
| Point(this.x, this.y); | |
| Point.origin() | |
| : x = 0, | |
| y = 0; | |
| num distanceTo(Point other) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <canvas id="dart_canvas_example" height='500' width='500'> | |
| Your browser does not support Canvas | |
| </canvas> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 導入 dart 的核心數學程式庫, 並設其名稱為 math | |
| import "dart:math" as math; | |
| // 定義一個類別, 名稱為 Point | |
| class Point{ | |
| // 定應兩個案例變數 x 與 y 資料型別為 num, 表示可以是整數或幅點數 | |
| num x; | |
| num y; | |
| // 定義一個與類別名稱相同的建構子 (建立案例時, 會自動執行此一建構子方法內容), 具有兩個輸入變數 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:convert'; | |
| main() { | |
| var stud_no; | |
| var lists = json.decode(''' | |
| [[40523120, 40723102, 40723110, 40723112, 40723115, 40723120, 40723127, 40723136, 40723140, 40723143, 40723146, 40723148], [40523148, 40523241, 40723118, 40723129, 40723132, 40723135, 40723138, 40723139, 40723141, 40723144, 40723145, 40723153], [40523142, 40723104, 40723106, 40723108, 40723111, 40723121, 40723123, 40723126, 40723128, 40723130, 40723133], [40423218, 40623123, 40623143, 40723134, 40723137, 40723142, 40723147, 40723149, 40723150, 40723151, 40723154], [40523113, 40723101, 40723103, 40723107, 40723114, 40723119, 40723122, 40723124, 40723125, 40723152, 40723155]]'''); | |
| for (int i = 0; i < lists.length; i++) { | |
| print('=' * 20 + "<br />"); | |
| print("第 ${i + 1} 組成員:" + "<br />"); | |
| for (int j = 0; j < lists[i].length; j++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pkg_resources | |
| from subprocess import call | |
| packages = [dist.project_name for dist in pkg_resources.working_set] | |
| print(packages) | |
| print() | |
| call("python -m pip install --upgrade " + ' '.join(packages), shell=True) |