Refactor constants and logging in Shapes widget for consistency#11
Refactor constants and logging in Shapes widget for consistency#11charlesoj6205 wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the Shapes example app to use consistent Dart naming for constants and logging, and updates the example widget test to point at the correct package/app entry widget.
Changes:
- Renamed API-related constants to lowerCamelCase and updated all call sites.
- Refactored
Shapesto have aconstconstructor and adjusted state/logging identifiers for consistency. - Updated the widget test import and target widget from the old
examplepackage toapproov_http_client_example.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| example/test/widget_test.dart | Switches import/target widget to Shapes (but test logic still assumes a counter template). |
| example/lib/main.dart | Renames constants and logging identifiers; adds const Shapes constructor and adjusts state/log naming. |
Comments suppressed due to low confidence (1)
example/test/widget_test.dart:24
widget_test.dartis still the default counter template test (expects '0'/'1' text and aIcons.addbutton), but the app under test is nowShapes, which renders 'Approov Shapes' and 'Hello/Shape/Shape (Isolate)' buttons. This test will fail; update it to assert the initialShapesUI (e.g., header text and buttons) rather than counter behavior, and avoid tapping buttons that trigger real network calls.
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(const Shapes());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // execute the main function of the app | ||
| runApp(Shapes()); | ||
| } |
There was a problem hiding this comment.
Shapes now has a const constructor, but main() still calls runApp(Shapes()). Use runApp(const Shapes()) to satisfy prefer_const_constructors and avoid an unnecessary widget instantiation.
| class ShapesState extends State<Shapes> { | ||
| // logger | ||
| static Logger Log = Logger(); | ||
| static Logger log = Logger(); |
There was a problem hiding this comment.
log is a mutable static field (static Logger log = Logger();) but it is never reassigned. Make it static final to prevent accidental reassignment and better express intent.
| static Logger log = Logger(); | |
| static final Logger log = Logger(); |
No description provided.