Skip to content

Improve assertion message in AlignmentDirectional.resolve #172096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Prev Previous commit
Next Next commit
test: Verify assertion for null TextDirection in AlignmentDirectional
Adds a test case to ensure that calling `AlignmentDirectional.resolve` with a null `TextDirection` throws a `FlutterError`
with the expected improved message.
  • Loading branch information
SalehTZ committed Jul 14, 2025
commit bffcfba974fe61ac1cc51e5e59e357c7e7669936
18 changes: 18 additions & 0 deletions packages/flutter/test/painting/alignment_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'dart:math' as math;

import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
import 'package:flutter_test/flutter_test.dart';

Expand Down Expand Up @@ -350,4 +351,21 @@ void main() {
expect(AlignmentGeometry.bottomCenter, Alignment.bottomCenter);
expect(AlignmentGeometry.bottomRight, Alignment.bottomRight);
});

test('AlignmentDirectional.resolve with null TextDirection asserts', () {
const AlignmentDirectional alignmentDirectional = AlignmentDirectional(1.0, 2.0);

expect(
() => alignmentDirectional.resolve(null),
throwsA(
isFlutterError.having(
(FlutterError e) => e.message,
'message',
allOf(contains('No TextDirection found.'), contains('without a Directionality ancestor')),
),
),
);
});
}

double nonconst(double value) => value;
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy