83 lines
2.7 KiB
Dart
83 lines
2.7 KiB
Dart
import 'dart:ui' as ui;
|
|
import 'dart:html';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:manager_app/Components/loading.dart';
|
|
import 'package:manager_app/Components/loading_common.dart';
|
|
import 'package:manager_app/Screens/Policy/web_view.dart';
|
|
import 'package:manager_app/app_context.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class PolicyScreen extends StatefulWidget {
|
|
PolicyScreen({Key key}) : super(key: key);
|
|
|
|
@override
|
|
_PolicyScreenState createState() => _PolicyScreenState();
|
|
}
|
|
|
|
class _PolicyScreenState extends State<PolicyScreen> {
|
|
final IFrameElement _iframeElement = IFrameElement();
|
|
String filePath2 = 'files/policy_page.html';
|
|
String filePath = 'files/policy_text.text';
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final appContext = Provider.of<AppContext>(context);
|
|
Size size = MediaQuery.of(context).size;
|
|
|
|
return Scaffold(
|
|
body: FutureBuilder(
|
|
future: getHTML(),
|
|
builder: (context, AsyncSnapshot<dynamic> snapshot) {
|
|
if (snapshot.connectionState == ConnectionState.done) {
|
|
return Container(
|
|
width: size.width * 0.9,
|
|
height: size.height,
|
|
child: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(8.0),
|
|
child: Column(
|
|
children: [
|
|
Center(child: Text(snapshot.data)),
|
|
],
|
|
),
|
|
),
|
|
)
|
|
/*child: WebView(htmlText: snapshot.data))*/
|
|
);
|
|
} else if (snapshot.connectionState == ConnectionState.none) {
|
|
return Text("No data");
|
|
} else {
|
|
return Center(
|
|
child: Container(
|
|
height: size.height * 0.2,
|
|
child: LoadingCommon()
|
|
)
|
|
);
|
|
}
|
|
}
|
|
));
|
|
}
|
|
|
|
_loadHtmlFromAssets() async {
|
|
String fileHtmlContents = await rootBundle.loadString(filePath);
|
|
|
|
/*if(kIsWeb) {
|
|
_iframeElement.src = fileHtmlContents;
|
|
_iframeElement.style.border = 'none';
|
|
|
|
//ignore: undefined_prefixed_name
|
|
ui.platformViewRegistry.registerViewFactory(
|
|
_loadHtmlFromAssets(), //use source as registered key to ensure uniqueness
|
|
(int viewId) => _iframeElement,
|
|
);
|
|
}*/
|
|
return fileHtmlContents;
|
|
}
|
|
|
|
Future<String> getHTML() async {
|
|
return await rootBundle.loadString(filePath);
|
|
}
|
|
} |