### Redeploy DartPad UI to Firebase Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dartpad_ui/README.md After initial setup, use these commands to rebuild the web app with WASM and deploy it to Firebase Hosting. ```bash cd pkgs/dartpad_ui flutter build web --wasm firebase deploy ``` -------------------------------- ### Dart File Header Source: https://github.com/dart-lang/dart-pad/blob/main/CONTRIBUTING.md All files in the project must start with this copyright and license header. ```dart // Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. ``` -------------------------------- ### Configure Redis Cache Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dart_services/README.md Run the Dart Services server with the redis-url flag to configure it to use a local Redis cache. Installation instructions for Redis are provided for Ubuntu and macOS. ```bash dart bin/server.dart --redis-url= ``` -------------------------------- ### Run Dart Services Server Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dart_services/README.md Start the Dart Services backend server. The server runs from port 8080 and exports several JSON APIs. ```bash dart bin/server.dart ``` -------------------------------- ### Embed DartPad using iframe Source: https://github.com/dart-lang/dart-pad/wiki/Embedding-guide Use this HTML snippet to embed a DartPad example in your webpage. Customize the 'src' URL to point to your desired DartPad gist. ```html ``` -------------------------------- ### Build Web App and Initialize Firebase Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dartpad_ui/README.md Navigate to the `pkgs/dartpad_ui` directory, build the web application with WASM support, and initialize Firebase for deployment. ```bash cd pkgs/dartpad_ui flutter build web --wasm firebase -P init ``` -------------------------------- ### Run DartPad UI with Local Backend Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dartpad_ui/README.md Launch the DartPad UI on a specific port and direct it to connect to a local backend by passing the `channel=localhost` parameter. ```bash flutter run -d chrome --web-port 8888 --web-browser-flag "--disable-web-security" --web-launch-url "http://localhost:8888/?channel=localhost" ``` -------------------------------- ### Build Project Templates and Storage Artifacts Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dartpad_ui/README.md Execute these commands in the `pkgs/dart_services` directory to build necessary project templates and storage artifacts for the backend. ```bash dart tool/grind.dart build-project-templates ``` ```bash dart tool/grind.dart build-storage-artifacts ``` -------------------------------- ### Generate Dependency Diagrams with Layerlens Source: https://github.com/dart-lang/dart-pad/blob/main/CONTRIBUTING.md Use this command to activate and run layerlens for generating dependency diagrams. Navigate to the package directory first. ```bash cd pkgs/ dart pub global activate layerlens layerlens ``` -------------------------------- ### Build Project Templates Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dart_services/README.md Create Dart and Flutter projects in the project_templates/ directory. This command may fail if packages cannot be resolved, requiring edits to pub_dependencies yaml files. ```bash dart tool/grind.dart build-project-templates ``` -------------------------------- ### Enable Code Generation with API Key Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dart_services/README.md To test code generation features locally, set the GEMINI_API_KEY environment variable before running the server. ```bash export GEMINI_API_KEY= dart bin/server.dart ``` -------------------------------- ### Run DartPad Probes Locally Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dart_services/test/probes/README.md Execute the DartPad probe tests from the command line. Ensure you are in the correct directory before running the command. ```bash cd pkgs/dart_services/ dart test test/probes ``` -------------------------------- ### Run DartPad UI Locally Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dartpad_ui/README.md Use this command to run the DartPad UI locally with Chrome, disabling web security to handle CORS issues with asset manifest files. ```bash flutter run -d chrome --web-browser-flag "--disable-web-security" ``` -------------------------------- ### Load Dart Entrypoint with Service Worker Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/samples/web/index.html This snippet demonstrates how to load the main Dart entrypoint using the Flutter loader. It includes configuration for the service worker and an onEntrypointLoaded callback to initialize and run the Dart application. ```javascript const serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function(engineInitializer) { engineInitializer.initializeEngine().then(function(appRunner) { appRunner.runApp(); }); } }); }); ``` -------------------------------- ### Configure Firebase Hosting for DartPad Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dartpad_ui/README.md Adjust the `firebase.json` file by removing unnecessary hosting targets and changing rewrite rules from 'same-origin' to 'cross-origin'. ```json { "hosting": { "target": "dartpad" } } ``` -------------------------------- ### Build Storage Artifacts Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dart_services/README.md Re-generate pre-compiled .dill files for the Dart SDK and Flutter Web SDK. These files are typically uploaded to Cloud Storage. ```bash dart tool/grind.dart build-storage-artifacts ``` -------------------------------- ### Run Dart Services Tests Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dart_services/README.md Execute the test suite for the Dart Services backend. ```bash dart test ``` -------------------------------- ### Update Pub Dependencies Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dart_services/README.md Overwrite the pub_dependencies_.yaml file for the current channel to ensure all packages are pinned to the correct version. ```bash dart tool/grind.dart update-pub-dependencies ``` -------------------------------- ### Regenerate Model Code with Build Runner Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dartpad_shared/README.md Use this command to regenerate model code when necessary. Ensure conflicting outputs are deleted to avoid issues. ```bash dart run build_runner build --delete-conflicting-outputs ``` -------------------------------- ### Update .firebaserc for Default Project Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dartpad_ui/README.md Update the `.firebaserc` file to set your Firebase project as the default. ```json { "projects": { "default": "" }, "targets": { "": { "hosting": { "dartpad": [ "" ] } } }, } ``` -------------------------------- ### Update Firebase Project Configuration Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dartpad_ui/README.md Temporarily modify the `.firebaserc` file to target your specific Firebase project for hosting. ```json { "targets": { "": { "hosting": { "dartpad": [ "" ] } } } } ``` -------------------------------- ### Switch Flutter Channel Source: https://github.com/dart-lang/dart-pad/blob/main/pkgs/dart_services/README.md Change the active Flutter channel. This is a prerequisite for modifying supported packages. ```bash flutter channel ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.