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:intl/intl.dart'; | |
void main() { | |
final now = DateTime.now(); | |
print('isUTC: ${now.isUtc}'); // <- false | |
print('now: $now'); // <- now: 2021-12-16 07:58:03.661 | |
final hms = DateFormat.Hms().format(now); | |
print('hms: $hms'); // <- hms: 07:58:03 | |
} |
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/material.dart'; | |
import 'package:flutter_riverpod/flutter_riverpod.dart'; | |
class AsyncValueBuilder<R> extends StatelessWidget { | |
const AsyncValueBuilder({ | |
Key? key, | |
required this.asyncValue, | |
required this.builder, | |
}) : super(key: key); |
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/material.dart'; | |
enum AppForm { | |
first, | |
second, | |
third, | |
} | |
extension AppFormExt on AppForm { | |
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
class Cat { | |
const Cat(this.name); | |
final String name; | |
} | |
void f<T>(T arg) { | |
if (arg is String) { | |
print('This is String!'); | |
} |
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
/// Factory Constructorを使ったシングルトンクラスの定義方法 | |
class FactorySinglton { | |
/// 初めてインスタンス化するときにfactoryコンストラクタから使用する、Privateなコンストラクタ | |
FactorySinglton._() { | |
print('FactorySingleton Constructed'); | |
} | |
/// シングルトンを実現するインスタンスを提供 | |
factory FactorySinglton.instance() => _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
enum Sport { | |
baseball, | |
football, | |
tennis, | |
swimming, | |
} | |
void main() { | |
final list = [Sport.baseball,Sport.football, Sport.tennis]; | |
final hasTennis = list.contains(Sport.tennis); |
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
void main() { | |
final items = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']; | |
final chunkedItems = []; | |
final chunkSize = 3; | |
for (var i = 0; i < items.length; i += chunkSize) { | |
final isLast = i + chunkSize >= items.length; | |
final end = isLast ? items.length : i + chunkSize; | |
chunkedItems.add(items.sublist(i, end)); | |
} |
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
void main() { | |
final items = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k']; | |
final chunkedItems = []; | |
final chunkSize = 3; | |
var count = 0; | |
do { | |
chunkedItems.add(items.skip(count).take(chunkSize).toList()); | |
count += chunkSize; | |
} while (count < items.length); |
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/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( |