migrate flutter3.0

This commit is contained in:
Junyuan Feng
2022-05-12 15:06:48 +08:00
parent bfe7140a44
commit 282443a548
38 changed files with 184 additions and 140 deletions

View File

@@ -60,12 +60,15 @@ class _AptManagePageState extends State<AptManagePage>
// ignore: prefer_function_declarations_over_variables
PwdRequestFunc onPwdRequest = (user) async {
if (!mounted) return '';
final textController = TextEditingController();
await showRoundDialog(
context,
s.pwdForUser(user ?? s.unknown),
TextField(
controller: textController,
keyboardType: TextInputType.visiblePassword,
obscureText: true,
decoration: InputDecoration(
labelText: s.pwd,
),
@@ -153,7 +156,8 @@ class _AptManagePageState extends State<AptManagePage>
Padding(
padding: const EdgeInsets.all(17),
child: UrlText(
text: '${s.experimentalFeature}\n${s.reportBugsOnGithubIssue(issueUrl)}',
text:
'${s.experimentalFeature}\n${s.reportBugsOnGithubIssue(issueUrl)}',
replace: 'Github Issue',
textAlign: TextAlign.center,
),

View File

@@ -96,7 +96,7 @@ class _ConvertPageState extends State<ConvertPage>
Widget _buildTypeOption() {
final decode = s.decode;
final encode = s.encode;
final List<String> _typeOption = [
final List<String> typeOption = [
'Base64 $decode',
'Base64 $encode',
'URL $encode',
@@ -135,7 +135,7 @@ class _ConvertPageState extends State<ConvertPage>
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(_typeOption[_typeOptionIndex],
Text(typeOption[_typeOptionIndex],
textScaleFactor: 1.0,
textAlign: TextAlign.left,
style: TextStyle(
@@ -151,7 +151,7 @@ class _ConvertPageState extends State<ConvertPage>
],
),
),
children: _typeOption
children: typeOption
.map((e) => ListTile(
title: Text(
e,
@@ -159,7 +159,7 @@ class _ConvertPageState extends State<ConvertPage>
color:
_theme.textTheme.bodyText2!.color!.withAlpha(177)),
),
trailing: _buildRadio(_typeOption.indexOf(e)),
trailing: _buildRadio(typeOption.indexOf(e)),
))
.toList(),
),

View File

@@ -26,7 +26,6 @@ class DockerManagePage extends StatefulWidget {
class _DockerManagePageState extends State<DockerManagePage> {
final _docker = locator<DockerProvider>();
final greyTextStyle = const TextStyle(color: Colors.grey);
late MediaQueryData _media;
late S s;
@override
@@ -38,7 +37,6 @@ class _DockerManagePageState extends State<DockerManagePage> {
@override
void didChangeDependencies() {
super.didChangeDependencies();
_media = MediaQuery.of(context);
s = S.of(context);
}
@@ -72,17 +70,25 @@ class _DockerManagePageState extends State<DockerManagePage> {
return Consumer<DockerProvider>(builder: (_, docker, __) {
final running = docker.items;
if (docker.error != null && running == null) {
return SizedBox.expand(child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(Icons.error, size: 37,),
const SizedBox(height: 27),
Text(docker.error!),
const SizedBox(height: 27),
Padding(padding: const EdgeInsets.all(17), child: _buildSolution(docker.error!),)
],
),);
return SizedBox.expand(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.error,
size: 37,
),
const SizedBox(height: 27),
Text(docker.error!),
const SizedBox(height: 27),
Padding(
padding: const EdgeInsets.all(17),
child: _buildSolution(docker.error!),
)
],
),
);
}
if (running == null) {
_docker.refresh();
@@ -109,7 +115,10 @@ class _DockerManagePageState extends State<DockerManagePage> {
case 'no client':
return Text(s.waitConnection);
case 'invalid version':
return UrlText(text: s.invalidVersionHelp(issueUrl), replace: 'Github',);
return UrlText(
text: s.invalidVersionHelp(issueUrl),
replace: 'Github',
);
default:
return Text(s.unknownError);
}
@@ -154,17 +163,17 @@ class _DockerManagePageState extends State<DockerManagePage> {
),
customItemsHeight: 8,
items: [
DropdownMenuItem<MenuItem>(
DropdownMenuItem<DropdownBtnItem>(
value: item,
child: item.build,
),
DropdownMenuItem<MenuItem>(
DropdownMenuItem<DropdownBtnItem>(
value: DockerMenuItems.rm,
child: DockerMenuItems.rm.build,
),
],
onChanged: (value) {
final item = value as MenuItem;
final item = value as DropdownBtnItem;
switch (item) {
case DockerMenuItems.rm:
_docker.delete(containerId);

View File

@@ -53,7 +53,7 @@ class _MyHomePageState extends State<MyHomePage>
void initState() {
super.initState();
_serverProvider = locator<ServerProvider>();
WidgetsBinding.instance?.addObserver(this);
WidgetsBinding.instance.addObserver(this);
_selectIndex = locator<SettingStore>().launchPage.fetch()!;
_pageController = PageController(initialPage: _selectIndex);
_advancedDrawerController = AdvancedDrawerController();
@@ -69,7 +69,7 @@ class _MyHomePageState extends State<MyHomePage>
@override
void dispose() {
super.dispose();
WidgetsBinding.instance?.removeObserver(this);
WidgetsBinding.instance.removeObserver(this);
}
@override
@@ -249,7 +249,6 @@ class _MyHomePageState extends State<MyHomePage>
),
AboutListTile(
icon: const Icon(Icons.text_snippet),
child: Text(s.license),
applicationName: BuildData.name,
applicationVersion: _buildVersionStr(),
applicationIcon: _buildIcon(),
@@ -261,6 +260,7 @@ class _MyHomePageState extends State<MyHomePage>
replace: 'RainSunMe',
),
],
child: Text(s.license),
)
],
),

View File

@@ -80,9 +80,7 @@ class _PingPageState extends State<PingPage>
style: summaryTextStyle,
),
trailing: Text(
s.pingAvg +
(result.statistic?.avg?.toStringAsFixed(2) ?? s.unknown) +
' $ms',
'${s.pingAvg}${result.statistic?.avg?.toStringAsFixed(2) ?? s.unknown} $ms',
style: TextStyle(fontSize: 14, color: primaryColor)),
));
}

View File

@@ -85,7 +85,6 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
],
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.save),
tooltip: s.save,
onPressed: () async {
final name = nameController.text;
@@ -124,6 +123,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
}
Navigator.of(context).pop();
},
child: const Icon(Icons.save),
),
);
}

