Skip to content

Instantly share code, notes, and snippets.

@jxstxn1
Last active May 30, 2025 12:36
Show Gist options
  • Save jxstxn1/36417ca642fa7dd91a381ba54c3bf99d to your computer and use it in GitHub Desktop.
Save jxstxn1/36417ca642fa7dd91a381ba54c3bf99d to your computer and use it in GitHub Desktop.
import 'package:flutter_test/flutter_test.dart';
void main() {
test('should round 0.145 to 0.15', () {
const value = 0.145;
final rounded = value.toStringAsFixed(2);
expect(rounded, '0.15'); // actual 0.14
});
test('should round 0.145 to 0.15', () {
const value = 0.145;
final rounded = (value * 100).round() / 100;
expect(rounded, 0.15); // actual 0.14
});
test('should round 1.145 to 0.15', () {
const value = 1.145;
final rounded = value.toStringAsFixed(2);
expect(rounded, '1.15');
});
test('should round 1.145 to 1.15', () {
const value = 1.145;
final rounded = (value * 100).round() / 100;
expect(rounded, 1.15);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment