{"id":47317309,"url":"https://github.com/mahmoudelsayed7/flutter-extensions","last_synced_at":"2026-05-16T10:31:25.272Z","repository":{"id":266792313,"uuid":"851789647","full_name":"MAHMOUDELSAYED7/Flutter-extensions","owner":"MAHMOUDELSAYED7","description":"Flutter Extensions offer useful tools for enhancing code readability and functionality, covering themes, screens, navigation, and widget styling.","archived":false,"fork":false,"pushed_at":"2025-04-02T04:14:18.000Z","size":20,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-18T04:22:16.143Z","etag":null,"topics":["buildcontext","cliprrect","cubit","dart","dart-extension","datetime","extention","extentions","flutter","flutter-extension","flutter-extensions","flutter-ui","flutter-widget","gestures","margin","mediaquery","navigation","padding"],"latest_commit_sha":null,"homepage":"https://dart.dev/language/extension-methods","language":"Dart","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/MAHMOUDELSAYED7.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":"2024-09-03T17:50:46.000Z","updated_at":"2025-10-15T03:05:29.000Z","dependencies_parsed_at":"2024-12-06T06:30:28.841Z","dependency_job_id":"555041cb-6755-4ab3-89ec-7467a9294ac1","html_url":"https://github.com/MAHMOUDELSAYED7/Flutter-extensions","commit_stats":null,"previous_names":["mahmoudelsayed7/context-extensions","mahmoudelsayed7/flutter-extensions"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MAHMOUDELSAYED7/Flutter-extensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAHMOUDELSAYED7%2FFlutter-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAHMOUDELSAYED7%2FFlutter-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAHMOUDELSAYED7%2FFlutter-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAHMOUDELSAYED7%2FFlutter-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MAHMOUDELSAYED7","download_url":"https://codeload.github.com/MAHMOUDELSAYED7/Flutter-extensions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MAHMOUDELSAYED7%2FFlutter-extensions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33098787,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["buildcontext","cliprrect","cubit","dart","dart-extension","datetime","extention","extentions","flutter","flutter-extension","flutter-extensions","flutter-ui","flutter-widget","gestures","margin","mediaquery","navigation","padding"],"created_at":"2026-03-17T16:09:23.555Z","updated_at":"2026-05-16T10:31:25.238Z","avatar_url":"https://github.com/MAHMOUDELSAYED7.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv style=\"display: flex; justify-content: space-between;\"\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/4a97bae8-af8d-44d3-bb92-b5226dab348c\" alt=\"Screenshot 1\" style=\"width: 100%;\"/\u003e\n\u003c/div\u003e\n\n# Flutter Widget Extensions\n\nA lightweight library offering extensions for Flutter widgets and `BuildContext` to simplify tasks like alignment, padding, navigation, and more. These extensions reduce boilerplate, enhance readability, and streamline your widget code.\n\n## Table of Contents\n\n- [Getting Started](#getting-started)\n- [Before and After Examples](#before-and-after-examples)\n  - [1. Alignment Example](#1-alignment-example)\n  - [2. Padding Example](#2-padding-example)\n  - [3. Navigation Example](#3-navigation-example)\n  - [4. Gesture Example](#4-gesture-example)\n  - [5. SizedBox Example](#5-sizedbox-example)\n  - [6. Cubit Example](#6-cubit-example)\n  - [7. Media Query Example](#7-media-query-example)\n- [Available Extensions](#available-extensions)\n\n## Getting Started\n\nTo use these extensions in your Flutter project:\n\n1. **Clone the Repository**:\n   ```bash\n   git clone https://github.com/MAHMOUDELSAYED7/Flutter-extensions.git\n   ```\n2. **Navigate to the Directory**:\n   ```bash\n   cd Flutter-extensions\n   ```\n3. **Install Dependencies**:\n   ```bash\n   flutter pub get\n   ```\n\nExplore the extensions in the `lib/extensions/` folder and integrate them into your project.\n\n## Before and After Examples\n\nThese examples showcase how the extensions simplify Flutter code. Each includes a **Before** (traditional) and **After** (extension-based) version with a brief explanation.\n\n### 1. Alignment Example\n#### Before\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    body: Align(\n      alignment: Alignment.bottomRight,\n      child: Text('Bottom Right'),\n    ),\n  );\n}\n```\n\n#### After\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    body: Text('Bottom Right').alignBottomRight(),\n  );\n}\n```\n\n**Explanation**: `alignBottomRight()` removes the need for an `Align` widget, reducing nesting.\n\n---\n\n### 2. Padding Example\n#### Before\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    body: Padding(\n      padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 20.0),\n      child: Text('Symmetric Padding'),\n    ),\n  );\n}\n```\n\n#### After\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    body: Text('Symmetric Padding').withSymmetricPadding(vertical: 10.0, horizontal: 20.0),\n  );\n}\n```\n\n**Explanation**: `withSymmetricPadding()` replaces `Padding`, improving readability with named parameters.\n\n---\n\n### 3. Navigation Example\n#### Before\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    body: ElevatedButton(\n      onPressed: () {\n        Navigator.of(context).push(\n          MaterialPageRoute(builder: (_) =\u003e NextPage()),\n        );\n      },\n      child: Text('Next Page'),\n    ),\n  );\n}\n```\n\n#### After\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    body: ElevatedButton(\n      onPressed: () =\u003e context.push(NextPage()),\n      child: Text('Next Page'),\n    ),\n  );\n}\n```\n\n**Explanation**: `push()` simplifies navigation by abstracting `Navigator` boilerplate.\n\n---\n\n### 4. Gesture Example\n#### Before\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    body: GestureDetector(\n      onTap: () {\n        print('Tapped the icon');\n      },\n      child: Icon(Icons.star),\n    ),\n  );\n}\n```\n\n#### After\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    body: Icon(Icons.star).onTap(() =\u003e print('Tapped the icon')),\n  );\n}\n```\n\n**Explanation**: `onTap()` replaces `GestureDetector`, making tap handling more concise.\n\n---\n\n### 5. SizedBox Example\n#### Before\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    body: SizedBox(\n      width: 80.0,\n      height: 80.0,\n      child: Container(color: Colors.blue),\n    ),\n  );\n}\n```\n\n#### After\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    body: Container(color: Colors.blue).withSquareSize(80.0),\n  );\n}\n```\n\n**Explanation**: `withSquareSize()` eliminates `SizedBox`, setting a square size directly.\n\n---\n\n### 6. Cubit Example\n#### Before\n```dart\nimport 'package:flutter/material.dart';\nimport 'package:flutter_bloc/flutter_bloc.dart';\n\nclass CounterCubit extends Cubit\u003cint\u003e {\n  CounterCubit() : super(0);\n  void increment() =\u003e emit(state + 1);\n}\n\n// Usage\nBlocProvider.of\u003cCounterCubit\u003e(context).increment();\n\n```\n\n#### After\n```dart\nimport 'package:flutter/material.dart';\nimport 'package:flutter_bloc/flutter_bloc.dart';\n\nclass CounterCubit extends Cubit\u003cint\u003e {\n  CounterCubit() : super(0);\n  void increment() =\u003e emit(state + 1);\n}\n\n// Simplified usage\ncontext.cubit\u003cCounterCubit\u003e().increment();\n         \n```\n\n**Explanation**: `cubit\u003cT\u003e()` simplifies Cubit access, replacing verbose `BlocProvider.of\u003cT\u003e`.\n\n---\n\n### 7. Media Query Example\n#### Before\n```dart\nWidget build(BuildContext context) {\n  double screenWidth = MediaQuery.of(context).size.width;\n  return Scaffold(\n    body: Container(\n      width: screenWidth * 0.5,\n      height: 100,\n      color: Colors.green,\n      child: Text('Half Width Container'),\n    ),\n  );\n}\n```\n\n#### After\n```dart\nWidget build(BuildContext context) {\n  return Scaffold(\n    body: Container(\n      width: context.width * 0.5,\n      height: 100,\n      color: Colors.green,\n      child: Text('Half Width Container'),\n    ),\n  );\n}\n```\n\n**Explanation**: `context.width` provides direct screen width access, skipping `MediaQuery`.\n\n---\n\n## Available Extensions\n\nHere’s a concise overview of the extensions provided:\n\n- **Alignment**: `center()`, `alignBottomRight()`, etc., for easy widget alignment.\n- **Padding**: `withPadding()`, `withSymmetricPadding()`, etc., for flexible padding.\n- **Navigation**: `push()`, `back()`, etc., for simplified routing.\n- **Gesture**: `onTap()`, `onLongPress()`, etc., for gesture handling.\n- **SizedBox**: `withWidth()`, `withSquareSize()`, etc., for sizing widgets.\n- **Cubit/Bloc**: `cubit\u003cT\u003e()`, `bloc\u003cT\u003e()` for state management access.\n- **Media Query**: `width`, `height`, `isLandscape`, etc., for screen data.\n- **ClipRRect**: `circular()`, `topRounded()`, etc., for border radius.\n- **Positioned**: `positionedTopLeft()`, etc., for `Stack` positioning.\n- **Transform**: `rotate()`, `scale()`, etc., for widget transformations.\n- **Visibility**: `visible()`, `invisible()`, etc., for show/hide control.\n- **Theme**: `theme`, `textTheme`, etc., for theme access.\n- **Post Frame Callback**: `addPostFrameCallback()`, etc., for post-build actions.\n\nFor detailed usage and additional methods, refer to the source files in `lib/extensions/`.\n\n---\n\n## Contact\n\nFor any questions or feedback, please reach out via email: [mahmoudelsayed.dev@gmail.com](mahmoudelsayed.dev@gmail.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahmoudelsayed7%2Fflutter-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmahmoudelsayed7%2Fflutter-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahmoudelsayed7%2Fflutter-extensions/lists"}