Skip to content

Instantly share code, notes, and snippets.

View mutant0113's full-sized avatar

Evan Fang mutant0113

View GitHub Profile
@mutant0113
mutant0113 / flutter_isolate_spawn_only_receive
Last active December 4, 2022 09:37
flutter_isolate_spawn_only_receive
import 'dart:async';
import 'dart:isolate';
void main() async {
final receivePort = ReceivePort();
final newIsolate = await Isolate.spawn(createNewIsolate, receivePort.sendPort);
final message = await receivePort.first; // Receive the result.
print("Main Isolate: $message"); // Print "Main Isolate: Hello New Isolate"
}
void createNewIsolate(SendPort sendPort) {
@mutant0113
mutant0113 / flutter_isolate_spawn.dart
Last active December 4, 2022 09:49
flutter_isolate_spawn
import 'dart:async';
import 'dart:isolate';
void main() async {
// 1. Create the main receive port.
final mainReceivePort = ReceivePort();
// 2. Spawn an isolate with the main send port.
final newIsolate = await Isolate.spawn(createNewIsolate, mainReceivePort.sendPort);
mainReceivePort.listen((message) {
@mutant0113
mutant0113 / mac_setup.md
Created July 11, 2022 07:46 — forked from ricky9667/mac_setup.md
My Mac Setup

💻 My Mac Setup

⚙️ System Settings

  • Three finger drag
  • Hide recent apps in dock
    • System Preferences -> Dock & Menu Bar -> Uncheck "Show recent applications in Dock"

🖥 Terminal Setup

@mutant0113
mutant0113 / home_page_timeline.timeline_summary.json
Created June 29, 2022 14:24
home_page_timeline.timeline_summary.json
{
"average_frame_build_time_millis": 6.7094482758620675,
"90th_percentile_frame_build_time_millis": 16.72,
"99th_percentile_frame_build_time_millis": 32.135,
"worst_frame_build_time_millis": 32.135,
"missed_frame_build_budget_count": 4,
"average_frame_rasterizer_time_millis": 3.961793103448275,
"90th_percentile_frame_rasterizer_time_millis": 4.718,
"99th_percentile_frame_rasterizer_time_millis": 7.026,
"worst_frame_rasterizer_time_millis": 7.026,
@mutant0113
mutant0113 / binding_trace_action.dart
Created June 26, 2022 09:29
binding_trace_action.dart
// Record the performance of the app.
await binding.traceAction(
() async {
// Scroll until the item to be found appears.
await tester.scrollUntilVisible(
itemFinder,
500.0,
scrollable: listFinder,
);
},
@mutant0113
mutant0113 / FlutterRefreshIndicatorCupertinoStyle.dart
Created January 6, 2021 06:41
FlutterRefreshIndicatorCupertinoStyle
import 'dart:math';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
@mutant0113
mutant0113 / FlutterRefreshIndicatorCustomScrollView.dart
Created December 19, 2020 02:03
FlutterRefreshIndicatorCustomScrollView
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) => MaterialApp(
@mutant0113
mutant0113 / FlutterRefreshIndicator.dart
Last active December 12, 2020 08:49
FlutterRefreshIndicator
import 'dart:math';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) => MaterialApp(
@mutant0113
mutant0113 / FlutterContainerTransformFinalCode.dart
Last active November 8, 2020 11:01
FlutterContainerTransformFinalCode
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@mutant0113
mutant0113 / FlutterContainerTransformShrink.dart
Created July 25, 2020 12:36
FlutterContainerTransformShrink
class _PageAState extends State<PageA> {
...
// A widget for page transition between the `pageA` and `pageB` after tapping the `FAB button`.
Widget get _pageTransition {
// Dismiss ripple widget if `_pageTransitionRect` is null.
if (_pageTransitionRect == null) {
return Container();
}