webf 0.16.0-beta.5
webf: ^0.16.0-beta.5 copied to clipboard
W3C standards-compliant web rendering engine based on Flutter, allowing web applications to run natively on Flutter.
example/lib/main.dart
/*
* Copyright (C) 2019-2022 The Kraken authors. All rights reserved.
* Copyright (C) 2022-present The WebF authors. All rights reserved.
*/
import 'package:flutter/material.dart';
import 'package:webf/webf.dart';
import 'package:webf/devtools.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: 'Kraken Browser',
// theme: ThemeData.dark(),
debugShowCheckedModeBanner: false,
home: FirstPage(title: 'Landing Bay'),
);
}
}
class FirstPage extends StatefulWidget {
const FirstPage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<StatefulWidget> createState() {
return FirstPageState();
}
}
class FirstPageState extends State<FirstPage> {
late WebFController controller;
@override
void didChangeDependencies() {
super.didChangeDependencies();
controller = WebFController(
context,
devToolsService: ChromeDevToolsService(),
);
controller.preload(WebFBundle.fromUrl('assets:assets/bundle.html'));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: ElevatedButton(
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return MyBrowser(title: 'SecondPage', controller: controller);
}));
},
child: const Text('Open WebF Page'),
),
),
);
}
}
class MyBrowser extends StatefulWidget {
MyBrowser({Key? key, this.title, required this.controller}) : super(key: key);
final WebFController controller;
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String? title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyBrowser> {
OutlineInputBorder outlineBorder = OutlineInputBorder(
borderSide: BorderSide(color: Colors.transparent, width: 0.0),
borderRadius: const BorderRadius.all(
Radius.circular(20.0),
),
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('WebF Demo'),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: WebF(controller: widget.controller),
));
}
}