Prepare working version of `package:tflite_native` for Dart 2.6

origin/master is currently broken: The tests on windows fail because the
checked-in `lib/src/blobs/libtensorflowlite_c-win64.dll` library does
not seem to have the necessary symbols.

This branch is based on fbabf0b9 which is a working version of the
`package:tflite_native`. Any changes necessary for this code to work
with D26 ffi will be included in this branch.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 88de4ff..5f0de1d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+# 0.3.1-dev.2
+
+* Replaced uses of deprecated `asExternalTypedData` with `asTypedList`.
+
+# 0.3.0
+
+* Update to new tflite C API
+
 # 0.2.3
 
 * Specify `>=2.5.0` in `pubspec.yaml`
diff --git a/lib/src/bindings/bindings.dart b/lib/src/bindings/bindings.dart
index 4594cd9..fa3f900 100644
--- a/lib/src/bindings/bindings.dart
+++ b/lib/src/bindings/bindings.dart
@@ -3,7 +3,9 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'dart:ffi';
-import 'utf8.dart';
+
+import 'package:ffi/ffi.dart';
+
 import 'dlib.dart';
 
 /// Version information for the TensorFlowLite library.
diff --git a/lib/src/bindings/interpreter_options.dart b/lib/src/bindings/interpreter_options.dart
index 021ed76..617b2b1 100644
--- a/lib/src/bindings/interpreter_options.dart
+++ b/lib/src/bindings/interpreter_options.dart
@@ -4,7 +4,8 @@
 
 import 'dart:ffi';
 
-import 'utf8.dart';
+import 'package:ffi/ffi.dart';
+
 import 'dlib.dart';
 import 'types.dart';
 
diff --git a/lib/src/bindings/model.dart b/lib/src/bindings/model.dart
index 8fdc8d2..14f45a9 100644
--- a/lib/src/bindings/model.dart
+++ b/lib/src/bindings/model.dart
@@ -4,7 +4,8 @@
 
 import 'dart:ffi';
 
-import 'utf8.dart';
+import 'package:ffi/ffi.dart';
+
 import 'dlib.dart';
 import 'types.dart';
 
diff --git a/lib/src/bindings/tensor.dart b/lib/src/bindings/tensor.dart
index 04c6407..00d939c 100644
--- a/lib/src/bindings/tensor.dart
+++ b/lib/src/bindings/tensor.dart
@@ -4,7 +4,8 @@
 
 import 'dart:ffi';
 
-import 'utf8.dart';
+import 'package:ffi/ffi.dart';
+
 import 'dlib.dart';
 import 'types.dart';
 
diff --git a/lib/src/bindings/types.dart b/lib/src/bindings/types.dart
index 6701233..430552d 100644
--- a/lib/src/bindings/types.dart
+++ b/lib/src/bindings/types.dart
@@ -5,16 +5,16 @@
 import 'dart:ffi';
 
 /// Wraps a model interpreter.
-class TFL_Interpreter extends Struct<TFL_Interpreter> {}
+class TFL_Interpreter extends Struct {}
 
 /// Wraps customized interpreter configuration options.
-class TFL_InterpreterOptions extends Struct<TFL_InterpreterOptions> {}
+class TFL_InterpreterOptions extends Struct {}
 
 /// Wraps a loaded TensorFlowLite model.
-class TFL_Model extends Struct<TFL_Model> {}
+class TFL_Model extends Struct {}
 
 /// Wraps data associated with a graph tensor.
