标签:结构 span 假设 tac set this 定义 obj ttf
dependencies:
pkg1:
path: ../../code/pkg1
依赖git包
dependencies: pkg1: git: url: git://github.com/xxx/pkg1.git
flutter: assets: - assets/my_icon.png - assets/background.png
import ‘dart:async‘ show Future;import ‘package:flutter/services.dart‘ show rootBundle; Future<String> loadAsset() async { return await rootBundle.loadString(‘assets/config.json‘);}
Widget build(BuildContext context) { return new DecoratedBox( decoration: new BoxDecoration( image: new DecorationImage( image: new AssetImage(‘graphics/background.png‘), ), ), );}
Widget build(BuildContext context){ return Image.asset(‘graphics/background.png‘) }
new AssetImage(‘icons/heart.png", package:‘my_icons‘)
或
new Image.asset(‘icons/heart.png‘, package: ‘my_icons‘)
flutter:
assets:
- packages/fancy_backgrounds/backgrounds/background1.png
void collectLog(String line){ ... //收集日志}void reportErrorAndLog(FlutterErrorDetails details){ ... //上报错误和日志逻辑} FlutterErrorDetails makeDetails(Object obj, StackTrace stack){ ...// 构建错误信息} void main() { FlutterError.onError = (FlutterErrorDetails details) { reportErrorAndLog(details); }; runZoned( () => runApp(MyApp()), zoneSpecification: ZoneSpecification( print: (Zone self, ZoneDelegate parent, Zone zone, String line) { collectLog(line); // 收集日志 }, ), onError: (Object obj, StackTrace stack) { var details = makeDetails(obj, stack); reportErrorAndLog(details); }, );}
flutter: fonts: - family: Raleway fonts: - asset: assets/fonts/Raleway-Regular.ttf - asset: assets/fonts/Raleway-Medium.ttf weight: 500 - asset: assets/fonts/Raleway-SemiBold.ttf weight: 600 - family: AbrilFatface fonts: - asset: assets/fonts/abrilfatface/AbrilFatface-Regular.ttf
使用字体
// 声明文本样式const textStyle = const TextStyle( fontFamily: ‘Raleway‘,); // 使用文本样式var buttonText = const Text( "Use the font for this text", style: textStyle,);
const textStyle = const TextStyle( fontFamily: ‘Raleway‘, package: ‘my_package‘, //指定包名);
lib/fonts/Raleway-Medium.ttf
flutter: fonts: - family: Raleway fonts: - asset: assets/fonts/Raleway-Regular.ttf - asset: packages/my_package/fonts/Raleway-Medium.ttf weight: 500
const textStyle = const TextStyle( fontFamily: ‘Raleway‘,);
标签:结构 span 假设 tac set this 定义 obj ttf
原文地址:https://www.cnblogs.com/changeMsBlog/p/11296193.html