当前位置:网站首页>Use of fluent custom fonts and pictures

Use of fluent custom fonts and pictures

2022-04-23 19:10:00 Little brother

1. First put the fonts and pictures you need to use under the specified folder :

2. stay pubspec.yaml Initialize fonts and pictures under file :

#  Add images 
assets:
   - assets/images/bg_swms.png
   - assets/images/icon.png


#  Add the font 
fonts:
   - family: fzktc
     fonts:
       - asset: assets/fonts/fzktc.TTF

3. After initialization , Implement... In code :

display picture

 

class _SplashState extends State<HomePage> {

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: double.infinity,
      color: Colors.white,
      child: Image.asset(
        "assets/images/icon.png", /// Your local pictures --local picture
        fit: BoxFit.fill,/// Auto fill page size --auto fill page size
      ),
    );
  }

Set the font

class _MyLoginPageState extends State<Login> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(' The test system '),
        centerTitle: true,
      ),
      body: Center(
        child: Text(
          productName,
          style: TextStyle(fontFamily: 'fzktc', fontSize: 30),
        ),
      ),
    );
  }
}

Just beginning to learn , Daily records .

版权声明
本文为[Little brother]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210601422463.html