Skip to content

Instantly share code, notes, and snippets.

@X-Wei
X-Wei / main.dart
Created June 6, 2022 19:16
ImageFilter.compose crash
// https://github.com/X-Wei/flutter_catalog/issues/131
import 'dart:ui';
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
@X-Wei
X-Wei / main.dart
Created January 11, 2020 22:57
HiveObject subclasses issue: must not register base class HiveObject
import 'package:hive/hive.dart';
/////////////// 'vehicle.dart' ///////////////
@HiveType(typeId: 0)
class Vehicle extends HiveObject {
@HiveField(0)
String name;
}
@HiveType(typeId: 1)
[ +21 ms] executing: [$HOME/.local/bin/flutter/] git log -n 1 --pretty=format:%H
[ +23 ms] Exit code 0 from: git log -n 1 --pretty=format:%H
[ ] 2e540931f73593e35627592ca4f9a4ca3035ed31
[ ] executing: [$HOME/.local/bin/flutter/] git describe --match v*.*.* --first-parent --long --tags
[ +8 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[ ] v1.7.8+hotfix.2-0-g2e540931f
[ +9 ms] executing: [$HOME/.local/bin/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +6 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ ] origin/stable
[ ] executing: [$HOME/.local/bin/flutter/] git ls-remote --get-url origin
@X-Wei
X-Wei / syntax_highlighter.dart
Last active July 15, 2021 19:52
syntax-highlighter for flutter_markdown (adopted from flutter_gallery)
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart' show SyntaxHighlighter;
import 'package:string_scanner/string_scanner.dart';
class SyntaxHighlighterStyle {
SyntaxHighlighterStyle(
@X-Wei
X-Wei / sliver_appbar_with_tabs.dart
Created July 29, 2018 11:36
Demo of using SliverAppbar with tabs.
// Sliver appbar with tabs.
// Adapted from: https://stackoverflow.com/a/50858058
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(
home: SilverAppBarWithTabBarScreen(),
));
class SilverAppBarWithTabBarScreen extends StatefulWidget {
@X-Wei
X-Wei / jkxy-download.py
Created December 31, 2016 11:29
jikexueyuan video downloader
# coding: utf-8
import requests
from lxml import etree
import os, time, sys
import cPickle as pk
reload(sys)
sys.setdefaultencoding('utf-8') # to avoid encoding problems
hea = {