jaguar_flutter_asset 3.0.0 copy "jaguar_flutter_asset: ^3.0.0" to clipboard
jaguar_flutter_asset: ^3.0.0 copied to clipboard

Serve files from Flutter assets.

jaguar_flutter_asset #

Serve files from Flutter assets.

Example showing how to use it in a project.

Usage #

Use FlutterAssetServer request handler to serve files from flutter assets.

  final server = Jaguar();
  server.addRoute(serveFlutterAssets());
  await server.serve();

Complete example #

import 'package:flutter/material.dart';
import 'package:jaguar/jaguar.dart';
import 'package:jaguar_flutter_asset/jaguar_flutter_asset.dart';

import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';

final flutterWebviewPlugin = new FlutterWebviewPlugin();

main() async {
  final server = Jaguar();
  server.addRoute(serveFlutterAssets());
  await server.serve(logRequests: true);

  server.log.onRecord.listen((r) => print(r));

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Jaguar Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Jaguar Demo'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(title),
      ),
      body: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Text(
              'Press the button to launch webview!',
            ),
          ],
        ),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: () {
          flutterWebviewPlugin.launch('http://127.0.0.1:8080/');
        },
        tooltip: 'Launch',
        child: new Icon(Icons.web),
      ),
    );
  }
}

5
likes
120
pub points
82%
popularity

Publisher

unverified uploader

Serve files from Flutter assets.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

flutter, jaguar

More

Packages that depend on jaguar_flutter_asset