Flutter:如何在AppBar的左侧添加徽标图像?

时间:2019-11-15 14:29:47

标签: flutter dart

我要在AppBar的左侧添加徽标图像,如下所示:https://i.stack.imgur.com/qGIbb.png

这是我当前的代码:

main.dart:

import 'package:flutter/material.dart';
import 'home_page.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(title: "Chat App", home: new LoginPage());
  }
}

home_page.dart:

import 'package:flutter/material.dart';

class LoginPage extends StatelessWidget {
  @override 
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Smart ID',
      home: Container(
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage("assets/background.png"), fit: BoxFit.cover)),
        child: Scaffold(
          backgroundColor: Colors.transparent,
          appBar: AppBar(
            elevation: 0,
            backgroundColor: Color(0xff05B068),
            centerTitle: true,
            title: Text('SMARTID', style: TextStyle(fontFamily: 'Open Sans', fontWeight: FontWeight.bold)),
          ),
        ),
      )
    );
  }
}

我如何应用徽标图像?

2 个答案:

答案 0 :(得分:2)

有一个名为def pointsAreOnSameSideOfLine(a, b, c, x1, y1, x2, y2): fx1 = 0 # Variable to store a * x1 + b * y1 - c fx2 = 0 # Variable to store a * x2 + b * y2 - c fx1 = a * x1 + b * y1 - c fx2 = a * x2 + b * y2 - c # If fx1 and fx2 have same sign if ((fx1 * fx2) > 0): return True return False 的参数,该参数采用a, b, c = 1, 1, 1 x1, y1 = 1, 1 x2, y2 = 2, 1 if (pointsAreOnSameSideOfLine(a, b, c, x1, y1, x2, y2)): print("Yes") else: print("No") 并将其放在leading的左侧。

替换我在徽标中加上的widget

AppBar

答案 1 :(得分:0)

这样做,

int a;
int c;

std::cin >> a >> discarded<int>() >> c;

输出

enter image description here

像这样在资产文件夹中添加徽标,

enter image description here

然后打开pubspec.yaml并添加徽标,

enter image description here

最后,按获取软件包,

enter image description here

相关问题