From dfd27ab406c2a7b848c3e410c0d59068ff73c750 Mon Sep 17 00:00:00 2001 From: Tyler Dunn Date: Tue, 28 May 2024 21:13:10 -0400 Subject: [PATCH] dart: Fix incorrect write in Float64 write method (#8290) Co-authored-by: Llamadmiral Co-authored-by: Derek Bailey --- dart/lib/flat_buffers.dart | 2 +- dart/test/flat_buffers_test.dart | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dart/lib/flat_buffers.dart b/dart/lib/flat_buffers.dart index 6f307872e10..2395992ae28 100644 --- a/dart/lib/flat_buffers.dart +++ b/dart/lib/flat_buffers.dart @@ -386,7 +386,7 @@ class Builder { /// Updates the [offset] pointer. This method is intended for use when writing structs to the buffer. void putFloat64(double value) { _prepare(_sizeofFloat64, 1); - _setFloat32AtTail(_tail, value); + _setFloat64AtTail(_tail, value); } /// Writes a Float32 to the tail of the buffer after preparing space for it. diff --git a/dart/test/flat_buffers_test.dart b/dart/test/flat_buffers_test.dart index caf2fc79a9e..83a6e2b3f1e 100644 --- a/dart/test/flat_buffers_test.dart +++ b/dart/test/flat_buffers_test.dart @@ -215,6 +215,10 @@ class BuilderTest { ..addTestarrayofstringOffset(testArrayOfString); final mon = monBuilder.finish(); fbBuilder.finish(mon); + + final mon3 = example.Monster(fbBuilder.buffer); + expect(mon3.name, 'MyMonster'); + expect(mon3.pos!.test1, 3.0); } void test_error_addInt32_withoutStartTable([Builder? builder]) {