Skip to content

Instantly share code, notes, and snippets.

View CaiJingLong's full-sized avatar
💭
I may be slow to respond.

Caijinglong CaiJingLong

💭
I may be slow to respond.
View GitHub Profile
@CaiJingLong
CaiJingLong / main.dart
Last active September 18, 2020 07:48
Multi textfield
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. 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/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@CaiJingLong
CaiJingLong / main.dart
Created April 29, 2020 03:16
给2法看看
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. 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';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@CaiJingLong
CaiJingLong / main.dart
Last active April 24, 2020 06:15
全局loading
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) {
return MaterialApp(
title: 'Flutter Demo',
@CaiJingLong
CaiJingLong / build.gradle
Created April 12, 2020 05:42
Depending on whether the IP is China, decide whether to use aliyun maven.
import groovy.json.JsonSlurper
buildscript {
ext.kotlin_version = '1.3.61'
def isChina = false
try {
def connection = new URL('https://api.ip.sb/geoip').openConnection()
connection.setRequestMethod('GET')
def reader = new BufferedReader(new InputStreamReader(connection.inputStream))
def text = reader.readLine()
@CaiJingLong
CaiJingLong / build_ios.sh
Created April 9, 2020 03:10
build ios shell by @AlexVincent525
# remove iOS bitcode
flutter build ios
cd build/ios/iphoneos/Runner.app/Frameworks
cd App.framework
xcrun bitcode_strip -r app -o app
cd ..
cd Flutter.framework
xcrun bitcode_strip -r Flutter -o Flutter
cd ../../../../../../
@CaiJingLong
CaiJingLong / main.dart
Created March 26, 2020 12:32
FractionallySizedBox example
import "package:flutter/material.dart";
void main() {
runApp(
MaterialApp(
home: Container(
color: Colors.red,
child: Stack(
children: [
Align(
@CaiJingLong
CaiJingLong / main.dart
Last active March 24, 2020 09:10
Flutter ListWheelView example
import 'package:flutter/material.dart';
import 'dart:collection';
import 'dart:math';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
@CaiJingLong
CaiJingLong / main.dart
Created March 24, 2020 06:32
extension method in dart
typedef void ForEachHandle<T>(int index, T item);
extension _A<T> on List<T> {
void forEachIndexed(void func(int index, T item)) {
for (var i = 0; i < this.length; i++) {
func(i, this[i]);
}
}
void forEachIndexed2(void Function(int index, T item) func) {
@CaiJingLong
CaiJingLong / ResultHandler.kt
Last active August 22, 2020 15:02
ResultHandler in kotlin
package top.kikt.imagescanner.util
import android.os.Handler
import android.os.Looper
import io.flutter.plugin.common.MethodChannel
class ResultHandler(var result: MethodChannel.Result?) {
companion object {
@CaiJingLong
CaiJingLong / main.dart
Last active March 10, 2020 03:02
range like python for dart
void main() {
print(range(100, start: 1, step: 7));
}
Iterable<int> range(int end, {int start = 0, int step = 1}) sync* {
assert(step >= 1);
int r = start;
while (r < end) {
yield r;