A Flutter project about shop.
Response response = await Dio().get("http://www.baidu.com");
child: Swiper(
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: (){
Application.router.navigateTo(
context,
"detail?id=${swiperDataList[index]['goodsId']}");
},
child: Image.network(
"${swiperDataList[index]['image']}",
fit: BoxFit.fill),
);
},
itemCount: swiperDataList.length, //设置数据的长度
pagination: SwiperPagination(),
autoplay: true,
),
return Container(
height: ScreenUtil().setHeight(333),
width: ScreenUtil().setWidth(750),
.....
void _launchUrl() async {
String url = 'tel:' + leaderPhone; //url中需要添加需要访问服务的类型
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'url不能打开,异常';
}
}
return EasyRefresh(
child: ListView(
children: <Widget>[
... //嵌套在需要刷新的widget外层
]
//1、建立专门的provide类 Counter 并混入ChangeNotifier 类内部编写状态变化逻辑
import 'package:flutter/material.dart';
// import 'package:provide/provide.dart';
class Counter with ChangeNotifier{
int value = 0;
increment(){
value++;
notifyListeners();//局部刷新widget
}
}
//2、在main函数中进行声明并实例化对应的provide
void main(){
var counter = Counter();
var provides = Providers();
provides..provide(Provider<Counter>.value(counter));
runApp(ProviderNode(child:MyApp(),providers:provides));
}
//3、在页面中引入该文件和库文件 即可使使用
child: Provide<Counter>(
builder: (context,child,val){ //此方法内参数固定,不需要修改
return Text(
'${counter.value}',
style: Theme.of(context).textTheme.display1,
);
},
),
if (goodsList.data == null) {
Fluttertoast.showToast(
backgroundColor: Colors.pink,
msg: '没有更多数据了',
gravity: ToastGravity.CENTER,
toastLength: Toast.LENGTH_SHORT,
textColor: Colors.white,
fontSize: 16.0
);
使用方法:商品静态化—>书写Handler—>总体route的设置,建立静态全局router 与handle的联系—>main函数中总体的注入,即将application中的声明的静态的router赋值给初始化的router,并在MaterialApp中设置其generator—>使用,直接使用application.router.navigateTo(参数)
使用方法:
return Html(
data:goodsDetail
);
var prefs = await SharedPreferences.getInstance();//获取实例对象
//增 setxx 、删 (remove、clear)、改 、查get
get/setInt(key) //- 查询或设置整型键。
get/setBool(key) //- 查询或设置布尔键。
get/setDouble(key) //- 查询或设置浮点键。
get/setString(key) //- 查询或设置字符串键。
get/setStringList(key) //- 查询或设置字符串列表键。
getKeys() //- 获取所有键值名。
remove(key) //- 删除某个键内容。
clear() //- 清除全部内容。
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.