This file contains 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/material.dart'; | |
import 'package:hooks_riverpod/hooks_riverpod.dart'; | |
import 'package:go_router/go_router.dart'; | |
enum AuthState { | |
guest, | |
registered, | |
} | |
final authProvider = StateProvider((ref) => AuthState.guest); |
This file contains 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
void main() { | |
final astronauts = 0; | |
try { | |
if (astronauts == 0) { | |
throw StateError('No astronauts.'); | |
} | |
} catch (e) { | |
print(e); | |
} |
This file contains 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
class Spacecraft { | |
final String name; | |
Spacecraft(this.name); | |
} | |
const oneSecond = Duration(seconds: 1); | |
// ··· | |
Future<void> printWithDelay(String message) async { | |
await Future.delayed(oneSecond); |
This file contains 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
class Spacecraft { | |
void describe() { | |
print('hi'); | |
} | |
} | |
class MockSpaceship implements Spacecraft { | |
@override | |
void describe() { | |
print('mock'); |
This file contains 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
class Spacecraft {} | |
mixin Piloted { | |
int astronauts = 1; | |
void describeCrew() { | |
print('Number of astronauts: $astronauts'); | |
} | |
} |
This file contains 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
class Spacecraft { | |
String name; | |
DateTime? launchDate; | |
int? get launchYear => launchDate?.year; | |
Spacecraft(this.name, this.launchDate) {} | |
Spacecraft.unlaunched(String name) : this(name, null); |
This file contains 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
enum PlanetType { terrestrial, gas, ice } | |
/// 太陽系の惑星を列挙する | |
enum Planet { | |
mercury(planetType: PlanetType.terrestrial, moons: 0, hasRings: false), | |
venus(planetType: PlanetType.terrestrial, moons: 0, hasRings: false), | |
// ··· | |
uranus(planetType: PlanetType.ice, moons: 27, hasRings: true), | |
neptune(planetType: PlanetType.ice, moons: 14, hasRings: true); |
This file contains 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
class Spacecraft { | |
// プロパティ | |
String name; | |
DateTime? launchDate; | |
// 読み込み専用プロパティのgetter | |
int? get launchYear => launchDate?.year; | |
// コンストラクタ。`this.`の糖衣構文によって引数をメンバに代入しています | |
Spacecraft(this.name, this.launchDate) { |
This file contains 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コアライブラリをインポート | |
import 'dart:math'; | |
// パッケージのライブラリをインポート | |
import 'package:test/test.dart'; | |
// 別ファイルをインポート | |
// ファイルがないためコメントアウト | |
// import 'path/to/my_other_file.dart'; |
This file contains 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
// 通常の一行コメントです。 | |
/// ドキュメンテーションコメントです。 | |
/// クラスやメンバーの説明を文書として説明できます。 | |
/// IDEやエディタでは見やすく表示されます。 | |
/* このようなコメントもサポートされています。 */ | |
void main() { | |
} |
NewerOlder