dart_pad_widget 1.0.1+2

  • Readme
  • Changelog
  • Example
  • Installing
  • 54

DartPad Flutter Web Plugin #

A new Flutter package that allows you to easily embed DartPad into your Flutter Web application.

import 'package:flutter/material.dart';
import 'package:dart_pad_widget/dart_pad_widget.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        body: SingleChildScrollView(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                DartPad(
                  key: Key('example1'),
                  width: 500,
                  height: 400,
                  code: 'void main() => print("Hello DartPad Widget");',
                ),
              ],
            ),
          ),
        ),
      ),
    );

Live Demo

Some code was borrowed from the dart-lang/dart-pad repository. Credit for that goes to them.

It should support most of the features listed in the dartpad embedding guide

Contributions welcome

Example

[1.0.0] - Apr 21 2020 #

  • Initial Release, works on FLutter Web

[1.0.1] - Apr 21 2020 #

  • Added license

[1.0.1+1] - Apr 21 2020 #

  • Added demo link in README

[1.0.1+2] - Apr 21 2020 #

  • Fixed code formatting in README

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:dart_pad_widget/dart_pad_widget.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        body: SingleChildScrollView(
          child: Center(
              child: Container(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                DartPad(
                  key: Key('example1'),
                  width: 500,
                  height: 400,
                  code: 'void main() => print("Hello DartPad Widget");',
                ),
                DartPad(
                  key: Key('example2'),
                  width: 1000,
                  height: 400,
                  flutter: true,
                  darkMode: true,
                  code: """import 'package:flutter/material.dart';

Future main() async {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  MyApp();

  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State {
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(),
        body: Center(
          child: Container(
            child: Text('Hello, World!'),
          ),
        ),
      ),
    );
  }
}""",
                ),
                DartPad(
                  key: Key('example3'),
                  width: 800,
                  height: 400,
                  split: true,
                  darkMode: false,
                  flutter: true,
                  code: """import 'package:flutter/material.dart';

Future main() async {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  MyApp();

  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State {
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: new ThemeData(
        brightness: Brightness.dark,
      ),
      home: Scaffold(
        appBar: AppBar(),
        body: Center(
          child: Container(
            child: Text('Hello, World!'),
          ),
        ),
      ),
    );
  }
}""",
                ),
              ],
            ),
          )),
        ),
      ),
    ),
  );
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_pad_widget: ^1.0.1+2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_pad_widget/dart_pad_widget.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
16
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
54
Learn more about scoring.

We analyzed this package on Jul 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • dart_pad_widget that is a package requiring null.

Package not compatible with runtime flutter-native on android

Because:

  • package:dart_pad_widget/dart_pad_widget.dart that imports:
  • dart:html

Package not compatible with runtime flutter-native on ios

Because:

  • package:dart_pad_widget/dart_pad_widget.dart that imports:
  • dart:html

Package not compatible with runtime flutter-native on linux

Because:

  • package:dart_pad_widget/dart_pad_widget.dart that imports:
  • dart:html

Package not compatible with runtime flutter-native on macos

Because:

  • package:dart_pad_widget/dart_pad_widget.dart that imports:
  • dart:html

Package not compatible with runtime flutter-native on windows

Because:

  • package:dart_pad_widget/dart_pad_widget.dart that imports:
  • dart:html

Health suggestions

Format lib/dart_pad_parser.dart.

Run flutter format to format lib/dart_pad_parser.dart.

Format lib/dart_pad_widget.dart.

Run flutter format to format lib/dart_pad_widget.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
html_unescape ^1.0.1+3 1.0.1+3
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test