Dart does not have a native 32-bit integer type.
The int type is a 64-bit two's complement type when run natively, and it's a non-fractional 64-bit floating point type when compiled to JavaScript (because that's what JavaScript has).
The most general solution is to use the Int32 type from the fixnum package. Then somebody else has worried about the problem for you. It's less efficient than just using int operations, but it will maintain consistent 32-bit semantics.
Depending on overflow behavior of the int type is not going to work the same on all platforms.
If you only care about native code, and your expression only uses *, - and + like above, you can just call toSigned on the result. That gives you the low 32 bits of the result, which is the same result as using 32-bit numbers for the entire computation:
var result =
(someInt1 * ((someInt2 * someInt3) - someInt4 - (someInt5 * someInt6) - someInt7).toSigned(32);
It's not actually using 32-bit numbers, and it doesn't work if you also do division.
It will not work the same when compiled to JavaScript because the overflow behavior when an intermediate result is greater than 253 differs.
You can choose to do .toSigned(32) on every intermediate result:
var result = ((someInt1 *
((((someInt2 * someInt3).toSigned(32) - someInt4).toSigned(32) -
(someInt5 * someInt6).toSigned(32))
.toSigned(32))
.toSigned(32)) -
someInt7)
.toSigned(32);
Not particularly readable, and still won't be enough when compiling to JavaScript, because even two 32-bit integers multiplied may lose precision when the result is represented as double.
package:fixnumif you need to work with fixed-width integers. That said, I also do not recommend depending on overflow behavior. As you've observed, it's brittle and non-portable (in some languages, signed integer overflow is undefined behavior).longinstead?