flutter 开发问题系列之一   2021-10-17


这是 todoline++ 项目开发过程中遇到的问题系列, 记录下来供大家参考。

1 flutter 如何获取屏幕宽度和高度?

1
2
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width

2 如何修改 appBar 的背景色和前景色?

1
2
3
4
5
appBar: AppBar(
elevation: 0.5,
brightness: Brightness.light,
backgroundColor: Colors.white,
),

3 flutter 如何使用正则表达式?

下面是从网上复制过来的代码, 没有试过:

1
2
3
4
5
6
7
8
9
10
11
12
13
RegExp re = RegExp(r'(\w+)');	
String str1 = "one two three";
print('Has match: ${re.hasMatch(str1)}');

// First match
Match firstMatch = re.firstMatch(str1);
print('First match: ${str1.substring(firstMatch.start, firstMatch.end)}');

// Iterate all matches
Iterable matches = re.allMatches(str1);
matches.forEach((match) {
print(str1.substring(match.start, match.end));
});

4 flutter 中如何查询 Colors.green 的颜色值?

api.flutter.dev/flutter/material/Colors-class.html

5 flutter 如何修改 TextFiled 中的 hintText(placeHolder) 颜色?

1
2
3
4
hintText: "tips text",
hintStyle: TextStyle(
color: Colors.green
),

6 flutter 如何修改 TextFiled 的边框颜色?

解决办法:

边框颜色有两个颜色, 获取焦点时显示的颜色和失去焦点时显示的颜色
通过修改 TextField 的 enabledBorder 和 focusedBorder 两个属性可以调整边框在选中和失焦时的颜色.

来源:

jianshu.com/p/cf639c88eadd

7 配色网站

我们选定了一个颜色为主色, 如何知道哪个颜色跟这个主色最搭配?

1
https://www.paletton.com/

8 flutter 中 sqlite 的 ORM 框架哪个最好?

我自己到 pub.dev 上找了好久, 有很多框架都可以使用, 比如 sqflite, sqfentity 等, 但我觉得 floor 最好, 因为他的使用方法更接近 android 中的 room.

1
2
https://pub.dev/packages/floor
https://floor.codes/

分享到:


  如果您觉得这篇文章对您的学习很有帮助, 请您也分享它, 让它能再次帮助到更多的需要学习的人. 您的支持将鼓励我继续创作 !
本文基于署名4.0国际许可协议发布,转载请保留本文署名和文章链接。 如您有任何授权方面的协商,请邮件联系我。

Contents

  1. 1 flutter 如何获取屏幕宽度和高度?
  2. 2 如何修改 appBar 的背景色和前景色?
  3. 3 flutter 如何使用正则表达式?
  4. 4 flutter 中如何查询 Colors.green 的颜色值?
  5. 5 flutter 如何修改 TextFiled 中的 hintText(placeHolder) 颜色?
  6. 6 flutter 如何修改 TextFiled 的边框颜色?
    1. 解决办法:
    2. 来源:
  • 7 配色网站
  • 8 flutter 中 sqlite 的 ORM 框架哪个最好?