[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-flutter-dart-add-unit-test":3,"mdc--yn4ovg-key":29,"related-repo-flutter-dart-add-unit-test":1065,"related-org-flutter-dart-add-unit-test":1139},{"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-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},"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:40.104823",null,155,[],{"repoUrl":20,"stars":19,"forks":23,"topics":26,"description":22},[],"https:\u002F\u002Fgithub.com\u002Fflutter\u002Fagent-plugins\u002Ftree\u002FHEAD\u002Fskills\u002Fdart-add-unit-test","---\nname: dart-add-unit-test\ndescription: 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.\nmetadata:\n  model: models\u002Fgemini-3.1-pro-preview\n  last_modified: Fri, 24 Apr 2026 15:07:58 GMT\n---\n# Testing Dart and Flutter Applications\n\n## Contents\n- [Structuring Test Files](#structuring-test-files)\n- [Writing Tests](#writing-tests)\n- [Executing Tests](#executing-tests)\n- [Test Implementation Workflow](#test-implementation-workflow)\n- [Examples](#examples)\n\n## Structuring Test Files\nOrganize test files to mirror the `lib` directory structure to maintain predictability.\n\n* Place all test code within the `test` directory at the root of the package.\n* Append `_test.dart` to the end of all test file names (e.g., `lib\u002Fsrc\u002Futils.dart` should be tested in `test\u002Fsrc\u002Futils_test.dart`).\n* If writing integration tests, place them in an `integration_test` directory at the root of the package.\n\n## Writing Tests\nUtilize `package:test` as the standard testing library for Dart applications.\n\n* Import `package:test\u002Ftest.dart` (or `package:flutter_test\u002Fflutter_test.dart` for Flutter).\n* Group related tests using the `group()` function to provide shared context.\n* Define individual test cases using the `test()` function.\n* Validate outcomes using the `expect()` function alongside matchers (e.g., `equals()`, `isTrue`, `throwsA()`).\n* Write asynchronous tests using standard `async`\u002F`await` syntax. The test runner automatically waits for the `Future` to complete.\n* Manage test setup and teardown using `setUp()` and `tearDown()` callbacks.\n* If testing code that relies on dependency injection, use `package:mockito` alongside `package:test` to generate mock objects, configure fixed scenarios, and verify interactions.\n\n## Executing Tests\nSelect the appropriate test runner based on the project type and test location.\n\n* If working on a pure Dart project, execute tests using the `dart test` command.\n* If working on a Flutter project, execute tests using the `flutter test` command.\n* If running integration tests, explicitly specify the directory path, as the default runner ignores it: `dart test integration_test` or `flutter test integration_test`.\n\n## Test Implementation Workflow\n\nFollow this sequential workflow when implementing new test suites. Copy the checklist to track your progress.\n\n### Task Progress\n- [ ] 1. Create the test file in the `test\u002F` directory, ensuring the `_test.dart` suffix.\n- [ ] 2. Import `package:test\u002Ftest.dart` and the target library.\n- [ ] 3. Define a `main()` function.\n- [ ] 4. Initialize shared resources or mocks using `setUp()`.\n- [ ] 5. Write `test()` cases grouped by functionality using `group()`.\n- [ ] 6. Execute the test suite using the appropriate CLI command.\n- [ ] 7. **Feedback Loop**: Run test -> Review stack trace for failures -> Fix implementation or assertions -> Re-run until passing.\n\n## Examples\n\n### Standard Unit Test Suite\nDemonstrates grouping, setup, synchronous, and asynchronous testing.\n\n```dart\nimport 'package:test\u002Ftest.dart';\nimport 'package:my_package\u002Fcalculator.dart';\n\nvoid main() {\n  group('Calculator', () {\n    late Calculator calc;\n\n    setUp(() {\n      calc = Calculator();\n    });\n\n    test('adds two numbers correctly', () {\n      expect(calc.add(2, 3), equals(5));\n    });\n\n    test('handles asynchronous operations', () async {\n      final result = await calc.fetchRemoteValue();\n      expect(result, isNotNull);\n      expect(result, greaterThan(0));\n    });\n  });\n}\n```\n\n### Mocking with Mockito\nDemonstrates configuring a mock object for dependency injection testing.\n\n```dart\nimport 'package:test\u002Ftest.dart';\nimport 'package:mockito\u002Fmockito.dart';\nimport 'package:mockito\u002Fannotations.dart';\nimport 'package:my_package\u002Fapi_client.dart';\nimport 'package:my_package\u002Fdata_service.dart';\n\n\u002F\u002F Generate the mock using build_runner: dart run build_runner build\n@GenerateNiceMocks([MockSpec\u003CApiClient>()])\nimport 'data_service_test.mocks.dart';\n\nvoid main() {\n  group('DataService', () {\n    late MockApiClient mockApiClient;\n    late DataService dataService;\n\n    setUp(() {\n      mockApiClient = MockApiClient();\n      dataService = DataService(apiClient: mockApiClient);\n    });\n\n    test('returns parsed data on successful API call', () async {\n      \u002F\u002F Configure the mock\n      when(mockApiClient.get('\u002Fdata')).thenAnswer((_) async => '{\"id\": 1}');\n\n      \u002F\u002F Execute the system under test\n      final result = await dataService.fetchData();\n\n      \u002F\u002F Verify outcomes and interactions\n      expect(result.id, equals(1));\n      verify(mockApiClient.get('\u002Fdata')).called(1);\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:07:58 GMT",{"type":35,"children":36},"root",[37,46,53,104,109,124,181,186,199,354,359,364,413,418,423,430,558,563,569,574,779,785,790,1059],{"type":38,"tag":39,"props":40,"children":42},"element","h1",{"id":41},"testing-dart-and-flutter-applications",[43],{"type":44,"value":45},"text","Testing Dart and Flutter 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],{"type":38,"tag":58,"props":59,"children":60},"li",{},[61],{"type":38,"tag":62,"props":63,"children":65},"a",{"href":64},"#structuring-test-files",[66],{"type":44,"value":67},"Structuring Test Files",{"type":38,"tag":58,"props":69,"children":70},{},[71],{"type":38,"tag":62,"props":72,"children":74},{"href":73},"#writing-tests",[75],{"type":44,"value":76},"Writing Tests",{"type":38,"tag":58,"props":78,"children":79},{},[80],{"type":38,"tag":62,"props":81,"children":83},{"href":82},"#executing-tests",[84],{"type":44,"value":85},"Executing Tests",{"type":38,"tag":58,"props":87,"children":88},{},[89],{"type":38,"tag":62,"props":90,"children":92},{"href":91},"#test-implementation-workflow",[93],{"type":44,"value":94},"Test Implementation Workflow",{"type":38,"tag":58,"props":96,"children":97},{},[98],{"type":38,"tag":62,"props":99,"children":101},{"href":100},"#examples",[102],{"type":44,"value":103},"Examples",{"type":38,"tag":47,"props":105,"children":107},{"id":106},"structuring-test-files",[108],{"type":44,"value":67},{"type":38,"tag":110,"props":111,"children":112},"p",{},[113,115,122],{"type":44,"value":114},"Organize test files to mirror the ",{"type":38,"tag":116,"props":117,"children":119},"code",{"className":118},[],[120],{"type":44,"value":121},"lib",{"type":44,"value":123}," directory structure to maintain predictability.",{"type":38,"tag":54,"props":125,"children":126},{},[127,140,169],{"type":38,"tag":58,"props":128,"children":129},{},[130,132,138],{"type":44,"value":131},"Place all test code within the ",{"type":38,"tag":116,"props":133,"children":135},{"className":134},[],[136],{"type":44,"value":137},"test",{"type":44,"value":139}," directory at the root of the package.",{"type":38,"tag":58,"props":141,"children":142},{},[143,145,151,153,159,161,167],{"type":44,"value":144},"Append ",{"type":38,"tag":116,"props":146,"children":148},{"className":147},[],[149],{"type":44,"value":150},"_test.dart",{"type":44,"value":152}," to the end of all test file names (e.g., ",{"type":38,"tag":116,"props":154,"children":156},{"className":155},[],[157],{"type":44,"value":158},"lib\u002Fsrc\u002Futils.dart",{"type":44,"value":160}," should be tested in ",{"type":38,"tag":116,"props":162,"children":164},{"className":163},[],[165],{"type":44,"value":166},"test\u002Fsrc\u002Futils_test.dart",{"type":44,"value":168},").",{"type":38,"tag":58,"props":170,"children":171},{},[172,174,180],{"type":44,"value":173},"If writing integration tests, place them in an ",{"type":38,"tag":116,"props":175,"children":177},{"className":176},[],[178],{"type":44,"value":179},"integration_test",{"type":44,"value":139},{"type":38,"tag":47,"props":182,"children":184},{"id":183},"writing-tests",[185],{"type":44,"value":76},{"type":38,"tag":110,"props":187,"children":188},{},[189,191,197],{"type":44,"value":190},"Utilize ",{"type":38,"tag":116,"props":192,"children":194},{"className":193},[],[195],{"type":44,"value":196},"package:test",{"type":44,"value":198}," as the standard testing library for Dart applications.",{"type":38,"tag":54,"props":200,"children":201},{},[202,223,236,249,284,313,334],{"type":38,"tag":58,"props":203,"children":204},{},[205,207,213,215,221],{"type":44,"value":206},"Import ",{"type":38,"tag":116,"props":208,"children":210},{"className":209},[],[211],{"type":44,"value":212},"package:test\u002Ftest.dart",{"type":44,"value":214}," (or ",{"type":38,"tag":116,"props":216,"children":218},{"className":217},[],[219],{"type":44,"value":220},"package:flutter_test\u002Fflutter_test.dart",{"type":44,"value":222}," for Flutter).",{"type":38,"tag":58,"props":224,"children":225},{},[226,228,234],{"type":44,"value":227},"Group related tests using the ",{"type":38,"tag":116,"props":229,"children":231},{"className":230},[],[232],{"type":44,"value":233},"group()",{"type":44,"value":235}," function to provide shared context.",{"type":38,"tag":58,"props":237,"children":238},{},[239,241,247],{"type":44,"value":240},"Define individual test cases using the ",{"type":38,"tag":116,"props":242,"children":244},{"className":243},[],[245],{"type":44,"value":246},"test()",{"type":44,"value":248}," function.",{"type":38,"tag":58,"props":250,"children":251},{},[252,254,260,262,268,270,276,277,283],{"type":44,"value":253},"Validate outcomes using the ",{"type":38,"tag":116,"props":255,"children":257},{"className":256},[],[258],{"type":44,"value":259},"expect()",{"type":44,"value":261}," function alongside matchers (e.g., ",{"type":38,"tag":116,"props":263,"children":265},{"className":264},[],[266],{"type":44,"value":267},"equals()",{"type":44,"value":269},", ",{"type":38,"tag":116,"props":271,"children":273},{"className":272},[],[274],{"type":44,"value":275},"isTrue",{"type":44,"value":269},{"type":38,"tag":116,"props":278,"children":280},{"className":279},[],[281],{"type":44,"value":282},"throwsA()",{"type":44,"value":168},{"type":38,"tag":58,"props":285,"children":286},{},[287,289,295,297,303,305,311],{"type":44,"value":288},"Write asynchronous tests using standard ",{"type":38,"tag":116,"props":290,"children":292},{"className":291},[],[293],{"type":44,"value":294},"async",{"type":44,"value":296},"\u002F",{"type":38,"tag":116,"props":298,"children":300},{"className":299},[],[301],{"type":44,"value":302},"await",{"type":44,"value":304}," syntax. The test runner automatically waits for the ",{"type":38,"tag":116,"props":306,"children":308},{"className":307},[],[309],{"type":44,"value":310},"Future",{"type":44,"value":312}," to complete.",{"type":38,"tag":58,"props":314,"children":315},{},[316,318,324,326,332],{"type":44,"value":317},"Manage test setup and teardown using ",{"type":38,"tag":116,"props":319,"children":321},{"className":320},[],[322],{"type":44,"value":323},"setUp()",{"type":44,"value":325}," and ",{"type":38,"tag":116,"props":327,"children":329},{"className":328},[],[330],{"type":44,"value":331},"tearDown()",{"type":44,"value":333}," callbacks.",{"type":38,"tag":58,"props":335,"children":336},{},[337,339,345,347,352],{"type":44,"value":338},"If testing code that relies on dependency injection, use ",{"type":38,"tag":116,"props":340,"children":342},{"className":341},[],[343],{"type":44,"value":344},"package:mockito",{"type":44,"value":346}," alongside ",{"type":38,"tag":116,"props":348,"children":350},{"className":349},[],[351],{"type":44,"value":196},{"type":44,"value":353}," to generate mock objects, configure fixed scenarios, and verify interactions.",{"type":38,"tag":47,"props":355,"children":357},{"id":356},"executing-tests",[358],{"type":44,"value":85},{"type":38,"tag":110,"props":360,"children":361},{},[362],{"type":44,"value":363},"Select the appropriate test runner based on the project type and test location.",{"type":38,"tag":54,"props":365,"children":366},{},[367,380,392],{"type":38,"tag":58,"props":368,"children":369},{},[370,372,378],{"type":44,"value":371},"If working on a pure Dart project, execute tests using the ",{"type":38,"tag":116,"props":373,"children":375},{"className":374},[],[376],{"type":44,"value":377},"dart test",{"type":44,"value":379}," command.",{"type":38,"tag":58,"props":381,"children":382},{},[383,385,391],{"type":44,"value":384},"If working on a Flutter project, execute tests using the ",{"type":38,"tag":116,"props":386,"children":388},{"className":387},[],[389],{"type":44,"value":390},"flutter test",{"type":44,"value":379},{"type":38,"tag":58,"props":393,"children":394},{},[395,397,403,405,411],{"type":44,"value":396},"If running integration tests, explicitly specify the directory path, as the default runner ignores it: ",{"type":38,"tag":116,"props":398,"children":400},{"className":399},[],[401],{"type":44,"value":402},"dart test integration_test",{"type":44,"value":404}," or ",{"type":38,"tag":116,"props":406,"children":408},{"className":407},[],[409],{"type":44,"value":410},"flutter test integration_test",{"type":44,"value":412},".",{"type":38,"tag":47,"props":414,"children":416},{"id":415},"test-implementation-workflow",[417],{"type":44,"value":94},{"type":38,"tag":110,"props":419,"children":420},{},[421],{"type":44,"value":422},"Follow this sequential workflow when implementing new test suites. Copy the checklist to track your progress.",{"type":38,"tag":424,"props":425,"children":427},"h3",{"id":426},"task-progress",[428],{"type":44,"value":429},"Task Progress",{"type":38,"tag":54,"props":431,"children":434},{"className":432},[433],"contains-task-list",[435,463,479,495,510,532,541],{"type":38,"tag":58,"props":436,"children":439},{"className":437},[438],"task-list-item",[440,446,448,454,456,461],{"type":38,"tag":441,"props":442,"children":445},"input",{"disabled":443,"type":444},true,"checkbox",[],{"type":44,"value":447}," 1. Create the test file in the ",{"type":38,"tag":116,"props":449,"children":451},{"className":450},[],[452],{"type":44,"value":453},"test\u002F",{"type":44,"value":455}," directory, ensuring the ",{"type":38,"tag":116,"props":457,"children":459},{"className":458},[],[460],{"type":44,"value":150},{"type":44,"value":462}," suffix.",{"type":38,"tag":58,"props":464,"children":466},{"className":465},[438],[467,470,472,477],{"type":38,"tag":441,"props":468,"children":469},{"disabled":443,"type":444},[],{"type":44,"value":471}," 2. Import ",{"type":38,"tag":116,"props":473,"children":475},{"className":474},[],[476],{"type":44,"value":212},{"type":44,"value":478}," and the target library.",{"type":38,"tag":58,"props":480,"children":482},{"className":481},[438],[483,486,488,494],{"type":38,"tag":441,"props":484,"children":485},{"disabled":443,"type":444},[],{"type":44,"value":487}," 3. Define a ",{"type":38,"tag":116,"props":489,"children":491},{"className":490},[],[492],{"type":44,"value":493},"main()",{"type":44,"value":248},{"type":38,"tag":58,"props":496,"children":498},{"className":497},[438],[499,502,504,509],{"type":38,"tag":441,"props":500,"children":501},{"disabled":443,"type":444},[],{"type":44,"value":503}," 4. Initialize shared resources or mocks using ",{"type":38,"tag":116,"props":505,"children":507},{"className":506},[],[508],{"type":44,"value":323},{"type":44,"value":412},{"type":38,"tag":58,"props":511,"children":513},{"className":512},[438],[514,517,519,524,526,531],{"type":38,"tag":441,"props":515,"children":516},{"disabled":443,"type":444},[],{"type":44,"value":518}," 5. Write ",{"type":38,"tag":116,"props":520,"children":522},{"className":521},[],[523],{"type":44,"value":246},{"type":44,"value":525}," cases grouped by functionality using ",{"type":38,"tag":116,"props":527,"children":529},{"className":528},[],[530],{"type":44,"value":233},{"type":44,"value":412},{"type":38,"tag":58,"props":533,"children":535},{"className":534},[438],[536,539],{"type":38,"tag":441,"props":537,"children":538},{"disabled":443,"type":444},[],{"type":44,"value":540}," 6. Execute the test suite using the appropriate CLI command.",{"type":38,"tag":58,"props":542,"children":544},{"className":543},[438],[545,548,550,556],{"type":38,"tag":441,"props":546,"children":547},{"disabled":443,"type":444},[],{"type":44,"value":549}," 7. ",{"type":38,"tag":551,"props":552,"children":553},"strong",{},[554],{"type":44,"value":555},"Feedback Loop",{"type":44,"value":557},": Run test -> Review stack trace for failures -> Fix implementation or assertions -> Re-run until passing.",{"type":38,"tag":47,"props":559,"children":561},{"id":560},"examples",[562],{"type":44,"value":103},{"type":38,"tag":424,"props":564,"children":566},{"id":565},"standard-unit-test-suite",[567],{"type":44,"value":568},"Standard Unit Test Suite",{"type":38,"tag":110,"props":570,"children":571},{},[572],{"type":44,"value":573},"Demonstrates grouping, setup, synchronous, and asynchronous testing.",{"type":38,"tag":575,"props":576,"children":580},"pre",{"className":577,"code":578,"language":14,"meta":579,"style":579},"language-dart shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import 'package:test\u002Ftest.dart';\nimport 'package:my_package\u002Fcalculator.dart';\n\nvoid main() {\n  group('Calculator', () {\n    late Calculator calc;\n\n    setUp(() {\n      calc = Calculator();\n    });\n\n    test('adds two numbers correctly', () {\n      expect(calc.add(2, 3), equals(5));\n    });\n\n    test('handles asynchronous operations', () async {\n      final result = await calc.fetchRemoteValue();\n      expect(result, isNotNull);\n      expect(result, greaterThan(0));\n    });\n  });\n}\n","",[581],{"type":38,"tag":116,"props":582,"children":583},{"__ignoreMap":579},[584,595,604,613,622,631,640,648,657,666,675,683,692,701,709,717,726,735,744,753,761,770],{"type":38,"tag":585,"props":586,"children":589},"span",{"class":587,"line":588},"line",1,[590],{"type":38,"tag":585,"props":591,"children":592},{},[593],{"type":44,"value":594},"import 'package:test\u002Ftest.dart';\n",{"type":38,"tag":585,"props":596,"children":598},{"class":587,"line":597},2,[599],{"type":38,"tag":585,"props":600,"children":601},{},[602],{"type":44,"value":603},"import 'package:my_package\u002Fcalculator.dart';\n",{"type":38,"tag":585,"props":605,"children":607},{"class":587,"line":606},3,[608],{"type":38,"tag":585,"props":609,"children":610},{"emptyLinePlaceholder":443},[611],{"type":44,"value":612},"\n",{"type":38,"tag":585,"props":614,"children":616},{"class":587,"line":615},4,[617],{"type":38,"tag":585,"props":618,"children":619},{},[620],{"type":44,"value":621},"void main() {\n",{"type":38,"tag":585,"props":623,"children":625},{"class":587,"line":624},5,[626],{"type":38,"tag":585,"props":627,"children":628},{},[629],{"type":44,"value":630},"  group('Calculator', () {\n",{"type":38,"tag":585,"props":632,"children":634},{"class":587,"line":633},6,[635],{"type":38,"tag":585,"props":636,"children":637},{},[638],{"type":44,"value":639},"    late Calculator calc;\n",{"type":38,"tag":585,"props":641,"children":643},{"class":587,"line":642},7,[644],{"type":38,"tag":585,"props":645,"children":646},{"emptyLinePlaceholder":443},[647],{"type":44,"value":612},{"type":38,"tag":585,"props":649,"children":651},{"class":587,"line":650},8,[652],{"type":38,"tag":585,"props":653,"children":654},{},[655],{"type":44,"value":656},"    setUp(() {\n",{"type":38,"tag":585,"props":658,"children":660},{"class":587,"line":659},9,[661],{"type":38,"tag":585,"props":662,"children":663},{},[664],{"type":44,"value":665},"      calc = Calculator();\n",{"type":38,"tag":585,"props":667,"children":669},{"class":587,"line":668},10,[670],{"type":38,"tag":585,"props":671,"children":672},{},[673],{"type":44,"value":674},"    });\n",{"type":38,"tag":585,"props":676,"children":678},{"class":587,"line":677},11,[679],{"type":38,"tag":585,"props":680,"children":681},{"emptyLinePlaceholder":443},[682],{"type":44,"value":612},{"type":38,"tag":585,"props":684,"children":686},{"class":587,"line":685},12,[687],{"type":38,"tag":585,"props":688,"children":689},{},[690],{"type":44,"value":691},"    test('adds two numbers correctly', () {\n",{"type":38,"tag":585,"props":693,"children":695},{"class":587,"line":694},13,[696],{"type":38,"tag":585,"props":697,"children":698},{},[699],{"type":44,"value":700},"      expect(calc.add(2, 3), equals(5));\n",{"type":38,"tag":585,"props":702,"children":704},{"class":587,"line":703},14,[705],{"type":38,"tag":585,"props":706,"children":707},{},[708],{"type":44,"value":674},{"type":38,"tag":585,"props":710,"children":712},{"class":587,"line":711},15,[713],{"type":38,"tag":585,"props":714,"children":715},{"emptyLinePlaceholder":443},[716],{"type":44,"value":612},{"type":38,"tag":585,"props":718,"children":720},{"class":587,"line":719},16,[721],{"type":38,"tag":585,"props":722,"children":723},{},[724],{"type":44,"value":725},"    test('handles asynchronous operations', () async {\n",{"type":38,"tag":585,"props":727,"children":729},{"class":587,"line":728},17,[730],{"type":38,"tag":585,"props":731,"children":732},{},[733],{"type":44,"value":734},"      final result = await calc.fetchRemoteValue();\n",{"type":38,"tag":585,"props":736,"children":738},{"class":587,"line":737},18,[739],{"type":38,"tag":585,"props":740,"children":741},{},[742],{"type":44,"value":743},"      expect(result, isNotNull);\n",{"type":38,"tag":585,"props":745,"children":747},{"class":587,"line":746},19,[748],{"type":38,"tag":585,"props":749,"children":750},{},[751],{"type":44,"value":752},"      expect(result, greaterThan(0));\n",{"type":38,"tag":585,"props":754,"children":756},{"class":587,"line":755},20,[757],{"type":38,"tag":585,"props":758,"children":759},{},[760],{"type":44,"value":674},{"type":38,"tag":585,"props":762,"children":764},{"class":587,"line":763},21,[765],{"type":38,"tag":585,"props":766,"children":767},{},[768],{"type":44,"value":769},"  });\n",{"type":38,"tag":585,"props":771,"children":773},{"class":587,"line":772},22,[774],{"type":38,"tag":585,"props":775,"children":776},{},[777],{"type":44,"value":778},"}\n",{"type":38,"tag":424,"props":780,"children":782},{"id":781},"mocking-with-mockito",[783],{"type":44,"value":784},"Mocking with Mockito",{"type":38,"tag":110,"props":786,"children":787},{},[788],{"type":44,"value":789},"Demonstrates configuring a mock object for dependency injection testing.",{"type":38,"tag":575,"props":791,"children":793},{"className":577,"code":792,"language":14,"meta":579,"style":579},"import 'package:test\u002Ftest.dart';\nimport 'package:mockito\u002Fmockito.dart';\nimport 'package:mockito\u002Fannotations.dart';\nimport 'package:my_package\u002Fapi_client.dart';\nimport 'package:my_package\u002Fdata_service.dart';\n\n\u002F\u002F Generate the mock using build_runner: dart run build_runner build\n@GenerateNiceMocks([MockSpec\u003CApiClient>()])\nimport 'data_service_test.mocks.dart';\n\nvoid main() {\n  group('DataService', () {\n    late MockApiClient mockApiClient;\n    late DataService dataService;\n\n    setUp(() {\n      mockApiClient = MockApiClient();\n      dataService = DataService(apiClient: mockApiClient);\n    });\n\n    test('returns parsed data on successful API call', () async {\n      \u002F\u002F Configure the mock\n      when(mockApiClient.get('\u002Fdata')).thenAnswer((_) async => '{\"id\": 1}');\n\n      \u002F\u002F Execute the system under test\n      final result = await dataService.fetchData();\n\n      \u002F\u002F Verify outcomes and interactions\n      expect(result.id, equals(1));\n      verify(mockApiClient.get('\u002Fdata')).called(1);\n    });\n  });\n}\n",[794],{"type":38,"tag":116,"props":795,"children":796},{"__ignoreMap":579},[797,804,812,820,828,836,843,851,859,867,874,881,889,897,905,912,919,927,935,942,949,957,965,974,982,991,1000,1008,1017,1026,1035,1043,1051],{"type":38,"tag":585,"props":798,"children":799},{"class":587,"line":588},[800],{"type":38,"tag":585,"props":801,"children":802},{},[803],{"type":44,"value":594},{"type":38,"tag":585,"props":805,"children":806},{"class":587,"line":597},[807],{"type":38,"tag":585,"props":808,"children":809},{},[810],{"type":44,"value":811},"import 'package:mockito\u002Fmockito.dart';\n",{"type":38,"tag":585,"props":813,"children":814},{"class":587,"line":606},[815],{"type":38,"tag":585,"props":816,"children":817},{},[818],{"type":44,"value":819},"import 'package:mockito\u002Fannotations.dart';\n",{"type":38,"tag":585,"props":821,"children":822},{"class":587,"line":615},[823],{"type":38,"tag":585,"props":824,"children":825},{},[826],{"type":44,"value":827},"import 'package:my_package\u002Fapi_client.dart';\n",{"type":38,"tag":585,"props":829,"children":830},{"class":587,"line":624},[831],{"type":38,"tag":585,"props":832,"children":833},{},[834],{"type":44,"value":835},"import 'package:my_package\u002Fdata_service.dart';\n",{"type":38,"tag":585,"props":837,"children":838},{"class":587,"line":633},[839],{"type":38,"tag":585,"props":840,"children":841},{"emptyLinePlaceholder":443},[842],{"type":44,"value":612},{"type":38,"tag":585,"props":844,"children":845},{"class":587,"line":642},[846],{"type":38,"tag":585,"props":847,"children":848},{},[849],{"type":44,"value":850},"\u002F\u002F Generate the mock using build_runner: dart run build_runner build\n",{"type":38,"tag":585,"props":852,"children":853},{"class":587,"line":650},[854],{"type":38,"tag":585,"props":855,"children":856},{},[857],{"type":44,"value":858},"@GenerateNiceMocks([MockSpec\u003CApiClient>()])\n",{"type":38,"tag":585,"props":860,"children":861},{"class":587,"line":659},[862],{"type":38,"tag":585,"props":863,"children":864},{},[865],{"type":44,"value":866},"import 'data_service_test.mocks.dart';\n",{"type":38,"tag":585,"props":868,"children":869},{"class":587,"line":668},[870],{"type":38,"tag":585,"props":871,"children":872},{"emptyLinePlaceholder":443},[873],{"type":44,"value":612},{"type":38,"tag":585,"props":875,"children":876},{"class":587,"line":677},[877],{"type":38,"tag":585,"props":878,"children":879},{},[880],{"type":44,"value":621},{"type":38,"tag":585,"props":882,"children":883},{"class":587,"line":685},[884],{"type":38,"tag":585,"props":885,"children":886},{},[887],{"type":44,"value":888},"  group('DataService', () {\n",{"type":38,"tag":585,"props":890,"children":891},{"class":587,"line":694},[892],{"type":38,"tag":585,"props":893,"children":894},{},[895],{"type":44,"value":896},"    late MockApiClient mockApiClient;\n",{"type":38,"tag":585,"props":898,"children":899},{"class":587,"line":703},[900],{"type":38,"tag":585,"props":901,"children":902},{},[903],{"type":44,"value":904},"    late DataService dataService;\n",{"type":38,"tag":585,"props":906,"children":907},{"class":587,"line":711},[908],{"type":38,"tag":585,"props":909,"children":910},{"emptyLinePlaceholder":443},[911],{"type":44,"value":612},{"type":38,"tag":585,"props":913,"children":914},{"class":587,"line":719},[915],{"type":38,"tag":585,"props":916,"children":917},{},[918],{"type":44,"value":656},{"type":38,"tag":585,"props":920,"children":921},{"class":587,"line":728},[922],{"type":38,"tag":585,"props":923,"children":924},{},[925],{"type":44,"value":926},"      mockApiClient = MockApiClient();\n",{"type":38,"tag":585,"props":928,"children":929},{"class":587,"line":737},[930],{"type":38,"tag":585,"props":931,"children":932},{},[933],{"type":44,"value":934},"      dataService = DataService(apiClient: mockApiClient);\n",{"type":38,"tag":585,"props":936,"children":937},{"class":587,"line":746},[938],{"type":38,"tag":585,"props":939,"children":940},{},[941],{"type":44,"value":674},{"type":38,"tag":585,"props":943,"children":944},{"class":587,"line":755},[945],{"type":38,"tag":585,"props":946,"children":947},{"emptyLinePlaceholder":443},[948],{"type":44,"value":612},{"type":38,"tag":585,"props":950,"children":951},{"class":587,"line":763},[952],{"type":38,"tag":585,"props":953,"children":954},{},[955],{"type":44,"value":956},"    test('returns parsed data on successful API call', () async {\n",{"type":38,"tag":585,"props":958,"children":959},{"class":587,"line":772},[960],{"type":38,"tag":585,"props":961,"children":962},{},[963],{"type":44,"value":964},"      \u002F\u002F Configure the mock\n",{"type":38,"tag":585,"props":966,"children":968},{"class":587,"line":967},23,[969],{"type":38,"tag":585,"props":970,"children":971},{},[972],{"type":44,"value":973},"      when(mockApiClient.get('\u002Fdata')).thenAnswer((_) async => '{\"id\": 1}');\n",{"type":38,"tag":585,"props":975,"children":977},{"class":587,"line":976},24,[978],{"type":38,"tag":585,"props":979,"children":980},{"emptyLinePlaceholder":443},[981],{"type":44,"value":612},{"type":38,"tag":585,"props":983,"children":985},{"class":587,"line":984},25,[986],{"type":38,"tag":585,"props":987,"children":988},{},[989],{"type":44,"value":990},"      \u002F\u002F Execute the system under test\n",{"type":38,"tag":585,"props":992,"children":994},{"class":587,"line":993},26,[995],{"type":38,"tag":585,"props":996,"children":997},{},[998],{"type":44,"value":999},"      final result = await dataService.fetchData();\n",{"type":38,"tag":585,"props":1001,"children":1003},{"class":587,"line":1002},27,[1004],{"type":38,"tag":585,"props":1005,"children":1006},{"emptyLinePlaceholder":443},[1007],{"type":44,"value":612},{"type":38,"tag":585,"props":1009,"children":1011},{"class":587,"line":1010},28,[1012],{"type":38,"tag":585,"props":1013,"children":1014},{},[1015],{"type":44,"value":1016},"      \u002F\u002F Verify outcomes and interactions\n",{"type":38,"tag":585,"props":1018,"children":1020},{"class":587,"line":1019},29,[1021],{"type":38,"tag":585,"props":1022,"children":1023},{},[1024],{"type":44,"value":1025},"      expect(result.id, equals(1));\n",{"type":38,"tag":585,"props":1027,"children":1029},{"class":587,"line":1028},30,[1030],{"type":38,"tag":585,"props":1031,"children":1032},{},[1033],{"type":44,"value":1034},"      verify(mockApiClient.get('\u002Fdata')).called(1);\n",{"type":38,"tag":585,"props":1036,"children":1038},{"class":587,"line":1037},31,[1039],{"type":38,"tag":585,"props":1040,"children":1041},{},[1042],{"type":44,"value":674},{"type":38,"tag":585,"props":1044,"children":1046},{"class":587,"line":1045},32,[1047],{"type":38,"tag":585,"props":1048,"children":1049},{},[1050],{"type":44,"value":769},{"type":38,"tag":585,"props":1052,"children":1054},{"class":587,"line":1053},33,[1055],{"type":38,"tag":585,"props":1056,"children":1057},{},[1058],{"type":44,"value":778},{"type":38,"tag":1060,"props":1061,"children":1062},"style",{},[1063],{"type":44,"value":1064},"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":1066,"total":976},[1067,1072,1083,1095,1106,1115,1127],{"slug":4,"name":4,"fn":5,"description":6,"org":1068,"tags":1069,"stars":19,"repoUrl":20,"updatedAt":21},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1070,1071],{"name":13,"slug":14,"type":15},{"name":17,"slug":18,"type":15},{"slug":1073,"name":1073,"fn":1074,"description":1075,"org":1076,"tags":1077,"stars":19,"repoUrl":20,"updatedAt":1082},"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},[1078,1081],{"name":1079,"slug":1080,"type":15},"CLI","cli",{"name":13,"slug":14,"type":15},"2026-07-15T05:22:18.863572",{"slug":1084,"name":1084,"fn":1085,"description":1086,"org":1087,"tags":1088,"stars":19,"repoUrl":20,"updatedAt":1094},"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},[1089,1090,1093],{"name":13,"slug":14,"type":15},{"name":1091,"slug":1092,"type":15},"Reporting","reporting",{"name":17,"slug":18,"type":15},"2026-07-15T05:22:21.38636",{"slug":1096,"name":1096,"fn":1097,"description":1098,"org":1099,"tags":1100,"stars":19,"repoUrl":20,"updatedAt":1105},"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},[1101,1102],{"name":13,"slug":14,"type":15},{"name":1103,"slug":1104,"type":15},"Debugging","debugging","2026-07-15T05:22:22.622501",{"slug":1107,"name":1107,"fn":1108,"description":1109,"org":1110,"tags":1111,"stars":19,"repoUrl":20,"updatedAt":1114},"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},[1112,1113],{"name":13,"slug":14,"type":15},{"name":17,"slug":18,"type":15},"2026-07-15T05:22:42.607449",{"slug":1116,"name":1116,"fn":1117,"description":1118,"org":1119,"tags":1120,"stars":19,"repoUrl":20,"updatedAt":1126},"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},[1121,1122,1125],{"name":13,"slug":14,"type":15},{"name":1123,"slug":1124,"type":15},"Migration","migration",{"name":17,"slug":18,"type":15},"2026-07-15T05:22:31.276564",{"slug":1128,"name":1128,"fn":1129,"description":1130,"org":1131,"tags":1132,"stars":19,"repoUrl":20,"updatedAt":1138},"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},[1133,1134,1135],{"name":13,"slug":14,"type":15},{"name":1103,"slug":1104,"type":15},{"name":1136,"slug":1137,"type":15},"Engineering","engineering","2026-07-15T05:22:30.059335",{"items":1140,"total":1002},[1141,1146,1151,1157,1162,1167,1173,1179,1191,1203,1217,1227],{"slug":4,"name":4,"fn":5,"description":6,"org":1142,"tags":1143,"stars":19,"repoUrl":20,"updatedAt":21},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1144,1145],{"name":13,"slug":14,"type":15},{"name":17,"slug":18,"type":15},{"slug":1073,"name":1073,"fn":1074,"description":1075,"org":1147,"tags":1148,"stars":19,"repoUrl":20,"updatedAt":1082},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1149,1150],{"name":1079,"slug":1080,"type":15},{"name":13,"slug":14,"type":15},{"slug":1084,"name":1084,"fn":1085,"description":1086,"org":1152,"tags":1153,"stars":19,"repoUrl":20,"updatedAt":1094},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1154,1155,1156],{"name":13,"slug":14,"type":15},{"name":1091,"slug":1092,"type":15},{"name":17,"slug":18,"type":15},{"slug":1096,"name":1096,"fn":1097,"description":1098,"org":1158,"tags":1159,"stars":19,"repoUrl":20,"updatedAt":1105},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1160,1161],{"name":13,"slug":14,"type":15},{"name":1103,"slug":1104,"type":15},{"slug":1107,"name":1107,"fn":1108,"description":1109,"org":1163,"tags":1164,"stars":19,"repoUrl":20,"updatedAt":1114},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1165,1166],{"name":13,"slug":14,"type":15},{"name":17,"slug":18,"type":15},{"slug":1116,"name":1116,"fn":1117,"description":1118,"org":1168,"tags":1169,"stars":19,"repoUrl":20,"updatedAt":1126},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1170,1171,1172],{"name":13,"slug":14,"type":15},{"name":1123,"slug":1124,"type":15},{"name":17,"slug":18,"type":15},{"slug":1128,"name":1128,"fn":1129,"description":1130,"org":1174,"tags":1175,"stars":19,"repoUrl":20,"updatedAt":1138},{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[1176,1177,1178],{"name":13,"slug":14,"type":15},{"name":1103,"slug":1104,"type":15},{"name":1136,"slug":1137,"type":15},{"slug":1180,"name":1180,"fn":1181,"description":1182,"org":1183,"tags":1184,"stars":19,"repoUrl":20,"updatedAt":1190},"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},[1185,1188,1189],{"name":1186,"slug":1187,"type":15},"Code Analysis","code-analysis",{"name":13,"slug":14,"type":15},{"name":1103,"slug":1104,"type":15},"2026-07-15T05:22:23.861119",{"slug":1192,"name":1192,"fn":1193,"description":1194,"org":1195,"tags":1196,"stars":19,"repoUrl":20,"updatedAt":1202},"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},[1197,1198,1201],{"name":13,"slug":14,"type":15},{"name":1199,"slug":1200,"type":15},"Deployment","deployment",{"name":1136,"slug":1137,"type":15},"2026-07-15T05:22:20.138636",{"slug":1204,"name":1204,"fn":1205,"description":1206,"org":1207,"tags":1208,"stars":19,"repoUrl":20,"updatedAt":1216},"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},[1209,1210,1213],{"name":13,"slug":14,"type":15},{"name":1211,"slug":1212,"type":15},"Plugin Development","plugin-development",{"name":1214,"slug":1215,"type":15},"QA","qa","2026-07-15T05:22:47.488998",{"slug":1218,"name":1218,"fn":1219,"description":1220,"org":1221,"tags":1222,"stars":19,"repoUrl":20,"updatedAt":1226},"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},[1223,1224,1225],{"name":13,"slug":14,"type":15},{"name":1211,"slug":1212,"type":15},{"name":1214,"slug":1215,"type":15},"2026-07-21T05:38:34.451024",{"slug":1228,"name":1228,"fn":1229,"description":1230,"org":1231,"tags":1232,"stars":19,"repoUrl":20,"updatedAt":1235},"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},[1233,1234],{"name":13,"slug":14,"type":15},{"name":1136,"slug":1137,"type":15},"2026-07-15T05:22:17.592351"]