Showing
1 changed file
with
5 additions
and
157 deletions
| @@ -14,6 +14,10 @@ | @@ -14,6 +14,10 @@ | ||
| 14 | 14 | ||
| 15 | [Histórico de atualizações](https://github.com/OpenFlutter/flutter_screenutil/blob/master/CHANGELOG.md) | 15 | [Histórico de atualizações](https://github.com/OpenFlutter/flutter_screenutil/blob/master/CHANGELOG.md) |
| 16 | 16 | ||
| 17 | +## Note | ||
| 18 | +v3 requer `flutter> = 1.19.0`. | ||
| 19 | +v2 é usado para a versão atual de flutter estável. | ||
| 20 | + | ||
| 17 | ## Como usar: | 21 | ## Como usar: |
| 18 | 22 | ||
| 19 | ### Adicionando a dependência: | 23 | ### Adicionando a dependência: |
| @@ -140,160 +144,4 @@ Container( | @@ -140,160 +144,4 @@ Container( | ||
| 140 | ScreenUtil().setSp(28) | 144 | ScreenUtil().setSp(28) |
| 141 | 145 | ||
| 142 | //Tamanho da fonte informado,em pixels,a fonte irá dimensionar respeitando a opção "Tamanho de Fonte" nas configurações de acessibilidade | 146 | //Tamanho da fonte informado,em pixels,a fonte irá dimensionar respeitando a opção "Tamanho de Fonte" nas configurações de acessibilidade |
| 143 | -//(Se em algum lugar não seguir a configuração global da propriedade allowFontScaling) | ||
| 144 | -ScreenUtil().setSp(24, allowFontScalingSelf: true) | ||
| 145 | - | ||
| 146 | -//Exemplo: | ||
| 147 | - | ||
| 148 | -Column( | ||
| 149 | - crossAxisAlignment: CrossAxisAlignment.start, | ||
| 150 | - children: <Widget>[ | ||
| 151 | - Text( | ||
| 152 | - 'Minha fonte tem 24px no protótipo de design e não irá mudar com o sistema.', | ||
| 153 | - style: TextStyle( | ||
| 154 | - color: Colors.black, | ||
| 155 | - fontSize: ScreenUtil().setSp(24), | ||
| 156 | - )), | ||
| 157 | - Text( | ||
| 158 | - 'Minha fonte tem 24px no protótipo de design e poderá mudar com o sistema.', | ||
| 159 | - style: TextStyle( | ||
| 160 | - color: Colors.black, | ||
| 161 | - fontSize: ScreenUtil() | ||
| 162 | - .setSp(24, allowFontScalingSelf: true))), | ||
| 163 | - ], | ||
| 164 | - ) | ||
| 165 | -``` | ||
| 166 | - | ||
| 167 | -#### Outras APIs relacionadas: | ||
| 168 | -```dart | ||
| 169 | - ScreenUtil.pixelRatio //Densidade de pixels do dispositivo | ||
| 170 | - ScreenUtil.screenWidth //Largura da tela do dispositivo | ||
| 171 | - ScreenUtil.screenHeight //Altura da tela do dispositivo | ||
| 172 | - ScreenUtil.bottomBarHeight //Distância segura do rodapé, adequada para botões em tela cheia | ||
| 173 | - ScreenUtil.statusBarHeight //Altura da status bar em pixels, Notch será maior | ||
| 174 | - ScreenUtil.textScaleFactor //Fator de escala da fonte do sistema | ||
| 175 | - | ||
| 176 | - ScreenUtil().scaleWidth //Razão entre a largura atual e a largura do protótipo de design em pixels | ||
| 177 | - ScreenUtil().scaleHeight //Razão entre a altura atual e a altura do protótipo de design em pixels | ||
| 178 | - | ||
| 179 | -``` | ||
| 180 | - | ||
| 181 | -```dart | ||
| 182 | -//import | ||
| 183 | -import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 184 | - | ||
| 185 | -... | ||
| 186 | - | ||
| 187 | - @override | ||
| 188 | - Widget build(BuildContext context) { | ||
| 189 | - ///Define o tamanho de ajuste (preenche o tamanho da tela do dispositivo no design). Se o design é baseado no tamanho do iPhone6 (iPhone6 750*1334) | ||
| 190 | - ScreenUtil.init(width: 750, height: 1334, allowFontScaling: false); | ||
| 191 | - | ||
| 192 | - print('Largura do dispositivo:${ScreenUtil.screenWidth}'); //Largura do dispositivo | ||
| 193 | - print('Altura do dispositivo:${ScreenUtil.screenHeight}'); //Altura do dispositivo | ||
| 194 | - print( | ||
| 195 | - 'Densidade de pixels do dispositivo:${ScreenUtil.pixelRatio}'); //Densidade de pixels do dispositivo | ||
| 196 | - print( | ||
| 197 | - 'Distância segura do rodapé:${ScreenUtil.bottomBarHeight}'); //Distância segura do rodapé, adequada para botões em tela cheia | ||
| 198 | - print( | ||
| 199 | - 'Altura da status bar:${ScreenUtil.statusBarHeight}px'); //Altura da status bar em pixels, Notch será maior | ||
| 200 | - print( | ||
| 201 | - 'Razão entre a largura atual e a largura do protótipo de design em pixels:${ScreenUtil().scaleWidth}'); | ||
| 202 | - print( | ||
| 203 | - 'Razão entre a altura atual e a altura do protótipo de design em pixels:${ScreenUtil().scaleHeight}'); | ||
| 204 | - print( | ||
| 205 | - 'Razão da fonte e largura para o tamanho do design:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}'); | ||
| 206 | - print( | ||
| 207 | - 'Razão da fonte e altura para o tamanho do design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}'); | ||
| 208 | - | ||
| 209 | - return Scaffold( | ||
| 210 | - appBar: AppBar( | ||
| 211 | - title: Text(widget.title), | ||
| 212 | - ), | ||
| 213 | - body: SingleChildScrollView( | ||
| 214 | - child: Column( | ||
| 215 | - crossAxisAlignment: CrossAxisAlignment.center, | ||
| 216 | - children: <Widget>[ | ||
| 217 | - Row( | ||
| 218 | - children: <Widget>[ | ||
| 219 | - Container( | ||
| 220 | - padding: EdgeInsets.all(ScreenUtil().setWidth(10)), | ||
| 221 | - width: ScreenUtil().setWidth(375), | ||
| 222 | - height: ScreenUtil().setHeight(200), | ||
| 223 | - color: Colors.red, | ||
| 224 | - child: Text( | ||
| 225 | - 'Minha largura:${ScreenUtil().setWidth(375)}dp', | ||
| 226 | - style: TextStyle( | ||
| 227 | - color: Colors.white, | ||
| 228 | - fontSize: ScreenUtil().setSp(12)), | ||
| 229 | - ), | ||
| 230 | - ), | ||
| 231 | - Container( | ||
| 232 | - padding: EdgeInsets.all(ScreenUtil().setWidth(10)), | ||
| 233 | - width: ScreenUtil().setWidth(375), | ||
| 234 | - height: ScreenUtil().setHeight(200), | ||
| 235 | - color: Colors.blue, | ||
| 236 | - child: Text('Minha largura:${ScreenUtil().setWidth(375)}dp', | ||
| 237 | - style: TextStyle( | ||
| 238 | - color: Colors.white, | ||
| 239 | - fontSize: ScreenUtil().setSp(12))), | ||
| 240 | - ), | ||
| 241 | - ], | ||
| 242 | - ), | ||
| 243 | - Text('Largura do dispositivo:${ScreenUtil.screenWidth}dp'), | ||
| 244 | - Text('Altura do dispositivo:${ScreenUtil.screenHeight}dp'), | ||
| 245 | - Text('Densidade de pixels do dispositivo:${ScreenUtil.pixelRatio}'), | ||
| 246 | - Text('Distância segura do rodapé:${ScreenUtil.bottomBarHeight}dp'), | ||
| 247 | - Text('Altura da status bar:${ScreenUtil.statusBarHeight}dp'), | ||
| 248 | - Text( | ||
| 249 | - 'Razão entre a largura atual e a largura do protótipo de design em pixels:${ScreenUtil().scaleWidth}', | ||
| 250 | - textAlign: TextAlign.center, | ||
| 251 | - ), | ||
| 252 | - Text( | ||
| 253 | - 'Razão entre a altura atual e a altura do protótipo de design em pixels:${ScreenUtil().scaleHeight}', | ||
| 254 | - textAlign: TextAlign.center, | ||
| 255 | - ), | ||
| 256 | - Text( | ||
| 257 | - 'Razão da fonte e largura para o tamanho do design:${ScreenUtil().scaleWidth * ScreenUtil.pixelRatio}', | ||
| 258 | - textAlign: TextAlign.center, | ||
| 259 | - ), | ||
| 260 | - Text( | ||
| 261 | - 'Razão da fonte e altura para o tamanho do design:${ScreenUtil().scaleHeight * ScreenUtil.pixelRatio}', | ||
| 262 | - textAlign: TextAlign.center, | ||
| 263 | - ), | ||
| 264 | - SizedBox( | ||
| 265 | - height: ScreenUtil().setHeight(100), | ||
| 266 | - ), | ||
| 267 | - Text('Fator de escala da fonte do sistema:${ScreenUtil.textScaleFactor}'), | ||
| 268 | - Column( | ||
| 269 | - crossAxisAlignment: CrossAxisAlignment.start, | ||
| 270 | - children: <Widget>[ | ||
| 271 | - Text( | ||
| 272 | - 'Minha fonte tem 24px no protótipo de design e não irá mudar com o sistema.', | ||
| 273 | - style: TextStyle( | ||
| 274 | - color: Colors.black, | ||
| 275 | - fontSize: ScreenUtil().setSp(24), | ||
| 276 | - )), | ||
| 277 | - Text( | ||
| 278 | - 'Minha fonte tem 24px no protótipo de design e poderá mudar com o sistema.', | ||
| 279 | - style: TextStyle( | ||
| 280 | - color: Colors.black, | ||
| 281 | - fontSize: ScreenUtil().setSp(24, allowFontScalingSelf: true), | ||
| 282 | - )), | ||
| 283 | - ], | ||
| 284 | - ) | ||
| 285 | - ], | ||
| 286 | - ), | ||
| 287 | - ), | ||
| 288 | - ); | ||
| 289 | - } | ||
| 290 | -``` | ||
| 291 | - | ||
| 292 | -### Exemplo: | ||
| 293 | - | ||
| 294 | -[Demonstração](/example/lib/main_zh.dart) | ||
| 295 | - | ||
| 296 | -Efeito: | ||
| 297 | - | ||
| 298 | - | ||
| 299 | - | ||
| 147 | +//(Se em algum lugar não seguir a configuração global da propriedade allowFontScaling |
-
Please register or login to post a comment