[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-flutter-dart-generate-test-mocks":3,"mdc-ussnj7-key":29,"related-org-flutter-dart-generate-test-mocks":1457,"related-repo-flutter-dart-generate-test-mocks":1588},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":19,"repoUrl":20,"updatedAt":21,"license":22,"forks":23,"topics":24,"repo":25,"sourceUrl":27,"mdContent":28},"dart-generate-test-mocks","generate mock objects for Dart tests","Define and generate mock objects for external dependencies using `package:mockito` and `build_runner`. Use when unit testing classes that depend on complex external services like APIs or databases.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"flutter","Flutter (Google)","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fflutter.png",[12,16],{"name":13,"slug":14,"type":15},"Dart","dart","tag",{"name":17,"slug":18,"type":15},"Testing","testing",2664,"https:\u002F\u002Fgithub.com\u002Fflutter\u002Fagent-plugins","2026-07-15T05:22:42.607449",null,155,[],{"repoUrl":20,"stars":19,"forks":23,"topics":26,"description":22},[],"https:\u002F\u002Fgithub.com\u002Fflutter\u002Fagent-plugins\u002Ftree\u002FHEAD\u002Fskills\u002Fdart-generate-test-mocks","---\nname: dart-generate-test-mocks\ndescription: Define and generate mock objects for external dependencies using `package:mockito` and `build_runner`. Use when unit testing classes that depend on complex external services like APIs or databases.\nmetadata:\n  model: models\u002Fgemini-3.1-pro-preview\n  last_modified: Fri, 24 Apr 2026 15:13:58 GMT\n---\n# Testing and Mocking Dart Applications\n\n## Contents\n- [Structuring Code for Testability](#structuring-code-for-testability)\n- [Managing Dependencies](#managing-dependencies)\n- [Generating Mocks](#generating-mocks)\n- [Implementing Unit Tests](#implementing-unit-tests)\n- [Workflow: Creating and Running Mocked Tests](#workflow-creating-and-running-mocked-tests)\n- [Examples](#examples)\n\n## Structuring Code for Testability\nDesign Dart classes to support dependency injection. Isolate complex external dependencies (like API clients or databases) so they can be replaced with mock objects during testing.\n\n- Inject external services (e.g., `http.Client`) through class constructors.\n- Represent URLs strictly as `Uri` objects using `Uri.parse(string)`.\n- Utilize Dart's object-oriented features (classes, mixins) to define clear interfaces for external interactions.\n\n## Managing Dependencies\nConfigure the `pubspec.yaml` file with the necessary testing and code generation packages.\n\n- Add runtime dependencies (e.g., `package:http`) using `dart pub add http`.\n- Add testing dependencies using `dart pub add dev:test dev:mockito dev:build_runner`.\n- Import HTTP libraries with a prefix to avoid namespace collisions: `import 'package:http\u002Fhttp.dart' as http;`.\n\n## Generating Mocks\nUse `package:mockito` and `build_runner` to automatically generate mock classes for fixed scenarios and behavior verification.\n\n- Always use the `@GenerateNiceMocks` annotation (preferable to `@GenerateMocks` to avoid missing stub exceptions).\n- Place the annotation in the test file, passing a list of `MockSpec\u003CType>()` objects.\n- Import the generated file using the `.mocks.dart` extension.\n- Execute `build_runner` to generate the mock files: `dart run build_runner build`.\n\n## Implementing Unit Tests\nIsolate the system under test using the generated mock objects. Use `package:test` to structure the test suite.\n\n- **Stubbing:** Configure mock behavior before interacting with the system under test.\n  - Use `when(mock.method()).thenReturn(value)` for synchronous methods.\n  - **CRITICAL:** Always use `thenAnswer((_) async => value)` for methods returning a `Future` or `Stream`. Never use `thenReturn` for asynchronous returns.\n- **Verification:** Assert that the system under test interacted with the mock object correctly.\n  - Use `verify(mock.method()).called(1)` to check exact invocation counts.\n  - Use argument matchers like `any`, `anyNamed`, or `captureAny` for flexible verification.\n\n## Workflow: Creating and Running Mocked Tests\n\nUse the following checklist to implement and verify mocked unit tests.\n\n### Task Progress\n- [ ] 1. Identify the external dependency to mock (e.g., `http.Client`).\n- [ ] 2. Inject the dependency into the target class constructor.\n- [ ] 3. Create a test file (e.g., `target_test.dart`) and add `@GenerateNiceMocks([MockSpec\u003CDependency>()])`.\n- [ ] 4. Add the `part` or `import` directive for the generated `.mocks.dart` file.\n- [ ] 5. Run `dart run build_runner build` to generate the mock classes.\n- [ ] 6. Write the test cases using `group()` and `test()`.\n- [ ] 7. Stub required behaviors using `when()`.\n- [ ] 8. Execute the target method.\n- [ ] 9. Verify interactions using `verify()` and assert outcomes using `expect()`.\n- [ ] 10. Run the test suite using `dart test`.\n\n### Feedback Loop: Test Failures\nIf tests fail or `build_runner` encounters errors:\n1. **Run validator:** Execute `dart test` or `dart run build_runner build`.\n2. **Review errors:** Check for missing stubs, mismatched argument matchers, or syntax errors in the generated files.\n3. **Fix:**\n   - If a mock method throws an unexpected null error, ensure you used `@GenerateNiceMocks`.\n   - If an async stub throws an `ArgumentError`, change `thenReturn` to `thenAnswer`.\n   - If `build_runner` fails, ensure the `.mocks.dart` import matches the file name exactly.\n4. Repeat until all tests pass.\n\n## Examples\n\n### High-Fidelity Mocking and Testing Example\n\n**1. System Under Test (`lib\u002Fapi_service.dart`)**\n```dart\nimport 'dart:convert';\nimport 'package:http\u002Fhttp.dart' as http;\n\nclass ApiService {\n  final http.Client client;\n\n  ApiService(this.client);\n\n  Future\u003CString> fetchData(String urlString) async {\n    final uri = Uri.parse(urlString);\n    final response = await client.get(uri);\n\n    if (response.statusCode == 200) {\n      return jsonDecode(response.body)['data'];\n    } else {\n      throw Exception('Failed to load data');\n    }\n  }\n}\n```\n\n**2. Test Implementation (`test\u002Fapi_service_test.dart`)**\n```dart\nimport 'package:test\u002Ftest.dart';\nimport 'package:mockito\u002Fannotations.dart';\nimport 'package:mockito\u002Fmockito.dart';\nimport 'package:http\u002Fhttp.dart' as http;\nimport 'package:my_app\u002Fapi_service.dart';\n\n\u002F\u002F Generate the mock class for http.Client\n@GenerateNiceMocks([MockSpec\u003Chttp.Client>()])\nimport 'api_service_test.mocks.dart';\n\nvoid main() {\n  group('ApiService', () {\n    late ApiService apiService;\n    late MockClient mockHttpClient;\n\n    setUp(() {\n      mockHttpClient = MockClient();\n      apiService = ApiService(mockHttpClient);\n    });\n\n    test('returns data if the http call completes successfully', () async {\n      \u002F\u002F Arrange: Stub the async HTTP GET request using thenAnswer\n      when(mockHttpClient.get(any)).thenAnswer(\n        (_) async => http.Response('{\"data\": \"Success\"}', 200),\n      );\n\n      \u002F\u002F Act\n      final result = await apiService.fetchData('https:\u002F\u002Fapi.example.com\u002Fdata');\n\n      \u002F\u002F Assert\n      expect(result, 'Success');\n\n      \u002F\u002F Verify the mock was called with the correct Uri\n      verify(mockHttpClient.get(Uri.parse('https:\u002F\u002Fapi.example.com\u002Fdata'))).called(1);\n    });\n\n    test('throws an exception if the http call completes with an error', () {\n      \u002F\u002F Arrange\n      when(mockHttpClient.get(any)).thenAnswer(\n        (_) async => http.Response('Not Found', 404),\n      );\n\n      \u002F\u002F Act & Assert\n      expect(\n        apiService.fetchData('https:\u002F\u002Fapi.example.com\u002Fdata'),\n        throwsException,\n      );\n    });\n  });\n}\n```\n",{"data":30,"body":34},{"name":4,"description":6,"metadata":31},{"model":32,"last_modified":33},"models\u002Fgemini-3.1-pro-preview","Fri, 24 Apr 2026 15:13:58 GMT",{"type":35,"children":36},"root",[37,46,53,113,118,124,167,172,185,232,237,258,327,332,345,470,475,480,487,680,686,698,807,812,818,834,1014,1029,1451],{"type":38,"tag":39,"props":40,"children":42},"element","h1",{"id":41},"testing-and-mocking-dart-applications",[43],{"type":44,"value":45},"text","Testing and Mocking Dart Applications",{"type":38,"tag":47,"props":48,"children":50},"h2",{"id":49},"contents",[51],{"type":44,"value":52},"Contents",{"type":38,"tag":54,"props":55,"children":56},"ul",{},[57,68,77,86,95,104],{"type":38,"tag":58,"props":59,"children":60},"li",{},[61],{"type":38,"tag":62,"props":63,"children":65},"a",{"href":64},"#structuring-code-for-testability",[66],{"type":44,"value":67},"Structuring Code for Testability",{"type":38,"tag":58,"props":69,"children":70},{},[71],{"type":38,"tag":62,"props":72,"children":74},{"href":73},"#managing-dependencies",[75],{"type":44,"value":76},"Managing Dependencies",{"type":38,"tag":58,"props":78,"children":79},{},[80],{"type":38,"tag":62,"props":81,"children":83},{"href":82},"#generating-mocks",[84],{"type":44,"value":85},"Generating Mocks",{"type":38,"tag":58,"props":87,"children":88},{},[89],{"type":38,"tag":62,"props":90,"children":92},{"href":91},"#implementing-unit-tests",[93],{"type":44,"value":94},"Implementing Unit Tests",{"type":38,"tag":58,"props":96,"children":97},{},[98],{"type":38,"tag":62,"props":99,"children":101},{"href":100},"#workflow-creating-and-running-mocked-tests",[102],{"type":44,"value":103},"Workflow: Creating and Running Mocked Tests",{"type":38,"tag":58,"props":105,"children":106},{},[107],{"type":38,"tag":62,"props":108,"children":110},{"href":109},"#examples",[111],{"type":44,"value":112},"Examples",{"type":38,"tag":47,"props":114,"children":116},{"id":115},"structuring-code-for-testability",[117],{"type":44,"value":67},{"type":38,"tag":119,"props":120,"children":121},"p",{},[122],{"type":44,"value":123},"Design Dart classes to support dependency injection. Isolate complex external dependencies (like API clients or databases) so they can be replaced with mock objects during testing.",{"type":38,"tag":54,"props":125,"children":126},{},[127,141,162],{"type":38,"tag":58,"props":128,"children":129},{},[130,132,139],{"type":44,"value":131},"Inject external services (e.g., ",{"type":38,"tag":133,"props":134,"children":136},"code",{"className":135},[],[137],{"type":44,"value":138},"http.Client",{"type":44,"value":140},") through class constructors.",{"type":38,"tag":58,"props":142,"children":143},{},[144,146,152,154,160],{"type":44,"value":145},"Represent URLs strictly as ",{"type":38,"tag":133,"props":147,"children":149},{"className":148},[],[150],{"type":44,"value":151},"Uri",{"type":44,"value":153}," objects using ",{"type":38,"tag":133,"props":155,"children":157},{"className":156},[],[158],{"type":44,"value":159},"Uri.parse(string)",{"type":44,"value":161},".",{"type":38,"tag":58,"props":163,"children":164},{},[165],{"type":44,"value":166},"Utilize Dart's object-oriented features (classes, mixins) to define clear interfaces for external interactions.",{"type":38,"tag":47,"props":168,"children":170},{"id":169},"managing-dependencies",[171],{"type":44,"value":76},{"type":38,"tag":119,"props":173,"children":174},{},[175,177,183],{"type":44,"value":176},"Configure the ",{"type":38,"tag":133,"props":178,"children":180},{"className":179},[],[181],{"type":44,"value":182},"pubspec.yaml",{"type":44,"value":184}," file with the necessary testing and code generation packages.",{"type":38,"tag":54,"props":186,"children":187},{},[188,208,220],{"type":38,"tag":58,"props":189,"children":190},{},[191,193,199,201,207],{"type":44,"value":192},"Add runtime dependencies (e.g., ",{"type":38,"tag":133,"props":194,"children":196},{"className":195},[],[197],{"type":44,"value":198},"package:http",{"type":44,"value":200},") using ",{"type":38,"tag":133,"props":202,"children":204},{"className":203},[],[205],{"type":44,"value":206},"dart pub add http",{"type":44,"value":161},{"type":38,"tag":58,"props":209,"children":210},{},[211,213,219],{"type":44,"value":212},"Add testing dependencies using ",{"type":38,"tag":133,"props":214,"children":216},{"className":215},[],[217],{"type":44,"value":218},"dart pub add dev:test dev:mockito dev:build_runner",{"type":44,"value":161},{"type":38,"tag":58,"props":221,"children":222},{},[223,225,231],{"type":44,"value":224},"Import HTTP libraries with a prefix to avoid namespace collisions: ",{"type":38,"tag":133,"props":226,"children":228},{"className":227},[],[229],{"type":44,"value":230},"import 'package:http\u002Fhttp.dart' as http;",{"type":44,"value":161},{"type":38,"tag":47,"props":233,"children":235},{"id":234},"generating-mocks",[236],{"type":44,"value":85},{"type":38,"tag":119,"props":238,"children":239},{},[240,242,248,250,256],{"type":44,"value":241},"Use ",{"type":38,"tag":133,"props":243,"children":245},{"className":244},[],[246],{"type":44,"value":247},"package:mockito",{"type":44,"value":249}," and ",{"type":38,"tag":133,"props":251,"children":253},{"className":252},[],[254],{"type":44,"value":255},"build_runner",{"type":44,"value":257}," to automatically generate mock classes for fixed scenarios and behavior verification.",{"type":38,"tag":54,"props":259,"children":260},{},[261,282,295,308],{"type":38,"tag":58,"props":262,"children":263},{},[264,266,272,274,280],{"type":44,"value":265},"Always use the ",{"type":38,"tag":133,"props":267,"children":269},{"className":268},[],[270],{"type":44,"value":271},"@GenerateNiceMocks",{"type":44,"value":273}," annotation (preferable to ",{"type":38,"tag":133,"props":275,"children":277},{"className":276},[],[278],{"type":44,"value":279},"@GenerateMocks",{"type":44,"value":281}," to avoid missing stub exceptions).",{"type":38,"tag":58,"props":283,"children":284},{},[285,287,293],{"type":44,"value":286},"Place the annotation in the test file, passing a list of ",{"type":38,"tag":133,"props":288,"children":290},{"className":289},[],[291],{"type":44,"value":292},"MockSpec\u003CType>()",{"type":44,"value":294}," objects.",{"type":38,"tag":58,"props":296,"children":297},{},[298,300,306],{"type":44,"value":299},"Import the generated file using the ",{"type":38,"tag":133,"props":301,"children":303},{"className":302},[],[304],{"type":44,"value":305},".mocks.dart",{"type":44,"value":307}," extension.",{"type":38,"tag":58,"props":309,"children":310},{},[311,313,318,320,326],{"type":44,"value":312},"Execute ",{"type":38,"tag":133,"props":314,"children":316},{"className":315},[],[317],{"type":44,"value":255},{"type":44,"value":319}," to generate the mock files: ",{"type":38,"tag":133,"props":321,"children":323},{"className":322},[],[324],{"type":44,"value":325},"dart run build_runner build",{"type":44,"value":161},{"type":38,"tag":47,"props":328,"children":330},{"id":329},"implementing-unit-tests",[331],{"type":44,"value":94},{"type":38,"tag":119,"props":333,"children":334},{},[335,337,343],{"type":44,"value":336},"Isolate the system under test using the generated mock objects. Use ",{"type":38,"tag":133,"props":338,"children":340},{"className":339},[],[341],{"type":44,"value":342},"package:test",{"type":44,"value":344}," to structure the test suite.",{"type":38,"tag":54,"props":346,"children":347},{},[348,416],{"type":38,"tag":58,"props":349,"children":350},{},[351,357,359],{"type":38,"tag":352,"props":353,"children":354},"strong",{},[355],{"type":44,"value":356},"Stubbing:",{"type":44,"value":358}," Configure mock behavior before interacting with the system under test.\n",{"type":38,"tag":54,"props":360,"children":361},{},[362,374],{"type":38,"tag":58,"props":363,"children":364},{},[365,366,372],{"type":44,"value":241},{"type":38,"tag":133,"props":367,"children":369},{"className":368},[],[370],{"type":44,"value":371},"when(mock.method()).thenReturn(value)",{"type":44,"value":373}," for synchronous methods.",{"type":38,"tag":58,"props":375,"children":376},{},[377,382,384,390,392,398,400,406,408,414],{"type":38,"tag":352,"props":378,"children":379},{},[380],{"type":44,"value":381},"CRITICAL:",{"type":44,"value":383}," Always use ",{"type":38,"tag":133,"props":385,"children":387},{"className":386},[],[388],{"type":44,"value":389},"thenAnswer((_) async => value)",{"type":44,"value":391}," for methods returning a ",{"type":38,"tag":133,"props":393,"children":395},{"className":394},[],[396],{"type":44,"value":397},"Future",{"type":44,"value":399}," or ",{"type":38,"tag":133,"props":401,"children":403},{"className":402},[],[404],{"type":44,"value":405},"Stream",{"type":44,"value":407},". Never use ",{"type":38,"tag":133,"props":409,"children":411},{"className":410},[],[412],{"type":44,"value":413},"thenReturn",{"type":44,"value":415}," for asynchronous returns.",{"type":38,"tag":58,"props":417,"children":418},{},[419,424,426],{"type":38,"tag":352,"props":420,"children":421},{},[422],{"type":44,"value":423},"Verification:",{"type":44,"value":425}," Assert that the system under test interacted with the mock object correctly.\n",{"type":38,"tag":54,"props":427,"children":428},{},[429,441],{"type":38,"tag":58,"props":430,"children":431},{},[432,433,439],{"type":44,"value":241},{"type":38,"tag":133,"props":434,"children":436},{"className":435},[],[437],{"type":44,"value":438},"verify(mock.method()).called(1)",{"type":44,"value":440}," to check exact invocation counts.",{"type":38,"tag":58,"props":442,"children":443},{},[444,446,452,454,460,462,468],{"type":44,"value":445},"Use argument matchers like ",{"type":38,"tag":133,"props":447,"children":449},{"className":448},[],[450],{"type":44,"value":451},"any",{"type":44,"value":453},", ",{"type":38,"tag":133,"props":455,"children":457},{"className":456},[],[458],{"type":44,"value":459},"anyNamed",{"type":44,"value":461},", or ",{"type":38,"tag":133,"props":463,"children":465},{"className":464},[],[466],{"type":44,"value":467},"captureAny",{"type":44,"value":469}," for flexible verification.",{"type":38,"tag":47,"props":471,"children":473},{"id":472},"workflow-creating-and-running-mocked-tests",[474],{"type":44,"value":103},{"type":38,"tag":119,"props":476,"children":477},{},[478],{"type":44,"value":479},"Use the following checklist to implement and verify mocked unit tests.",{"type":38,"tag":481,"props":482,"children":484},"h3",{"id":483},"task-progress",[485],{"type":44,"value":486},"Task Progress",{"type":38,"tag":54,"props":488,"children":491},{"className":489},[490],"contains-task-list",[492,512,521,545,576,592,615,631,640,664],{"type":38,"tag":58,"props":493,"children":496},{"className":494},[495],"task-list-item",[497,503,505,510],{"type":38,"tag":498,"props":499,"children":502},"input",{"disabled":500,"type":501},true,"checkbox",[],{"type":44,"value":504}," 1. Identify the external dependency to mock (e.g., ",{"type":38,"tag":133,"props":506,"children":508},{"className":507},[],[509],{"type":44,"value":138},{"type":44,"value":511},").",{"type":38,"tag":58,"props":513,"children":515},{"className":514},[495],[516,519],{"type":38,"tag":498,"props":517,"children":518},{"disabled":500,"type":501},[],{"type":44,"value":520}," 2. Inject the dependency into the target class constructor.",{"type":38,"tag":58,"props":522,"children":524},{"className":523},[495],[525,528,530,536,538,544],{"type":38,"tag":498,"props":526,"children":527},{"disabled":500,"type":501},[],{"type":44,"value":529}," 3. Create a test file (e.g., ",{"type":38,"tag":133,"props":531,"children":533},{"className":532},[],[534],{"type":44,"value":535},"target_test.dart",{"type":44,"value":537},") and add ",{"type":38,"tag":133,"props":539,"children":541},{"className":540},[],[542],{"type":44,"value":543},"@GenerateNiceMocks([MockSpec\u003CDependency>()])",{"type":44,"value":161},{"type":38,"tag":58,"props":546,"children":548},{"className":547},[495],[549,552,554,560,561,567,569,574],{"type":38,"tag":498,"props":550,"children":551},{"disabled":500,"type":501},[],{"type":44,"value":553}," 4. Add the ",{"type":38,"tag":133,"props":555,"children":557},{"className":556},[],[558],{"type":44,"value":559},"part",{"type":44,"value":399},{"type":38,"tag":133,"props":562,"children":564},{"className":563},[],[565],{"type":44,"value":566},"import",{"type":44,"value":568}," directive for the generated ",{"type":38,"tag":133,"props":570,"children":572},{"className":571},[],[573],{"type":44,"value":305},{"type":44,"value":575}," file.",{"type":38,"tag":58,"props":577,"children":579},{"className":578},[495],[580,583,585,590],{"type":38,"tag":498,"props":581,"children":582},{"disabled":500,"type":501},[],{"type":44,"value":584}," 5. Run ",{"type":38,"tag":133,"props":586,"children":588},{"className":587},[],[589],{"type":44,"value":325},{"type":44,"value":591}," to generate the mock classes.",{"type":38,"tag":58,"props":593,"children":595},{"className":594},[495],[596,599,601,607,608,614],{"type":38,"tag":498,"props":597,"children":598},{"disabled":500,"type":501},[],{"type":44,"value":600}," 6. Write the test cases using ",{"type":38,"tag":133,"props":602,"children":604},{"className":603},[],[605],{"type":44,"value":606},"group()",{"type":44,"value":249},{"type":38,"tag":133,"props":609,"children":611},{"className":610},[],[612],{"type":44,"value":613},"test()",{"type":44,"value":161},{"type":38,"tag":58,"props":616,"children":618},{"className":617},[495],[619,622,624,630],{"type":38,"tag":498,"props":620,"children":621},{"disabled":500,"type":501},[],{"type":44,"value":623}," 7. Stub required behaviors using ",{"type":38,"tag":133,"props":625,"children":627},{"className":626},[],[628],{"type":44,"value":629},"when()",{"type":44,"value":161},{"type":38,"tag":58,"props":632,"children":634},{"className":633},[495],[635,638],{"type":38,"tag":498,"props":636,"children":637},{"disabled":500,"type":501},[],{"type":44,"value":639}," 8. Execute the target method.",{"type":38,"tag":58,"props":641,"children":643},{"className":642},[495],[644,647,649,655,657,663],{"type":38,"tag":498,"props":645,"children":646},{"disabled":500,"type":501},[],{"type":44,"value":648}," 9. Verify interactions using ",{"type":38,"tag":133,"props":650,"children":652},{"className":651},[],[653],{"type":44,"value":654},"verify()",{"type":44,"value":656}," and assert outcomes using ",{"type":38,"tag":133,"props":658,"children":660},{"className":659},[],[661],{"type":44,"value":662},"expect()",{"type":44,"value":161},{"type":38,"tag":58,"props":665,"children":667},{"className":666},[495],[668,671,673,679],{"type":38,"tag":498,"props":669,"children":670},{"disabled":500,"type":501},[],{"type":44,"value":672}," 10. Run the test suite using ",{"type":38,"tag":133,"props":674,"children":676},{"className":675},[],[677],{"type":44,"value":678},"dart test",{"type":44,"value":161},{"type":38,"tag":481,"props":681,"children":683},{"id":682},"feedback-loop-test-failures",[684],{"type":44,"value":685},"Feedback Loop: Test Failures",{"type":38,"tag":119,"props":687,"children":688},{},[689,691,696],{"type":44,"value":690},"If tests fail or ",{"type":38,"tag":133,"props":692,"children":694},{"className":693},[],[695],{"type":44,"value":255},{"type":44,"value":697}," encounters errors:",{"type":38,"tag":699,"props":700,"children":701},"ol",{},[702,724,734,802],{"type":38,"tag":58,"props":703,"children":704},{},[705,710,712,717,718,723],{"type":38,"tag":352,"props":706,"children":707},{},[708],{"type":44,"value":709},"Run validator:",{"type":44,"value":711}," Execute ",{"type":38,"tag":133,"props":713,"children":715},{"className":714},[],[716],{"type":44,"value":678},{"type":44,"value":399},{"type":38,"tag":133,"props":719,"children":721},{"className":720},[],[722],{"type":44,"value":325},{"type":44,"value":161},{"type":38,"tag":58,"props":725,"children":726},{},[727,732],{"type":38,"tag":352,"props":728,"children":729},{},[730],{"type":44,"value":731},"Review errors:",{"type":44,"value":733}," Check for missing stubs, mismatched argument matchers, or syntax errors in the generated files.",{"type":38,"tag":58,"props":735,"children":736},{},[737,742],{"type":38,"tag":352,"props":738,"children":739},{},[740],{"type":44,"value":741},"Fix:",{"type":38,"tag":54,"props":743,"children":744},{},[745,756,783],{"type":38,"tag":58,"props":746,"children":747},{},[748,750,755],{"type":44,"value":749},"If a mock method throws an unexpected null error, ensure you used ",{"type":38,"tag":133,"props":751,"children":753},{"className":752},[],[754],{"type":44,"value":271},{"type":44,"value":161},{"type":38,"tag":58,"props":757,"children":758},{},[759,761,767,769,774,776,782],{"type":44,"value":760},"If an async stub throws an ",{"type":38,"tag":133,"props":762,"children":764},{"className":763},[],[765],{"type":44,"value":766},"ArgumentError",{"type":44,"value":768},", change ",{"type":38,"tag":133,"props":770,"children":772},{"className":771},[],[773],{"type":44,"value":413},{"type":44,"value":775}," to ",{"type":38,"tag":133,"props":777,"children":779},{"className":778},[],[780],{"type":44,"value":781},"thenAnswer",{"type":44,"value":161},{"type":38,"tag":58,"props":784,"children":785},{},[786,788,793,795,800],{"type":44,"value":787},"If ",{"type":38,"tag":133,"props":789,"children":791},{"className":790},[],[792],{"type":44,"value":255},{"type":44,"value":794}," fails, ensure the ",{"type":38,"tag":133,"props":796,"children":798},{"className":797},[],[799],{"type":44,"value":305},{"type":44,"value":801}," import matches the file name exactly.",{"type":38,"tag":58,"props":803,"children":804},{},[805],{"type":44,"value":806},"Repeat until all tests pass.",{"type":38,"tag":47,"props":808,"children":810},{"id":809},"examples",[811],{"type":44,"value":112},{"type":38,"tag":481,"props":813,"children":815},{"id":814},"high-fidelity-mocking-and-testing-example",[816],{"type":44,"value":817},"High-Fidelity Mocking and Testing Example",{"type":38,"tag":119,"props":819,"children":820},{},[821],{"type":38,"tag":352,"props":822,"children":823},{},[824,826,832],{"type":44,"value":825},"1. System Under Test (",{"type":38,"tag":133,"props":827,"children":829},{"className":828},[],[830],{"type":44,"value":831},"lib\u002Fapi_service.dart",{"type":44,"value":833},")",{"type":38,"tag":835,"props":836,"children":840},"pre",{"className":837,"code":838,"language":14,"meta":839,"style":839},"language-dart shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import 'dart:convert';\nimport 'package:http\u002Fhttp.dart' as http;\n\nclass ApiService {\n  final http.Client client;\n\n  ApiService(this.client);\n\n  Future\u003CString> fetchData(String urlString) async {\n    final uri = Uri.parse(urlString);\n    final response = await client.get(uri);\n\n    if (response.statusCode == 200) {\n      return jsonDecode(response.body)['data'];\n    } else {\n      throw Exception('Failed to load data');\n    }\n  }\n}\n","",[841],{"type":38,"tag":133,"props":842,"children":843},{"__ignoreMap":839},[844,855,864,873,882,891,899,908,916,925,934,943,951,960,969,978,987,996,1005],{"type":38,"tag":845,"props":846,"children":849},"span",{"class":847,"line":848},"line",1,[850],{"type":38,"tag":845,"props":851,"children":852},{},[853],{"type":44,"value":854},"import 'dart:convert';\n",{"type":38,"tag":845,"props":856,"children":858},{"class":847,"line":857},2,[859],{"type":38,"tag":845,"props":860,"children":861},{},[862],{"type":44,"value":863},"import 'package:http\u002Fhttp.dart' as http;\n",{"type":38,"tag":845,"props":865,"children":867},{"class":847,"line":866},3,[868],{"type":38,"tag":845,"props":869,"children":870},{"emptyLinePlaceholder":500},[871],{"type":44,"value":872},"\n",{"type":38,"tag":845,"props":874,"children":876},{"class":847,"line":875},4,[877],{"type":38,"tag":845,"props":878,"children":879},{},[880],{"type":44,"value":881},"class ApiService {\n",{"type":38,"tag":845,"props":883,"children":885},{"class":847,"line":884},5,[886],{"type":38,"tag":845,"props":887,"children":888},{},[889],{"type":44,"value":890},"  final http.Client client;\n",{"type":38,"tag":845,"props":892,"children":894},{"class":847,"line":893},6,[895],{"type":38,"tag":845,"props":896,"children":897},{"emptyLinePlaceholder":500},[898],{"type":44,"value":872},{"type":38,"tag":845,"props":900,"children":902},{"class":847,"line":901},7,[903],{"type":38,"tag":845,"props":904,"children":905},{},[906],{"type":44,"value":907},"  ApiService(this.client);\n",{"type":38,"tag":845,"props":909,"children":911},{"class":847,"line":910},8,[912],{"type":38,"tag":845,"props":913,"children":914},{"emptyLinePlaceholder":500},[915],{"type":44,"value":872},{"type":38,"tag":845,"props":917,"children":919},{"class":847,"line":918},9,[920],{"type":38,"tag":845,"props":921,"children":922},{},[923],{"type":44,"value":924},"  Future\u003CString> fetchData(String urlString) async {\n",{"type":38,"tag":845,"props":926,"children":928},{"class":847,"line":927},10,[929],{"type":38,"tag":845,"props":930,"children":931},{},[932],{"type":44,"value":933},"    final uri = Uri.parse(urlString);\n",{"type":38,"tag":845,"props":935,"children":937},{"class":847,"line":936},11,[938],{"type":38,"tag":845,"props":939,"children":940},{},[941],{"type":44,"value":942},"    final response = await client.get(uri);\n",{"type":38,"tag":845,"props":944,"children":946},{"class":847,"line":945},12,[947],{"type":38,"tag":845,"props":948,"children":949},{"emptyLinePlaceholder":500},[950],{"type":44,"value":872},{"type":38,"tag":845,"props":952,"children":954},{"class":847,"line":953},13,[955],{"type":38,"tag":845,"props":956,"children":957},{},[958],{"type":44,"value":959},"    if (response.statusCode == 200) {\n",{"type":38,"tag":845,"props":961,"children":963},{"class":847,"line":962},14,[964],{"type":38,"tag":845,"props":965,"children":966},{},[967],{"type":44,"value":968},"      return jsonDecode(response.body)['data'];\n",{"type":38,"tag":845,"props":970,"children":972},{"class":847,"line":971},15,[973],{"type":38,"tag":845,"props":974,"children":975},{},[976],{"type":44,"value":977},"    } else {\n",{"type":38,"tag":845,"props":979,"children":981},{"class":847,"line":980},16,[982],{"type":38,"tag":845,"props":983,"children":984},{},[985],{"type":44,"value":986},"      throw Exception('Failed to load data');\n",{"type":38,"tag":845,"props":988,"children":990},{"class":847,"line":989},17,[991],{"type":38,"tag":845,"props":992,"children":993},{},[994],{"type":44,"value":995},"    }\n",{"type":38,"tag":845,"props":997,"children":999},{"class":847,"line":998},18,[1000],{"type":38,"tag":845,"props":1001,"children":1002},{},[1003],{"type":44,"value":1004},"  }\n",{"type":38,"tag":845,"props":1006,"children":1008},{"class":847,"line":1007},19,[1009],{"type":38,"tag":845,"props":1010,"children":1011},{},[1012],{"type":44,"value":1013},"}\n",{"type":38,"tag":119,"props":1015,"children":1016},{},[1017],{"type":38,"tag":352,"props":1018,"children":1019},{},[1020,1022,1028],{"type":44,"value":1021},"2. Test Implementation (",{"type":38,"tag":133,"props":1023,"children":1025},{"className":1024},[],[1026],{"type":44,"value":1027},"test\u002Fapi_service_test.dart",{"type":44,"value":833},{"type":38,"tag":835,"props":1030,"children":1032},{"className":837,"code":1031,"language":14,"meta":839,"style":839},"import 'package:test\u002Ftest.dart';\nimport 'package:mockito\u002Fannotations.dart';\nimport 'package:mockito\u002Fmockito.dart';\nimport 'package:http\u002Fhttp.dart' as http;\nimport 'package:my_app\u002Fapi_service.dart';\n\n\u002F\u002F Generate the mock class for http.Client\n@GenerateNiceMocks([MockSpec\u003Chttp.Client>()])\nimport 'api_service_test.mocks.dart';\n\nvoid main() {\n  group('ApiService', () {\n    late ApiService apiService;\n    late MockClient mockHttpClient;\n\n    setUp(() {\n      mockHttpClient = MockClient();\n      apiService = ApiService(mockHttpClient);\n    });\n\n    test('returns data if the http call completes successfully', () async {\n      \u002F\u002F Arrange: Stub the async HTTP GET request using thenAnswer\n      when(mockHttpClient.get(any)).thenAnswer(\n        (_) async => http.Response('{\"data\": \"Success\"}', 200),\n      );\n\n      \u002F\u002F Act\n      final result = await apiService.fetchData('https:\u002F\u002Fapi.example.com\u002Fdata');\n\n      \u002F\u002F Assert\n      expect(result, 'Success');\n\n      \u002F\u002F Verify the mock was called with the correct Uri\n      verify(mockHttpClient.get(Uri.parse('https:\u002F\u002Fapi.example.com\u002Fdata'))).called(1);\n    });\n\n    test('throws an exception if the http call completes with an error', () {\n      \u002F\u002F Arrange\n      when(mockHttpClient.get(any)).thenAnswer(\n        (_) async => http.Response('Not Found', 404),\n      );\n\n      \u002F\u002F Act & Assert\n      expect(\n        apiService.fetchData('https:\u002F\u002Fapi.example.com\u002Fdata'),\n        throwsException,\n      );\n    });\n  });\n}\n",[1033],{"type":38,"tag":133,"props":1034,"children":1035},{"__ignoreMap":839},[1036,1044,1052,1060,1067,1075,1082,1090,1098,1106,1113,1121,1129,1137,1145,1152,1160,1168,1176,1184,1192,1201,1210,1219,1228,1237,1245,1254,1263,1271,1280,1289,1297,1306,1315,1323,1331,1340,1349,1357,1366,1374,1382,1391,1400,1409,1418,1426,1434,1443],{"type":38,"tag":845,"props":1037,"children":1038},{"class":847,"line":848},[1039],{"type":38,"tag":845,"props":1040,"children":1041},{},[1042],{"type":44,"value":1043},"import 'package:test\u002Ftest.dart';\n",{"type":38,"tag":845,"props":1045,"children":1046},{"class":847,"line":857},[1047],{"type":38,"tag":845,"props":1048,"children":1049},{},[1050],{"type":44,"value":1051},"import 'package:mockito\u002Fannotations.dart';\n",{"type":38,"tag":845,"props":1053,"children":1054},{"class":847,"line":866},[1055],{"type":38,"tag":845,"props":1056,"children":1057},{},[1058],{"type":44,"value":1059},"import 'package:mockito\u002Fmockito.dart';\n",{"type":38,"tag":845,"props":1061,"children":1062},{"class":847,"line":875},[1063],{"type":38,"tag":845,"props":1064,"children":1065},{},[1066],{"type":44,"value":863},{"type":38,"tag":845,"props":1068,"children":1069},{"class":847,"line":884},[1070],{"type":38,"tag":845,"props":1071,"children":1072},{},[1073],{"type":44,"value":1074},"import 'package:my_app\u002Fapi_service.dart';\n",{"type":38,"tag":845,"props":1076,"children":1077},{"class":847,"line":893},[1078],{"type":38,"tag":845,"props":1079,"children":1080},{"emptyLinePlaceholder":500},[1081],{"type":44,"value":872},{"type":38,"tag":845,"props":1083,"children":1084},{"class":847,"line":901},[1085],{"type":38,"tag":845,"props":1086,"children":1087},{},[1088],{"type":44,"value":1089},"\u002F\u002F Generate the mock class for http.Client\n",{"type":38,"tag":845,"props":1091,"children":1092},{"class":847,"line":910},[1093],{"type":38,"tag":845,"props":1094,"children":1095},{},[1096],{"type":44,"value":1097},"@GenerateNiceMocks([MockSpec\u003Chttp.Client>()])\n",{"type":38,"tag":845,"props":1099,"children":1100},{"class":847,"line":918},[1101],{"type":38,"tag":845,"props":1102,"children":1103},{},[1104],{"type":44,"value":1105},"import 'api_service_test.mocks.dart';\n",{"type":38,"tag":845,"props":1107,"children":1108},{"class":847,"line":927},[1109],{"type":38,"tag":845,"props":1110,"children":1111},{"emptyLinePlaceholder":500},[1112],{"type":44,"value":872},{"type":38,"tag":845,"props":1114,"children":1115},{"class":847,"line":936},[1116],{"type":38,"tag":845,"props":1117,"children":1118},{},[1119],{"type":44,"value":1120},"void main() {\n",{"type":38,"tag":845,"props":1122,"children":1123},{"class":847,"line":945},[1124],{"type":38,"tag":845,"props":1125,"children":1126},{},[1127],{"type":44,"value":1128},"  group('ApiService', () {\n",{"type":38,"tag":845,"props":1130,"children":1131},{"class":847,"line":953},[1132],{"type":38,"tag":845,"props":1133,"children":1134},{},[1135],{"type":44,"value":1136},"    late ApiService apiService;\n",{"type":38,"tag":845,"props":1138,"children":1139},{"class":847,"line":962},[1140],{"type":38,"tag":845,"props":1141,"children":1142},{},[1143],{"type":44,"value":1144},"    late MockClient mockHttpClient;\n",{"type":38,"tag":845,"props":1146,"children":1147},{"class":847,"line":971},[1148],{"type":38,"tag":845,"props":1149,"children":1150},{"emptyLinePlaceholder":500},[1151],{"type":44,"value":872},{"type":38,"tag":845,"props":1153,"children":1154},{"class":847,"line":980},[1155],{"type":38,"tag":845,"props":1156,"children":1157},{},[1158],{"type":44,"value":1159},"    setUp(() {\n",{"type":38,"tag":845,"props":1161,"children":1162},{"class":847,"line":989},[1163],{"type":38,"tag":845,"props":1164,"children":1165},{},[1166],{"type":44,"value":1167},"      mockHttpClient = MockClient();\n",{"type":38,"tag":845,"props":1169,"children":1170},{"class":847,"line":998},[1171],{"type":38,"tag":845,"props":1172,"children":1173},{},[1174],{"type":44,"value":1175},"      apiService = ApiService(mockHttpClient);\n",{"type":38,"tag":845,"props":1177,"children":1178},{"class":847,"line":1007},[1179],{"type":38,"tag":845,"props":1180,"children":1181},{},[1182],{"type":44,"value":1183},"    });\n",{"type":38,"tag":845,"props":1185,"children":1187},{"class":847,"line":1186},20,[1188],{"type":38,"tag":845,"props":1189,"children":1190},{"emptyLinePlaceholder":500},[1191],{"type":44,"value":872},{"type":38,"tag":845,"props":1193,"children":1195},{"class":847,"line":1194},21,[1196],{"type":38,"tag":845,"props":1197,"children":1198},{},[1199],{"type":44,"value":1200},"    test('returns data if the http call completes successfully', () async {\n",{"type":38,"tag":845,"props":1202,"children":1204},{"class":847,"line":1203},22,[1205],{"type":38,"tag":845,"props":1206,"children":1207},{},[1208],{"type":44,"value":1209},"      \u002F\u002F Arrange: Stub the async HTTP GET request using thenAnswer\n",{"type":38,"tag":845,"props":1211,"children":1213},{"class":847,"line":1212},23,[1214],{"type":38,"tag":845,"props":1215,"children":1216},{},[1217],{"type":44,"value":1218},"      when(mockHttpClient.get(any)).thenAnswer(\n",{"type":38,"tag":845,"props":1220,"children":1222},{"class":847,"line":1221},24,[1223],{"type":38,"tag":845,"props":1224,"children":1225},{},[1226],{"type":44,"value":1227},"        (_) async => http.Response('{\"data\": \"Success\"}', 200),\n",{"type":38,"tag":845,"props":1229,"children":1231},{"class":847,"line":1230},25,[1232],{"type":38,"tag":845,"props":1233,"children":1234},{},[1235],{"type":44,"value":1236},"      );\n",{"type":38,"tag":845,"props":1238,"children":1240},{"class":847,"line":1239},26,[1241],{"type":38,"tag":845,"props":1242,"children":1243},{"emptyLinePlaceholder":500},[1244],{"type":44,"value":872},{"type":38,"tag":845,"props":1246,"children":1248},{"class":847,"line":1247},27,[1249],{"type":38,"tag":845,"props":1250,"children":1251},{},[1252],{"type":44,"value":1253},"      \u002F\u002F Act\n",{"type":38,"tag":845,"props":1255,"children":1257},{"class":847,"line":1256},28,[1258],{"type":38,"tag":845,"props":1259,"children":1260},{},[1261],{"type":44,"value":1262},"      final result = await apiService.fetchData('https:\u002F\u002Fapi.example.com\u002Fdata');\n",{"type":38,"tag":845,"props":1264,"children":1266},{"class":847,"line":1265},29,[1267],{"type":38,"tag":845,"props":1268,"children":1269},{"emptyLinePlaceholder":500},[1270],{"type":44,"value":872},{"type":38,"tag":845,"props":1272,"children":1274},{"class":847,"line":1273},30,[1275],{"type":38,"tag":845,"props":1276,"children":1277},{},[1278],{"type":44,"value":1279},"      \u002F\u002F Assert\n",{"type":38,"tag":845,"props":1281,"children":1283},{"class":847,"line":1282},31,[1284],{"type":38,"tag":845,"props":1285,"children":1286},{},[1287],{"type":44,"value":1288},"      expect(result, 'Success');\n",{"type":38,"tag":845,"props":1290,"children":1292},{"class":847,"line":1291},32,[1293],{"type":38,"tag":845,"props":1294,"children":1295},{"emptyLinePlaceholder":500},[1296],{"type":44,"value":872},{"type":38,"tag":845,"props":1298,"children":1300},{"class":847,"line":1299},33,[1301],{"type":38,"tag":845,"props":1302,"children":1303},{},[1304],{"type":44,"value":1305},"      \u002F\u002F Verify the mock was called with the correct Uri\n",{"type":38,"tag":845,"props":1307,"children":1309},{"class":847,"line":1308},34,[1310],{"type":38,"tag":845,"props":1311,"children":1312},{},[1313],{"type":44,"value":1314},"      verify(mockHttpClient.get(Uri.parse('https:\u002F\u002Fapi.example.com\u002Fdata'))).called(1);\n",{"type":38,"tag":845,"props":1316,"children":1318},{"class":847,"line":1317},35,[1319],{"type":38,"tag":845,"props":1320,"children":1321},{},[1322],{"type":44,"value":1183},{"type":38,"tag":845,"props":1324,"children":1326},{"class":847,"line":1325},36,[1327],{"type":38,"tag":845,"props":1328,"children":1329},{"emptyLinePlaceholder":500},[1330],{"type":44,"value":872},{"type":38,"tag":845,"props":1332,"children":1334},{"class":847,"line":1333},37,[1335],{"type":38,"tag":845,"props":1336,"children":1337},{},[1338],{"type":44,"value":1339},"    test('throws an exception if the http call completes with an error', () {\n",{"type":38,"tag":845,"props":1341,"children":1343},{"class":847,"line":1342},38,[1344],{"type":38,"tag":845,"props":1345,"children":1346},{},[1347],{"type":44,"value":1348},"      \u002F\u002F Arrange\n",{"type":38,"tag":845,"props":1350,"children":1352},{"class":847,"line":1351},39,[1353],{"type":38,"tag":845,"props":1354,"children":1355},{},[1356],{"type":44,"value":1218},{"type":38,"tag":845,"props":1358,"children":1360},{"class":847,"line":1359},40,[1361],{"type":38,"tag":845,"props":1362,"children":1363},{},[1364],{"type":44,"value":1365},"        (_) async => http.Response('Not Found', 404),\n",{"type":38,"tag":845,"props":1367,"children":1369},{"class":847,"line":1368},41,[1370],{"type":38,"tag":845,"props":1371,"children":1372},{},[1373],{"type":44,"value":1236},{"type":38,"tag":845,"props":1375,"children":1377},{"class":847,"line":1376},42,[1378],{"type":38,"tag":845,"props":1379,"children":1380},{"emptyLinePlaceholder":500},[1381],{"type":44,"value":872},{"type":38,"tag":845,"props":1383,"children":1385},{"class":847,"line":1384},43,[1386],{"type":38,"tag":845,"props":1387,"children":1388},{},[1389],{"type":44,"value":1390},"      \u002F\u002F Act & Assert\n",{"type":38,"tag":845,"props":1392,"children":1394},{"class":847,"line":1393},44,[1395],{"type":38,"tag":845,"props":1396,"children":1397},{},[1398],{"type":44,"value":1399},"      expect(\n",{"type":38,"tag":845,"props":1401,"children":1403},{"class":847,"line":1402},45,[1404],{"type":38,"tag":845,"props":1405,"children":1406},{},[1407],{"type":44,"value":1408},"        apiService.fetchData('https:\u002F\u002Fapi.example.com\u002Fdata'),\n",{"type":38,"tag":845,"props":1410,"children":1412},{"class":847,"line":1411},46,[1413],{"type":38,"tag":845,"props":1414,"children":1415},{},[1416],{"type":44,"value":1417},"        throwsException,\n",{"type":38,"tag":845,"props":1419,"children":1421},{"class":847,"line":1420},47,[1422],{"type":38,"tag":845,"props":1423,"children":1424},{},[1425],{"type":44,"value":1236},{"type":38,"tag":845,"props":1427,"children":1429},{"class":847,"line":1428},48,[1430],{"type":38,"tag":845,"props":1431,"children":1432},{},[1433],{"type":44,"value":1183},{"type":38,"tag":845,"props":1435,"children":1437},{"class":847,"line":1436},49,[1438],{"type":38,"tag":845,"props":1439,"children":1440},{},[1441],{"type":44,"value":1442},"  });\n",{"type":38,"tag":845,"props":1444,"children":1446},{"class":847,"line":1445},50,[1447],{"type":38,"tag":845,"props":1448,"children":1449},{},[1450],{"type":44,"value":1013},{"type":38,"tag":1452,"props":1453,"children":1454},"style",{},[1455],{"type":44,"value":1456},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":1458,"total":1247},[1459,1468,1479,1491,1502,1507,1519,1531,1543,1555,1569,1579],{"slug":1460,"name":1460,"fn":1461,"description":1462,"org":1463,"tags":1464,"stars":19,"repoUrl":20,"updatedAt":1467},"dart-add-unit-test","write unit tests for Dart code","Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1465,1466],{"name":13,"slug":14,"type":15},{"name":17,"slug":18,"type":15},"2026-07-15T05:22:40.104823",{"slug":1469,"name":1469,"fn":1470,"description":1471,"org":1472,"tags":1473,"stars":19,"repoUrl":20,"updatedAt":1478},"dart-build-cli-app","build Dart command line applications","Entrypoint structure, exit codes, cross-platform scripts. Use when building command line utilities, scripts, or applications.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1474,1477],{"name":1475,"slug":1476,"type":15},"CLI","cli",{"name":13,"slug":14,"type":15},"2026-07-15T05:22:18.863572",{"slug":1480,"name":1480,"fn":1481,"description":1482,"org":1483,"tags":1484,"stars":19,"repoUrl":20,"updatedAt":1490},"dart-collect-coverage","collect Dart test coverage reports","Collect coverage using the coverage packge and create an LCOV report",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1485,1486,1489],{"name":13,"slug":14,"type":15},{"name":1487,"slug":1488,"type":15},"Reporting","reporting",{"name":17,"slug":18,"type":15},"2026-07-15T05:22:21.38636",{"slug":1492,"name":1492,"fn":1493,"description":1494,"org":1495,"tags":1496,"stars":19,"repoUrl":20,"updatedAt":1501},"dart-fix-runtime-errors","debug and fix Dart runtime errors","Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1497,1498],{"name":13,"slug":14,"type":15},{"name":1499,"slug":1500,"type":15},"Debugging","debugging","2026-07-15T05:22:22.622501",{"slug":4,"name":4,"fn":5,"description":6,"org":1503,"tags":1504,"stars":19,"repoUrl":20,"updatedAt":21},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1505,1506],{"name":13,"slug":14,"type":15},{"name":17,"slug":18,"type":15},{"slug":1508,"name":1508,"fn":1509,"description":1510,"org":1511,"tags":1512,"stars":19,"repoUrl":20,"updatedAt":1518},"dart-migrate-to-checks-package","migrate test matchers to checks package","Replace the usage of `expect` and similar functions from `package:matcher`\nto `package:checks` equivalents.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1513,1514,1517],{"name":13,"slug":14,"type":15},{"name":1515,"slug":1516,"type":15},"Migration","migration",{"name":17,"slug":18,"type":15},"2026-07-15T05:22:31.276564",{"slug":1520,"name":1520,"fn":1521,"description":1522,"org":1523,"tags":1524,"stars":19,"repoUrl":20,"updatedAt":1530},"dart-resolve-package-conflicts","resolve Dart package version conflicts","Workflow for fixing package version conflicts. Use this when `pub get` fails due to incompatible package versions.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1525,1526,1527],{"name":13,"slug":14,"type":15},{"name":1499,"slug":1500,"type":15},{"name":1528,"slug":1529,"type":15},"Engineering","engineering","2026-07-15T05:22:30.059335",{"slug":1532,"name":1532,"fn":1533,"description":1534,"org":1535,"tags":1536,"stars":19,"repoUrl":20,"updatedAt":1542},"dart-run-static-analysis","run static analysis and apply fixes","Execute `dart analyze` to identify warnings and errors, and use `dart fix --apply` to automatically resolve mechanical lint issues. Use during development to ensure code quality and before committing changes.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1537,1540,1541],{"name":1538,"slug":1539,"type":15},"Code Analysis","code-analysis",{"name":13,"slug":14,"type":15},{"name":1499,"slug":1500,"type":15},"2026-07-15T05:22:23.861119",{"slug":1544,"name":1544,"fn":1545,"description":1546,"org":1547,"tags":1548,"stars":19,"repoUrl":20,"updatedAt":1554},"dart-setup-ffi-assets","package C\u002FC++ assets for Dart","Guides agents in compiling and packaging C\u002FC++ source code into dynamic or static libraries (Code Assets) using Dart's Native Assets hook system (via hook\u002Fbuild.dart and hook\u002Flink.dart utilizing package:hooks and package:native_toolchain_c). Use when a user asks to: 'setup native assets', 'compile C\u002FC++ source code', 'bundle dynamic libraries', 'build native C code', 'link native assets', 'implement build.dart or link.dart hooks', or 'integrate C\u002FC++ interop in Dart\u002FFlutter'. Helps agents avoid manual toolchain orchestration and configures secure hash-validated binary downloads or advanced linker tree-shaking with package:record_use mapping.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1549,1550,1553],{"name":13,"slug":14,"type":15},{"name":1551,"slug":1552,"type":15},"Deployment","deployment",{"name":1528,"slug":1529,"type":15},"2026-07-15T05:22:20.138636",{"slug":1556,"name":1556,"fn":1557,"description":1558,"org":1559,"tags":1560,"stars":19,"repoUrl":20,"updatedAt":1568},"dart-skills-lint-setup","configure dart_skills_lint for Dart projects","Use this skill when you need to set up validation for AI agent skills in a Dart project for the first time.\nAdds the linter as a dev_dependency, creates a configuration file, and generates a baseline for legacy repos.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1561,1562,1565],{"name":13,"slug":14,"type":15},{"name":1563,"slug":1564,"type":15},"Plugin Development","plugin-development",{"name":1566,"slug":1567,"type":15},"QA","qa","2026-07-15T05:22:47.488998",{"slug":1570,"name":1570,"fn":1571,"description":1572,"org":1573,"tags":1574,"stars":19,"repoUrl":20,"updatedAt":1578},"dart-skills-lint-validation","validate agent skills with dart_skills_lint","Use this skill when you need to validate AI agent skills with dart_skills_lint — running the linter, interpreting failures, fixing violations, and authoring custom rules.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1575,1576,1577],{"name":13,"slug":14,"type":15},{"name":1563,"slug":1564,"type":15},{"name":1566,"slug":1567,"type":15},"2026-07-21T05:38:34.451024",{"slug":1580,"name":1580,"fn":1581,"description":1582,"org":1583,"tags":1584,"stars":19,"repoUrl":20,"updatedAt":1587},"dart-use-ffigen","generate FFI bindings with ffigen","Guide agents to use `package:ffigen` to automatically generate FFI bindings instead of writing them manually. Use this skill when a task involves writing new FFI bindings, extending C\u002FObjective-C\u002FSwift integrations, or replacing hand-crafted `dart:ffi` setups.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1585,1586],{"name":13,"slug":14,"type":15},{"name":1528,"slug":1529,"type":15},"2026-07-15T05:22:17.592351",{"items":1589,"total":1221},[1590,1595,1600,1606,1611,1616,1622],{"slug":1460,"name":1460,"fn":1461,"description":1462,"org":1591,"tags":1592,"stars":19,"repoUrl":20,"updatedAt":1467},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1593,1594],{"name":13,"slug":14,"type":15},{"name":17,"slug":18,"type":15},{"slug":1469,"name":1469,"fn":1470,"description":1471,"org":1596,"tags":1597,"stars":19,"repoUrl":20,"updatedAt":1478},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1598,1599],{"name":1475,"slug":1476,"type":15},{"name":13,"slug":14,"type":15},{"slug":1480,"name":1480,"fn":1481,"description":1482,"org":1601,"tags":1602,"stars":19,"repoUrl":20,"updatedAt":1490},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1603,1604,1605],{"name":13,"slug":14,"type":15},{"name":1487,"slug":1488,"type":15},{"name":17,"slug":18,"type":15},{"slug":1492,"name":1492,"fn":1493,"description":1494,"org":1607,"tags":1608,"stars":19,"repoUrl":20,"updatedAt":1501},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1609,1610],{"name":13,"slug":14,"type":15},{"name":1499,"slug":1500,"type":15},{"slug":4,"name":4,"fn":5,"description":6,"org":1612,"tags":1613,"stars":19,"repoUrl":20,"updatedAt":21},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1614,1615],{"name":13,"slug":14,"type":15},{"name":17,"slug":18,"type":15},{"slug":1508,"name":1508,"fn":1509,"description":1510,"org":1617,"tags":1618,"stars":19,"repoUrl":20,"updatedAt":1518},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1619,1620,1621],{"name":13,"slug":14,"type":15},{"name":1515,"slug":1516,"type":15},{"name":17,"slug":18,"type":15},{"slug":1520,"name":1520,"fn":1521,"description":1522,"org":1623,"tags":1624,"stars":19,"repoUrl":20,"updatedAt":1530},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1625,1626,1627],{"name":13,"slug":14,"type":15},{"name":1499,"slug":1500,"type":15},{"name":1528,"slug":1529,"type":15}]