使用WillPopScope的默认构造函数实现,onWillPop回调函数返回的Future最终值为false时,当前路由不出栈(不会返回)。 主要是为了避免用户误触返回按钮导致app退出。 <code>import &#039;package:flutter/material.dart&#039;; main()=&gt;runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({Key? …

2022年8月7日 0条评论 1054点热度 0人点赞 小小调酒师 阅读全文

一、目标:使用StreamBuilder模拟实现每隔一秒返回从网络中获取的数据,并刷新页面。 效果图: Stream.periodic构造,顾名思义,是用来创建流,在周期间隔反复广播事件。 <code>import &#039;package:flutter/material.dart&#039;; main()=&gt;runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({Key? k…

2022年8月7日 0条评论 1071点热度 0人点赞 小小调酒师 阅读全文

效果图:Form表单校验 <code>import &#039;package:flutter/material.dart&#039;; main(){ runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialA…

2022年7月27日 0条评论 949点热度 0人点赞 小小调酒师 阅读全文

效果图: 1、获取文本 <code>import &#039;package:flutter/material.dart&#039;; main(){ runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialAp…

2022年7月26日 0条评论 935点热度 0人点赞 小小调酒师 阅读全文

效果图: <code>import &#039;package:flutter/material.dart&#039;; main(){ runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( debu…

2022年7月25日 0条评论 1108点热度 0人点赞 小小调酒师 阅读全文

1、async...await 返回的是Future,后面可以接then() <code>import &#039;package:flutter/material.dart&#039;; main(){ renderSome(); } request() async{ await Future.delayed(const Duration(seconds: 2)); return &quot;response&quot;; } doSomething() async{ …

2022年7月25日 0条评论 901点热度 0人点赞 小小调酒师 阅读全文

例子效果图: 代码: <code>import &#039;dart:math&#039;; import &#039;package:flutter/material.dart&#039;; main(){ runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(Buil…

2022年7月14日 0条评论 931点热度 0人点赞 小小调酒师 阅读全文

例子1: SliverGridDelegateWithMaxCrossAxisExtent 效果图: <code>import &#039;dart:math&#039;; import &#039;package:flutter/material.dart&#039;; main(){ runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : supe…

2022年7月13日 0条评论 958点热度 0人点赞 小小调酒师 阅读全文

NetworkImage 例子: 先上效果图: <code>import &#039;package:flutter/material.dart&#039;; main(){ runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { retur…

2022年7月11日 0条评论 702点热度 0人点赞 小小调酒师 阅读全文

例子一: 先上图: <code>import &#039;package:flutter/material.dart&#039;; main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return const Mater…

2022年7月10日 0条评论 781点热度 1人点赞 小小调酒师 阅读全文
1131415161729