Skip to content

Instantly share code, notes, and snippets.

@rickyngan
rickyngan / main.dart
Created June 11, 2020 08:05
2020 Jun 13 HoC HK Flutter: 1_hello_dart_in_console
// void main() {
print('hello');
// }
@rickyngan
rickyngan / main.dart
Created June 11, 2020 08:03
2020 Jun 13 HoC HK Flutter: 2_hello_3times
void main() {
for (var i = 0; i < 3; i++) {
print('hello $i');
}
}
@rickyngan
rickyngan / main.dart
Last active June 11, 2020 18:02
2020 Jun 13 HoC HK Flutter: 3_hello_widget
import 'package:flutter/material.dart';
void main() {
runApp(
Center(
child: Text(
'Hello, world!',
textDirection: TextDirection.ltr,
),
),
@rickyngan
rickyngan / main.dart
Last active June 11, 2020 07:53
2020 Jun 13 HoC HK Flutter: 4_statelesswidget
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
@rickyngan
rickyngan / main.dart
Last active June 12, 2020 14:16
2020 Jun 13 HoC HK Flutter: 5_statefulwidget
import 'package:flutter/material.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
@rickyngan
rickyngan / main.dart
Created June 11, 2020 07:39
2020 Jun 13 HoC HK Flutter: 6_row_column
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
@rickyngan
rickyngan / main.dart
Last active June 11, 2020 07:30
2020 Jun 13 HoC HK Flutter: 7_route_navigator
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(
title: 'Navigation Basics',
home: FirstRoute(),
));
}
class FirstRoute extends StatelessWidget {
@rickyngan
rickyngan / main.dart
Last active October 7, 2020 14:04
2020 Jun 13 HoC HK Flutter: 8_bottom_navigation_bar
import 'package:flutter/material.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'My Flutter App',
home: Home(),
import UIKit
public extension UIView {
@available(iOS 10.0, *)
public func renderToImage(afterScreenUpdates: Bool = false) -> UIImage {
let rendererFormat = UIGraphicsImageRendererFormat.default()
rendererFormat.opaque = isOpaque
let renderer = UIGraphicsImageRenderer(size: bounds.size, format: rendererFormat)
let snapshotImage = renderer.image { _ in
@rickyngan
rickyngan / gist:b2ce9b88594e1f88ac1599d250803c1f
Created September 28, 2016 07:22
UISearchBar extension
import UIKit
extension UISearchBar {
var textField: UITextField? {
return self.value(forKey: "_searchField") as? UITextField
}
}