Masterarbeit Richard Stern. Flutter App, sich mit einem Bluetooth-Gerät verbindet und Berührungen auf einem Sensor visualisiert.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SideBarContent.dart 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. import 'package:webview_flutter/webview_flutter.dart';
  4. import 'dart:async';
  5. class SideBarContent extends StatefulWidget {
  6. final String html;
  7. final String title;
  8. SideBarContent({this.title, this.html});
  9. @override
  10. SideBarContentState createState() {
  11. return new SideBarContentState();
  12. }
  13. }
  14. class SideBarContentState extends State<SideBarContent> {
  15. @override
  16. Widget build(BuildContext context) {
  17. return Scaffold(
  18. appBar: AppBar(
  19. title: Text('${widget.title}'),
  20. ),
  21. body: SafeArea(
  22. child: FutureBuilder<String>(
  23. future: LocalLoader().loadLocal(widget.html),
  24. builder: (context, snapshot) {
  25. if (snapshot.hasData) {
  26. return WebView(
  27. // HTML code loaded from file
  28. initialUrl: new Uri.dataFromString(snapshot.data,
  29. mimeType: 'text/html')
  30. .toString(),
  31. javascriptMode: JavascriptMode.unrestricted,
  32. );
  33. } else if (snapshot.hasError) {
  34. return Text("Error trying to load HTML FIle: ${snapshot.error}");
  35. } else {
  36. return Container();
  37. }
  38. })));
  39. }
  40. }
  41. class LocalLoader {
  42. Future<String> loadLocal(String html) async {
  43. String response = await rootBundle.loadString(html);
  44. // return await rootBundle.loadString('assets/yourFile.html');
  45. return response;
  46. }
  47. }