-class TFL_Tensor extends Struct<TFL_Tensor> {}
+class TFL_Tensor extends Struct {}
 
 /// Status of a TensorFlowLite function call.
 class TFL_Status {
diff --git a/lib/src/bindings/utf8.dart b/lib/src/bindings/utf8.dart
deleted file mode 100644
index 6c2db07..0000000
--- a/lib/src/bindings/utf8.dart
+++ /dev/null
@@ -1,37 +0,0 @@
-// 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 'dart:convert';
-import 'dart:ffi';
-
-/// Represents a string (char*) in C memory.
-class Utf8 extends Struct<Utf8> {
-  @Uint8()
-  int char;
-
-  /// Allocates and stores the given Dart [String] as a [Pointer<Utf8>].
-  static Pointer<Utf8> toUtf8(String str) {
-    final ptr = Pointer<Utf8>.allocate(count: str.length + 1);
-    final units = Utf8Encoder().convert(str);
-    units
-        .asMap()
-        .forEach((i, unit) => ptr.elementAt(i).load<Utf8>().char = unit);
-    ptr.elementAt(units.length).load<Utf8>().char = 0;
-    return ptr;
-  }
-
-  /// Gets the Dart [String] representation of a [Pointer<Utf8>].
-  static String fromUtf8(Pointer<Utf8> ptr) {
-    final units = <int>[];
-    var len = 0;
-    while (true) {
-      final char = ptr.elementAt(len++).load<Utf8>().char;
-      if (char == 0) {
-        break;
-      }
-      units.add(char);
-    }
-    return Utf8Decoder().convert(units);
-  }
-}
diff --git a/lib/src/interpreter.dart b/lib/src/interpreter.dart
index 44085a2..765d0d0 100644
--- a/lib/src/interpreter.dart
+++ b/lib/src/interpreter.dart
@@ -3,6 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'dart:ffi';
+
 import 'package:quiver/check.dart';
 
 import 'bindings/interpreter.dart';
@@ -69,6 +70,7 @@
       (i) => Tensor(TFL_InterpreterGetOutputTensor(_interpreter, i)),
       growable: false);
 
+
   // Unimplemented:
   // TFL_InterpreterResizeInputTensor
 }
diff --git a/lib/src/model.dart b/lib/src/model.dart
index 0cc63af..8f60fba 100644
--- a/lib/src/model.dart
+++ b/lib/src/model.dart
@@ -3,9 +3,10 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'dart:ffi';
+
+import 'package:ffi/ffi.dart';
 import 'package:quiver/check.dart';
 
-import 'bindings/utf8.dart';
 import 'bindings/model.dart';
 import 'bindings/types.dart';
 import 'ffi/helper.dart';
@@ -23,7 +24,7 @@
   factory Model.fromFile(String path) {
     final cpath = Utf8.toUtf8(path);
     final model = TFL_NewModelFromFile(cpath);
-    cpath.free();
+    free(cpath);
     checkArgument(isNotNull(model), message: 'Unable to create model.');
     return Model._(model);
   }
diff --git a/lib/src/tensor.dart b/lib/src/tensor.dart
index 1741d7b..7e1df0a 100644
--- a/lib/src/tensor.dart
+++ b/lib/src/tensor.dart
@@ -4,11 +4,12 @@
 
 import 'dart:ffi';
 import 'dart:typed_data';
+
+import 'package:ffi/ffi.dart';
 import 'package:quiver/check.dart';
 
 import 'bindings/tensor.dart';
 import 'bindings/types.dart';
-import 'bindings/utf8.dart';
 import 'ffi/helper.dart';
 
 export 'bindings/types.dart' show TFL_Type;
@@ -36,39 +37,45 @@
     final data = cast<Uint8>(TFL_TensorData(_tensor));
     checkState(isNotNull(data), message: 'Tensor data is null.');
     return UnmodifiableUint8ListView(
-        data.asExternalTypedData(count: TFL_TensorByteSize(_tensor)));
+        data.asTypedList(TFL_TensorByteSize(_tensor)));
   }
 
   /// Updates the underlying data buffer with new bytes.
   ///
   /// The size must match the size of the tensor.
   set data(List<int> bytes) {
+    final tensorByteSize = TFL_TensorByteSize(_tensor);
     checkArgument(TFL_TensorByteSize(_tensor) == bytes.length);
     final data = cast<Uint8>(TFL_TensorData(_tensor));
     checkState(isNotNull(data), message: 'Tensor data is null.');
-    bytes.asMap().forEach((i, byte) => data.elementAt(i).store(byte));
+    final externalTypedData = data.asTypedList(tensorByteSize);
+    externalTypedData.setRange(0, tensorByteSize, bytes);
   }
 
   /// Copies the input bytes to the underlying data buffer.
   // TODO(shanehop): Prevent access if unallocated.
