Skip to content

Instantly share code, notes, and snippets.

class TabBarWidget extends StatefulWidget {
@override
_TabBarWidgetState createState() => _TabBarWidgetState();
}
class _TabBarWidgetState extends State<TabBarWidget> {
List<Widget> _widgets = [
DashboardPage(),
import UIKit
protocol ExtendedTitleNavigationBarTouchResponder {}
extension UISegmentedControl: ExtendedTitleNavigationBarTouchResponder {}
extension UIView {
func hitTestSubviews(point: CGPoint, with event: UIEvent?) -> UIView? {
for subview in subviews {
import UIKit
struct ComplexObject: Decodable {
let timestamp: Int
let identifier: String
}
extension ComplexObject {
enum CodingKeys: String, CodingKey {
case timestamp
// Test
let json = """
{
"TjOnekTbvbh7XW7aTgEiyr2pccq1": 1565244404531,
"Zu9ujNWUi0fSz3Y8pNFJ8PV4Phk1": "some string value",
"AC5cZbp4XyPJfTu4zf9TfRQWRY02": {
"timestamp": 1566474347575,
"identifier": "Cu9BjNKU407Sz3Y8pNFJ8P64Phk1"
}
}
init(from decoder: Decoder) throws {
// 1
do {
let singleValueContainer = try decoder.singleValueContainer()
let timestamp = try singleValueContainer.decode(Int.self)
self = .number(timestamp)
return
} catch {}
// 2
do {
[
{
"id": "10232765268",
"type": "CreateEvent",
"payload": {
"ref": "greenkeeper/size-limit-2.1.1",
"ref_type": "branch",
"master_branch": "master",
"description": "Standard observable implementation",
"pusher_type": "user"
Logger.instance.addHandlers([
OsLogHandler(),
CrashlyticsLogHandler()
])
class OsLogHandler: LogHandler {
func handle(
_ level: LogLevel,
_ message: String,
extra: Any?,
category: LogCategory,
file: String,
line: Int,
column: Int,
extension OSLog {
private static var subsystem = Bundle.main.bundleIdentifier!
static let general = OSLog(subsystem: subsystem, category: LogCategory.general.rawValue)
static let viewCycle = OSLog(subsystem: subsystem, category: LogCategory.viewCycle.rawValue)
static let memorymanagementCycle = OSLog(subsystem: subsystem, category: LogCategory.memoryManagement.rawValue)
}
extension LogLevel {
var osLogType: OSLogType {
func logData(
_ level: LogLevel,
_ message: String = "",
extra: Any? = nil,
category: LogCategory = .general,
file: String = #file,
line: Int = #line,
column: Int = #column,
function: String = #function) {