View File

@@ -123,7 +123,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
percent.toStringAsFixed(1) + '%',
'${percent.toStringAsFixed(1)}%',
style: const TextStyle(fontSize: 13),
textScaleFactor: 1.0,
),

View File

@@ -195,10 +195,9 @@ class _ServerPageState extends State<ServerPage>
children: [
_buildPercentCircle(ss.cpu2Status.usedPercent()),
_buildPercentCircle(ss.memory.used / ss.memory.total * 100),
_buildIOData('Conn:\n' + ss.tcp.maxConn.toString(),
'Fail:\n' + ss.tcp.fail.toString()),
_buildIOData('Total:\n' + rootDisk.size,
'Used:\n' + rootDisk.usedPercent.toString() + '%')
_buildIOData('Conn:\n${ss.tcp.maxConn}', 'Fail:\n${ss.tcp.fail}'),
_buildIOData(
'Total:\n${rootDisk.size}', 'Used:\n${rootDisk.usedPercent}%')
],
),
const SizedBox(height: 13),
@@ -229,21 +228,21 @@ class _ServerPageState extends State<ServerPage>
customItemsHeight: 8,
items: [
...ServerTabMenuItems.firstItems.map(
(item) => DropdownMenuItem<MenuItem>(
(item) => DropdownMenuItem<DropdownBtnItem>(
value: item,
child: item.build,
),
),
const DropdownMenuItem<Divider>(enabled: false, child: Divider()),
...ServerTabMenuItems.secondItems.map(
(item) => DropdownMenuItem<MenuItem>(
(item) => DropdownMenuItem<DropdownBtnItem>(
value: item,
child: item.build,
),
),
],
onChanged: (value) {
final item = value as MenuItem;
final item = value as DropdownBtnItem;
switch (item) {
case ServerTabMenuItems.apt:
AppRoute(AptManagePage(spi), 'apt manage page').go(context);

View File

@@ -150,10 +150,6 @@ class _SettingPageState extends State<SettingPage> {
textColor: priColor,
tilePadding: roundRectCardPadding,
childrenPadding: roundRectCardPadding,
children: [
_buildAppColorPicker(priColor),
_buildColorPickerConfirmBtn()
],
trailing: ClipOval(
child: Container(
color: priColor,
@@ -164,7 +160,11 @@ class _SettingPageState extends State<SettingPage> {
title: Text(
s.appPrimaryColor,
style: textStyle,
));
),
children: [
_buildAppColorPicker(priColor),
_buildColorPickerConfirmBtn()
]);
}
Widget _buildAppColorPicker(Color selected) {

View File

@@ -31,7 +31,7 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
super.initState();
sftpDownloadDir.then((dir) {
_path = PathWithPrefix(dir.path);
_prefixPath = dir.path + '/';
_prefixPath = '${dir.path}/';
setState(() {});
});
}
@@ -58,8 +58,8 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
],
),
body: FadeIn(
child: _buildBody(),
key: UniqueKey(),
child: _buildBody(),
),
bottomNavigationBar: SafeArea(
child: _buildPath(),

View File

@@ -122,6 +122,7 @@ class _SFTPPageState extends State<SFTPPage> {
} else {
return RefreshIndicator(
child: FadeIn(
key: Key(_status.spi!.name + _status.path!.path),
child: ListView.builder(
itemCount: _status.files!.length + 1,
controller: _scrollController,
@@ -155,7 +156,6 @@ class _SFTPPageState extends State<SFTPPage> {
);
},
),
key: Key(_status.spi!.name + _status.path!.path),
),
onRefresh: () => listDir(path: _status.path?.path));
}
@@ -277,7 +277,7 @@ class _SFTPPageState extends State<SFTPPage> {
return;
}
_status.client!
.mkdir(_status.path!.path + '/' + textController.text);
.mkdir('${_status.path!.path}/${textController.text}');
Navigator.of(context).pop();
listDir();
},
@@ -316,7 +316,7 @@ class _SFTPPageState extends State<SFTPPage> {
return;
}
(await _status.client!
.open(_status.path!.path + '/' + textController.text))
.open('${_status.path!.path}/${textController.text}'))
.writeBytes(Uint8List(0));
Navigator.of(context).pop();
listDir();

View File

@@ -215,6 +215,10 @@ class _SnippetListPageState extends State<SnippetListPage> {
height: 111,
child: Stack(children: [
Positioned(
top: 36,
bottom: 36,
left: 0,
right: 0,
child: Container(
height: 37,
decoration: const BoxDecoration(
@@ -222,10 +226,6 @@ class _SnippetListPageState extends State<SnippetListPage> {
color: Colors.black12,
),
),
top: 36,
bottom: 36,
left: 0,
right: 0,
),
ListWheelScrollView.useDelegate(
itemExtent: 37,