mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-05-23 07:46:46 +08:00
refactor(many files): 页面部分的文件结构调整
1.views 文件夹里面分类,页面相关文件;2.公共组件全部放在components里;3.创建resources文件夹放置资源dart文件4.修改二级菜单文字大小 BREAKING CHANGE: 重构,建议删除本地db,再编译
This commit is contained in:
43
lib/utils/example_code_parser.dart
Normal file
43
lib/utils/example_code_parser.dart
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* @Author: 一凨
|
||||
* @Date: 2019-01-14 11:42:36
|
||||
* @Last Modified by: 一凨
|
||||
* @Last Modified time: 2019-01-14 16:53:11
|
||||
*/
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import '../routers/application.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
Map<String, String> _exampleCode;
|
||||
String _code;
|
||||
|
||||
void _launchURL(String url) async {
|
||||
if (await canLaunch(url)) {
|
||||
await launch(url);
|
||||
} else {
|
||||
throw 'Could not launch $url';
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getExampleCode(context,String filePath, AssetBundle bundle) async {
|
||||
if (_exampleCode == null) await _parseExampleCode(context,filePath, bundle);
|
||||
return _code;
|
||||
}
|
||||
|
||||
Future<void> _parseExampleCode(context,String filePath, AssetBundle bundle) async {
|
||||
String code;
|
||||
try {
|
||||
code = await bundle.loadString('lib/widgets/$filePath');
|
||||
} catch (err) {
|
||||
Navigator.of(context).pop();
|
||||
_launchURL(Application.github['widgetsURL'] + filePath);
|
||||
}
|
||||
_code = code;
|
||||
}
|
Reference in New Issue
Block a user