html_editor_enhanced 1.1.1 html_editor_enhanced: ^1.1.1 copied to clipboard
HTML Editor Enhanced is a text editor for Android and iOS to help write WYSIWYG HTML code using Summernote. Initially created by @xrb21, enhanced version maintained by @tneotia.
import 'package:flutter/material.dart';
import 'package:html_editor_enhanced/html_editor.dart';
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: 'Flutter HTML Editor Example'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
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",
height: 400,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextButton(
style: TextButton.styleFrom(backgroundColor: Colors.blueGrey),
onPressed: (){
HtmlEditor.clear();
},
child: Text("Reset", style: TextStyle(color: Colors.white)),
),
SizedBox(width: 16,),
TextButton(
style: TextButton.styleFrom(backgroundColor: Colors.blue),
onPressed: () async {
final txt = await HtmlEditor.getText();
setState(() {
result = txt;
});
},
child: Text("Submit", style: TextStyle(color: Colors.white),),
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(result),
)
],
),
),
),
);
}
}