Skip to content

Instantly share code, notes, and snippets.

View truongsinh's full-sized avatar
:octocat:
Blessed

TruongSinh Tran-Nguyen truongsinh

:octocat:
Blessed
View GitHub Profile
@truongsinh
truongsinh / step 5 uniquekey.diff
Created August 6, 2020 02:42
step 5 uniquekey
diff --git a/lib/main.dart b/lib/main.dart
index 439d0fb..fafcf3a 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -27,6 +27,9 @@ class MyStatefulWidget extends StatefulWidget {
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
var isSameAddress = true;
+ final billingAddress1Key = UniqueKey();
+ final billingAddress2Key = UniqueKey();
@truongsinh
truongsinh / step 4 nested AutofillGroup.diff
Created August 6, 2020 02:13
step 4 nested AutofillGroup.diff
diff --git a/lib/main.dart b/lib/main.dart
index 526ac61..439d0fb 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -31,11 +31,11 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
// has been removed
@override
- Widget build(BuildContext context) => ListView(
+ Widget build(BuildContext context) => AutofillGroup(
@truongsinh
truongsinh / step 3 add autofill to the rest.diff
Created August 6, 2020 02:05
step 3 add autofill to the rest
diff --git a/lib/main.dart b/lib/main.dart
index 4f1704b..526ac61 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -65,15 +65,18 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
},
),
if (!isSameAddress)
- Column(
+ AutofillGroup(
@truongsinh
truongsinh / step 2 AutofillGroup to autofill multiple fields in one tap.diff
Last active August 6, 2020 02:01
AutofillGroup to autofill multiple fields in one tap
diff --git a/lib/main.dart b/lib/main.dart
index ae75939..4f1704b 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -33,6 +33,9 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
@override
Widget build(BuildContext context) => ListView(
padding: EdgeInsets.symmetric(horizontal: 16),
+ children: [
+ AutofillGroup(
@truongsinh
truongsinh / step-1-first-fields-to-have-auto-fill.diff
Last active August 6, 2020 01:28
first field(s) to have autofill
diff --git a/lib/main.dart b/lib/main.dart
index 1460ece..ae75939 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -35,12 +35,14 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
padding: EdgeInsets.symmetric(horizontal: 16),
children: [
TextFormField(
+ autofillHints: [AutofillHints.streetAddressLine1],
decoration: const InputDecoration(
@truongsinh
truongsinh / main.dart
Last active April 29, 2020 13:27
example autovalidate
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
/// This Widget is the main application widget.
class MyApp extends StatelessWidget {
static const String _title = 'Flutter Code Sample';
@override
@truongsinh
truongsinh / right-way-to-do-cpu-bound-operations.dart
Last active April 11, 2020 11:34
right-way-to-do-cpu-bound-operations.dart
void main() async {
final then = DateTime.now();
print(then);
final r = await compute(veryLongRunningCpuBoundFunction, 10);
final now = DateTime.now();
print('${now.difference(then)} later, the result is $r');
}
int veryLongRunningCpuBoundFunction(int param) {
for (var i = 0; i < param; i++) {
@truongsinh
truongsinh / build.gradle.diff
Last active December 25, 2019 01:55
step 3
diff --git a/app/build.gradle b/app/build.gradle
index d1b7792..dd96f56 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -47,3 +47,15 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
}
+
+
before_script:
- export GOPATH=$(pwd)
stages:
- build
- test
- deploy
validate-schema:
image: truongsinh/pg-client:9.4
@truongsinh
truongsinh / tflite.dart
Created September 19, 2019 00:49
get detection result list
for (var index = 0; index < numDetections; index++) {
String detectedClass = localLabels[outputClasses[index].toInt()];
final top = max(0.0, outputLocations[index * 4 + 0]);
final left = max(0.0, outputLocations[index * 4 + 1]);
final bottom = min(1.0, outputLocations[index * 4 + 2]);
final right = min(1.0, outputLocations[index * 4 + 3]);
final thisSesult = DetectionResult(
rect: Rect.fromLTRB(left, top, right, bottom),