Skip to content

Instantly share code, notes, and snippets.

@nick45chen
nick45chen / main.dart
Created June 21, 2023 01:08
Flutter 置中,且內容保持有 46 px,並且可以上下滑動(內容消失的邊界為螢幕)
ScrollView(
child: Padding(
padding: const EdgeInsets.all(46.0), // 添加 46px 的邊距
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('這是第一行文字'),
Text('這是第二行文字'),
// 你可以在此處添加更多的 Widget
@nick45chen
nick45chen / http_result.dart
Created May 25, 2023 03:36
回傳資料的封裝
/// A generic class that holds a value or an exception.
class RequestResult<T> {
const RequestResult._();
const factory RequestResult.success(T? data) = Success<T>;
const factory RequestResult.error(Exception exception) = Error<T>;
const factory RequestResult.nothing() = Nothing<T>;
}
@nick45chen
nick45chen / main.dart
Last active February 16, 2023 15:14
text fade-in animation
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@nick45chen
nick45chen / router_delegate.dart
Created June 30, 2022 06:22 — forked from Ivy-Walobwa/router_delegate.dart
Code snippets implementing RouteDelegate, RouteInformationParser and defining user data-types. Full repo here: https://github.com/Ivy-Walobwa/flutter_declarative_navigation
import 'package:flutter/material.dart';
import 'routes_config.dart';
import '../presentation/screens.dart';
import '../constants.dart';
class ShopListRouterDelegate extends RouterDelegate<ShopListRouteConfig>
with ChangeNotifier, PopNavigatorRouterDelegateMixin<ShopListRouteConfig> {
@override
final GlobalKey<NavigatorState> navigatorKey;
@nick45chen
nick45chen / EasyWS.kt
Created October 17, 2021 04:48 — forked from omarmiatello/EasyWS.kt
First experiment with WebSocket and Kotlin Coroutine
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.channels.Channel
import kotlinx.coroutines.experimental.launch
import okhttp3.*
import okio.ByteString
import kotlin.coroutines.experimental.suspendCoroutine
/**
* Created by omarmiatello on 17/06/17.
*/
@nick45chen
nick45chen / Connectivity.java
Created August 2, 2021 03:35 — forked from emil2k/Connectivity.java
Android utility class for checking device's network connectivity and speed.
/*
* Copyright (c) 2017 Emil Davtyan
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:

商店後台步驟

  • 設定/應用程式完整性/Play 應用程式簽署

  • 選擇 從 Android Studio 匯出並上傳金鑰

  • 上傳私密金鑰

    • 📎 private_key.pepk

@nick45chen
nick45chen / dio_adapter.dart
Last active August 4, 2021 02:48
dio adapter
import 'package:dio/dio.dart';
import 'package:flutter_bili_app/http/core/hi_adapter.dart';
import 'package:flutter_bili_app/http/core/hi_error.dart';
import 'package:flutter_bili_app/http/request/base_request.dart';
/// Dio 適配器
class DioAdapter extends HiNetAdapter {
@override
Future<HiNetResponse<T>> send<T>(BaseRequest request) async {
var response, options = Options(headers: request.header);
@nick45chen
nick45chen / snapping_list_view.dart
Created December 21, 2020 08:11 — forked from yunyu/snapping_list_view.dart
A Flutter PageView replacement/snapping ListView for fixed-extent items
import "package:flutter/widgets.dart";
import "dart:math";
class SnappingListView extends StatefulWidget {
final Axis scrollDirection;
final ScrollController controller;
final IndexedWidgetBuilder itemBuilder;
final List<Widget> children;
final int itemCount;
@nick45chen
nick45chen / snapping_list_view.dart
Created December 21, 2020 08:11 — forked from yunyu/snapping_list_view.dart
A Flutter PageView replacement/snapping ListView for fixed-extent items
import "package:flutter/widgets.dart";
import "dart:math";
class SnappingListView extends StatefulWidget {
final Axis scrollDirection;
final ScrollController controller;
final IndexedWidgetBuilder itemBuilder;
final List<Widget> children;
final int itemCount;