white_board_flutter 0.0.10 white_board_flutter: ^0.0.10 copied to clipboard
白板的flutter插件
import 'dart:io';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:white_board_flutter/white_board_flutter.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or press Run > Flutter Hot Reload in IntelliJ). Notice that the
// counter didn't reset back to zero; the application is not restarted.
primarySwatch: Colors.blue,
),
home: new MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePage createState() => new _MyHomePage();
}
class _MyHomePage extends State<MyHomePage> {
final scaffoldKey = GlobalKey();
final mainWhiteBoardKey = GlobalKey<WhiteBoardState>();
@override
void initState() {
super.initState();
_join();
}
_join() async {
await WhiteBoardFlutter.login(
"40ced873-41c6-4df2-bccd-2217de37ca0d",
"da75a850-"
"39ff-4bf3-ac99-926c523c189d");
await WhiteBoardFlutter.joinRoom("5671b07a89c44bc2bda54f665c7bbe12");
}
_showMagnifier() {
final whiteBoardKey = GlobalKey();
showModalBottomSheet(
context: context,
builder: (context) => Container(
height: 200.0,
child: WhiteBoardWidget(
key: whiteBoardKey,
boardType: BoardType.assist,
whiteBoardCreated: (width, height) =>
WhiteBoardFlutter.openMagnifier(0.0),
),
));
}
_screenshot() async {
final path = await WhiteBoardFlutter.screenshots();
if (path != null) {
showDialog(
context: context,
builder: (context) => Container(
color: Colors.cyan,
child: Image.file(File(path)),
));
}
}
@override
Widget build(BuildContext context) {
return new Scaffold(
key: scaffoldKey,
appBar: new AppBar(
title: const Text('Plugin example app'),
),
body: AspectRatio(
aspectRatio: 1.6,
child: WhiteBoardWidget(
key: mainWhiteBoardKey,
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton(
onPressed: () => _screenshot(),
tooltip: 'Increment',
child: new Icon(Icons.add),
),
);
}
}