{"id":23463598,"url":"https://github.com/harmnot/flutter-cheatsheet","last_synced_at":"2026-02-02T15:08:31.348Z","repository":{"id":126665597,"uuid":"256783186","full_name":"harmnot/flutter-cheatsheet","owner":"harmnot","description":"flutter cheatsheet for dummy gang","archived":false,"fork":false,"pushed_at":"2020-04-18T15:12:27.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-12T08:47:08.297Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harmnot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-18T15:09:33.000Z","updated_at":"2020-04-18T15:12:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"f4d3eebc-27e2-47bd-8ec4-892cf7209138","html_url":"https://github.com/harmnot/flutter-cheatsheet","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/harmnot/flutter-cheatsheet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmnot%2Fflutter-cheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmnot%2Fflutter-cheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmnot%2Fflutter-cheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmnot%2Fflutter-cheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harmnot","download_url":"https://codeload.github.com/harmnot/flutter-cheatsheet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harmnot%2Fflutter-cheatsheet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29013926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T14:58:54.169Z","status":"ssl_error","status_checked_at":"2026-02-02T14:58:51.285Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-24T09:13:01.902Z","updated_at":"2026-02-02T15:08:31.302Z","avatar_url":"https://github.com/harmnot.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# FLUTTER DOC\n\n##### create fluuter\n\n```bash\n flutter create --org com.name-of-project-or-what-ever name-of-project\n```\n\n#### How to Loop in  Flutter \n\n```dart\nListView.builder() {\n\titemBuilder: (ctx, index) {\n\t\t// return Card? Column?\n\t\treturn Card(\n\t\t\tchild: // .... do something here\n\t\t)\n\t},\n  itemCount: // length of data want to loop E.g array.length\n}\n```\n\n#### make DateTime type to String [int package](https://pub.dev/packages/intl)\n\n```dart\nimport 'package:intl/intl.dart';\n\nDateFormat.yMMMD().format(\"DATE_HERE\") \n//May 19, 2020 \n```\n\n#### create Form\n\n```dart\nfinal stateForTitle = TextEditingController()\n  \nfinal stateForBody = TextEditingController()\n  \n// usage \nTextFormFiled(\n\tcontroller: stateForTitle,\n  decoration: InputDecoration(\n                labelText: \"Title\"\n             ),\n)\n```\n\n#### how to make validate in form \n\n```dart\nfinal _formKey = GlobalKey\u003cFormState\u003e();\n\n// usage\nForm(\n  key: _formKey\n)\n\nTextFormFiled(\n  keyboardType: TextInputType.numberWithOptions(decimal: true), // for strict data type\n  validator: (value) {\n    return value.isEmpty ? \"Required field\" : null;\n  }\n)\n  \n// before we click; that _formKey work like this on button\nFlatButton(\n\tonPressed: () {\n    if(_formKey.currentState.validate()) {\n      // do something if the field not empty or whatever you want to validate in validator\n    }\n    // if condition wrong, the \"Required field\" will be showing on below input form\n  }\n)\n```\n\n####  Space around Column widget\n\n```dart\n SizedBox(height: 10),\n\n// if you want responsive use LayoutBuilder \nLayoutBuilder(builder: (ctx, constrains){\n  Column: Widget\u003c\u003e [\n    Text(\"Some Text Here\"),\n    SizedBox(height: constrains.maxHeight * 0.05)\n  ]\n})\n```\n\n#### Model with required field\n\n```dart\nimport 'package:flutter/foundation.dart';\n\nclass Transaction {\n  final String id;\n  final String title;\n  final double amount;\n  final DateTime date;\n\n  Transaction({\n    @required this.id,\n    @required this.title,\n    @required this.amount,\n    @required this.date\n  });\n}\n```\n\n#### Data type\n\n```dart\nList\u003cMap\u003cString, Object\u003e\u003e // [ {name: \"heheh\"}]\nList\u003cCar\u003e // [ { name: \"toyota\"}]\nString\ndouble\nDateTime  \n```\n\n#### Make Circle with Container widget\n\n```dart\nContainer(\n\tdecoration: BoxDecoration(\n            \tcolor: Colors.amber,\n              shape: BoxShape.circle\n          \t),\n  width: \"NUMBER\",\n  height: \"NUMBER\",\n)\n```\n\n\n\n### Modal / Pop up\n\n#### Show Date Picker \n\n```dart\n// promise\nvoid _presentDatePickerModal() {\n  showDatePicker(\n      context: context,\n      initialDate: DateTime.now(),\n      firstDate: DateTime(2019),\n      lastDate: DateTime.now(),\n  ).then((pickedDateByUser) {\n    // do something here\n  })\n}\n```\n\n\n\n#### Show Modal\n\n```dart\nshowModalBottomSheet(\n  context: ctx,\n  builder: (_) =\u003e GestureDetector(\n    onTap: () {},\n    child: // your widget form or what ever here,\n    behavior: HitTestBehavior.opaque,\n  )\n);\n\n// close the modal when u click the submit NOTE: call this on your methods\nNavigator.of(context).pop();\n```\n\n#### Modal size Error\n\n```dart\n// if your modal covered by keyboard, wrap your modal / form with this widget below\nSingleChildScrollView()\n```\n\n\n\n### Responsive\n\n\n\n#### MediaQuery for responsive \n\n```dart\nContainer(\n  height: (MediaQuery.of(context).size.height - appBar.preferredsize.height() -MediaQuery.of(context).padding.top) * \"NUMBER_YOU_WANT\",\n)\n  \n// text scale\nfinal curScaleFactor = MediaQuery.of(context).textScaleFactor; \n\nText('This changes!', style: TextStyle(fontSize: 20 * curScaleFactor));\n\n// this builder is to gets parent size\nLayoutBuilder(builder: (ctx, constrains){\n  Container(\n    height: constrains.maxHeight * 0.7, // 7%\n    width: 10,\n    child: // child widgets here\n  )\n})\n```\n\n#### Get Orientation Landscape or Potrait\n\n```dart\nfinal isLandscape = MediaQuery.of(context).orientation == Orientation.landscape;\n```\n\n\n\n### Navigation / Routing \n\n#### Routing push to another widget\n\n```dart\nNavigator.of(context).push(\n   MaterialPageRoute(\n      builder: (_) =\u003e nameWidgetForThisRoute(propHere: \"text_here\")\n   )\n);\n\nNavigator.pushNamed(context, ‘/routingName’);\n\nNavigator.pushReplaceNames(context, “/nameRoute”, arguments : payload);\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmnot%2Fflutter-cheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharmnot%2Fflutter-cheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharmnot%2Fflutter-cheatsheet/lists"}