-  void copyFrom(List<int> bytes) {
-    final ptr = Pointer<Uint8>.allocate(count: bytes.length);
-    bytes.asMap().forEach((i, byte) => ptr.elementAt(i).store(byte));
+  void copyFrom(Uint8List bytes) {
+    final size = bytes.length;
+    final ptr = allocate<Uint8>(count: size);
+    final externalTypedData = ptr.asTypedList(size);
+    externalTypedData.setRange(0, bytes.length, bytes);
     checkState(TFL_TensorCopyFromBuffer(_tensor, ptr.cast(), bytes.length) ==
         TFL_Status.ok);
-    ptr.free();
+    free(ptr);
   }
 
   /// Returns a copy of the underlying data buffer.
   // TODO(shanehop): Prevent access if unallocated.
-  List<int> copyTo() {
+  Uint8List copyTo() {
     int size = TFL_TensorByteSize(_tensor);
-    final ptr = Pointer<Uint8>.allocate(count: size);
+    final ptr = allocate<Uint8>(count: size);
+    final externalTypedData = ptr.asTypedList(size);
     checkState(
         TFL_TensorCopyToBuffer(_tensor, ptr.cast(), size) == TFL_Status.ok);
-    final bytes = List.generate(size, (i) => ptr.elementAt(i).load<int>(),
-        growable: false);
-    ptr.free();
+    // Clone the data, because once `free(ptr)`, `externalTypedData` will be
+    // volatile
+    final bytes = externalTypedData.sublist(0);
+    free(ptr);
     return bytes;
   }
 
diff --git a/lib/tflite.dart b/lib/tflite.dart
index abfeb8c..6315294 100644
--- a/lib/tflite.dart
+++ b/lib/tflite.dart
@@ -5,9 +5,11 @@
 /// TensorFlow Lite for Dart
 library tflite;
 
+import 'package:ffi/ffi.dart';
+
 import 'src/bindings/bindings.dart';
-import 'src/bindings/utf8.dart';
 export 'src/model.dart';
+
 export 'src/interpreter.dart';
 export 'src/interpreter_options.dart';
 export 'src/tensor.dart';
diff --git a/pubspec.yaml b/pubspec.yaml
index 619b344..eb94ca2 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,12 +1,13 @@
 name: tflite_native
-version: 0.2.3
+version: 0.3.1-dev.2
 author: Dart Team <misc@dartlang.org>
 description: A Dart interface to TensorFlow Lite through Dart FFI. This library wraps the experimental tflite C API.
 homepage: https://github.com/dart-lang/tflite_native
 environment:
-  sdk: '>=2.5.0 <3.0.0'
+  sdk: '>=2.6.0-dev.6.0 <3.0.0'
 dependencies:
   path: ^1.6.2
   quiver: ^2.0.3
+  ffi: ^0.1.3-dev.3
 dev_dependencies:
   test: ^1.6.4
diff --git a/test/tflite_test.dart b/test/tflite_test.dart
index e178e33..db70959 100644
--- a/test/tflite_test.dart
+++ b/test/tflite_test.dart
@@ -3,6 +3,8 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'dart:io';
+import 'dart:typed_data';
+
 import 'package:path/path.dart' as path;
 import 'package:test/test.dart';
 import 'package:tflite_native/tflite.dart' as tfl;
@@ -158,15 +160,15 @@
 
         test('copyFrom throws if not allocated', () {
           expect(
-              () => tensors[0].copyFrom([0, 0, 0, 0]), throwsA(isStateError));
+              () => tensors[0].copyFrom(Uint8List.fromList([0, 0, 0, 0])), throwsA(isStateError));
         }, skip: 'segmentation fault!');
         // TODO(shanehop): Prevent data access for unallocated tensors.
 
         test('copyFrom', () {
           interpreter.allocateTensors();
-          tensors[0].copyFrom([0, 0, 0, 0]);
+          tensors[0].copyFrom(Uint8List.fromList([0, 0, 0, 0]));
           expect(tensors[0].data, [0, 0, 0, 0]);
-          tensors[0].copyFrom([0, 1, 10, 100]);
+          tensors[0].copyFrom(Uint8List.fromList([0, 1, 10, 100]));
           expect(tensors[0].data, [0, 1, 10, 100]);
         });
       });