0. 项目简介
项目想法脱胎于2023年服务外包大赛A18题 随手买(详情)
整个APP思路如下:
这篇博客主要服务于管理员界面的库存管理功能,在进入库存管理子界面后选择城市,根据城市购买管理库存。
1. 效果展示
2. 代码
依赖如下
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
address_picker: ^0.0.1
相关文件如下
// 点击后进入这个界面
storebuy.dart
// 主要代码都在这
storePage.dart
storePage.dart
import 'package:address_picker/address_picker.dart';
import 'package:flutter/material.dart';
import 'storebuy.dart';
class storePage extends StatefulWidget {
const storePage({Key? key}) : super(key: key);
State<storePage> createState() => _storePageState();
}
class _storePageState extends State<storePage> {
String city = "请选择城市";
Widget build(BuildContext context) {
return Scaffold(
body: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){
print("在不同页点击了空白区域!!!!!!!!!!!!!");
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (context) => storebuy(city: city),
),
);
},
child: Center(
child: TextButton(
child: Text(city, style: TextStyle(fontSize: 30),),
onPressed: () {
showModalBottomSheet(
context: context,
builder: (context) => BottomSheet(
onClosing: () { },
builder: (context) => Container(
height: 300.0,
child: AddressPicker(
style: TextStyle(color: Colors.black, fontSize: 17),
mode: AddressPickerMode.provinceCityAndDistrict,
onSelectedAddressChanged: (address) {
setState(() {
city = '${address.currentProvince.province}'+'${address.currentCity.city}'+'${address.currentDistrict.area}';
});
},
),
)
)
);
},
),
),
)
);
}
}