-
Create a demo web app:
dart create -t web-simple my-app
Having troubles? learn more from official guide
-
Add Rad as dependency:
- Open
pubspec.yaml
in newly created app folder and addrad
to your dependencies:dependencies: rad: '>=1.8.0 <2.0.0'
- Open
-
Run
dart pub get
. -
Import Rad widgets in your
main.dart
:import 'package:rad/rad.dart';
-
Create App:
void main() { runApp( // 'output' is the id of div in your web/index.html // framework will mount your app inside that div // if you don't have a div with id 'output' in web/index.html, appTargetId: "output", // you've to create it // e.g // <body> // <div id="output"></div> // ... app: Text("hello world"), ); }
-
Run
webdev serve
and follow on-screen instructions.
For debugging a Dart web app, you've to setup a debugger for your IDE/editor. See Dart guide for debugging web apps and tools that you can use. (remember you don't need Flutter SDK/or its plugins for using Rad).
If you happen to be using VS code,
- Install VS code Dart plugin
- Create a
launch.json
inside.vscode
folder - see example - Start your app in debug mode - see this for more
For getting a release build run webdev build --release
. It'll generate a ready-to-deploy build of your app inside build
folder. To customize your build, read this official deployment guide. Note that optimization level can be controlled. Refer to dart2js docs for options available. Alternatively, you can also follow webdev documentation.