import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

class FilePreview extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {

    return FilePreviewState();
  }

}

class FilePreviewState extends State<FilePreview>{


  String fileUrl='';

  @override
  void initState() {
    
    super.initState();

    fileUrl= 'newteach.pbworks.com%2Ff%2Fele%2Bnewsletter.docx';

  }

  @override
  Widget build(BuildContext context) {

    return SafeArea(child: Scaffold(body: Column(children: <Widget>[


        ///在线预览
      InkWell(onTap: () async{
//      String url ='https://view.officeapps.live.com/op/view.aspx?src='+Uri.encodeComponent(fileUrl);
        String url ='https://view.officeapps.live.com/op/view.aspx?src='+fileUrl;
        print('url:$url');
        await launch(url);

      },child: Container(child: Text('跳转--',style: TextStyle(fontSize: 30),),),)


    ],),));
  }

}