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-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 / 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 / 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 / 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),
@truongsinh
truongsinh / tflite.dart
Created September 19, 2019 00:47
combine to a single new list
// ...
final List<DetectionResult> results = List();
for (var index = 0; index < numDetections; index++) {
String detectedClass = localLabels[outputClasses[index].toInt()];
// final top // explain shortly after
// final left // explain shortly after
// final bottom // explain shortly after
// final right // explain shortly after
@truongsinh
truongsinh / tflite.dart
Created September 19, 2019 00:43
Parse raw bytes to approximately corresponding type
// https://www.tensorflow.org/lite/models/object_detection/overview
final outputTensors = localInterpreter.getOutputTensors();
final outputLocationsTensor = outputTensors[0];
// shape 1, 10, 4;
Float32List outputLocations =
outputLocationsTensor.data.buffer.asFloat32List();
final outputClassesTensor = outputTensors[1];
// shape 1, 10
@truongsinh
truongsinh / table.csv
Last active September 19, 2019 00:41
Index Name Expected type Description
0 Locations List<List<Float32>> Multidimensional array of [10][4] floating point values between 0 and 1, the inner arrays representing bounding boxes in the form [top, left, bottom, right]
1 Classes List<Float32> Array of 10 integers (output as floating point values) each indicating the index of a class label from the labels file
2 Scores List<Float32> Array of 10 floating point values between 0 and 1 representing probability that a class was detected
3 Number and detections Float32 Array of length 1 containing a floating point value expressing the total number of detection results