import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:webview_flutter/webview_flutter.dart'; import 'dart:async'; class SideBarContent extends StatefulWidget { final String html; final String title; SideBarContent({this.title, this.html}); @override SideBarContentState createState() { return new SideBarContentState(); } } class SideBarContentState extends State { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('${widget.title}'), ), body: SafeArea( child: FutureBuilder( future: LocalLoader().loadLocal(widget.html), builder: (context, snapshot) { if (snapshot.hasData) { return WebView( // HTML code loaded from file initialUrl: new Uri.dataFromString(snapshot.data, mimeType: 'text/html') .toString(), javascriptMode: JavascriptMode.unrestricted, ); } else if (snapshot.hasError) { return Text("Error trying to load HTML FIle: ${snapshot.error}"); } else { return Container(); } }))); } } class LocalLoader { Future loadLocal(String html) async { String response = await rootBundle.loadString(html); // return await rootBundle.loadString('assets/yourFile.html'); return response; } }