flutter_html_editor 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 78

Flutter Html Editor #

Flutter HTML Editor is a text editor for android and iOS to help write WYSIWYG HTML code based on the Summernote javascript wrapper. with this library you can insert images into the text editor

demo example demo android demo ios

Setup #

add flutter_html_editor: ^1.0.1 as deppendecy to pubspec.yaml

iOS #

Add the following keys to your Info.plist file, located in

    <key>io.flutter.embedded_views_preview</key>
    <true/>

    <key>NSCameraUsageDescription</key>
    <string>Used to demonstrate image picker plugin</string>
    <key>NSMicrophoneUsageDescription</key>
    <string>Used to capture audio for image picker plugin</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Used to demonstrate image picker plugin</string>

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
         <true/>
    </dict>

Usage #

  1. import flutter html editor
    import 'package:flutter_html_editor/flutter_html_editor.dart';
  1. Create Global key from HTML Editor State
    GlobalKey<HtmlEditorState> keyEditor = GlobalKey();
  1. Add HTML Editor to widget
    HtmlEditor(
        hint: "Your text here...",
        //value: "text content initial, if any",
        key: keyEditor,
        height: 400,
    ),
  1. Get text from Html Editor
    final txt = await keyEditor.currentState.getText();

Avalaible option parameters #

ParameterTypeDefaultDescription
keyGlobalKeyrequiredfor get method & reset
valueStringemptyiniate text content for text editor
heightdouble380height of text editor
decorationBoxDecorationDecoration editor
useBottomSheetbooltrueif true Pickup image user bottomsheet or dialog if else
widthImageString100%width of image picker
showBottomToolbarbooltrueshow hide bottom toolbar
hintStringemptyPlaceholder hint text

License #

This project is licensed under the MIT License - see the LICENSE file for details.

#MajalengkaExoticSundaland

[1.0.1] - 2020-05-07 #

  • Update Readme usage for iOS

[1.0.0] - 2020-05-07 #

  • fixing iOS blank screen
  • fixing text hint

[0.0.2+1] - 2020-05-02 #

  • fixing path packages

[0.0.2] - 2020-05-02 #

  • Change link repo

[0.0.1] - 2020-05-02 #

  • Initial Release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_html_editor/html_editor.dart';
/**
 * Created by riyadi rb on 2/5/2020.
 * link  : https://github.com/xrb21/flutter-html-editor
 */

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Demo Flutter HTML Editor'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  GlobalKey<HtmlEditorState> keyEditor = GlobalKey();
  String result = "";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        elevation: 0,
      ),
      backgroundColor: Colors.white,
      body: Padding(
        padding: const EdgeInsets.all(20),
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              HtmlEditor(
                hint: "Your text here...",
                //value: "text content initial, if any",
                key: keyEditor,
                height: 400,
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    FlatButton(
                      color: Colors.blueGrey,
                      onPressed: (){
                        setState(() {
                          keyEditor.currentState.setEmpty();
                        });
                      },
                      child: Text("Reset", style: TextStyle(color: Colors.white)),
                    ),
                    SizedBox(width: 16,),
                    FlatButton(
                      color: Colors.blue,
                      onPressed: () async {
                        final txt = await keyEditor.currentState.getText();
                        setState(() {
                          result = txt;
                        });
                      },
                      child: Text("Submit", style: TextStyle(color: Colors.white),),
                    ),
                  ],
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(result),
              )
            ],
          ),
        ),
      ),
      // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_html_editor: ^1.0.0

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:flutter_html_editor/html_editor.dart';
import 'package:flutter_html_editor/local_server.dart';
import 'package:flutter_html_editor/pick_image.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
56
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
78
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Linux

Because:

  • package:flutter_html_editor/html_editor.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:flutter_html_editor/html_editor.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:flutter_html_editor/html_editor.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform macOS

Because:

  • package:flutter_html_editor/html_editor.dart that imports:
  • package:webview_flutter/webview_flutter.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • flutter_html_editor that is a package requiring null.

Health suggestions

Fix lib/pick_image.dart. (-0.50 points)

Analysis of lib/pick_image.dart reported 1 hint:

line 97 col 35: 'pickImage' is deprecated and shouldn't be used. Use imagePicker.getImage() method instead..

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
image_picker ^0.6.4 0.6.7+4
mime ^0.9.6+3 0.9.6+3
path ^1.6.4 1.7.0
webview_flutter ^0.3.21 0.3.22+1
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
flutter_plugin_android_lifecycle 1.0.8
http 0.12.1
http_parser 3.1.4
image_picker_platform_interface 1.1.0
meta 1.1.8 1.2.2
pedantic 1.9.0 1.9.2
plugin_platform_interface 1.0.2
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test