我有两个页面P1和P2. P1有一个导航到P2的按钮。P2有一个函数来列出来自设备的所有pdf。我想显示带有P1按钮的圆形进度条我想在所有文件都得到
后导航并删除圆形进度条这只是一个例子,可以帮助你。
//Test1 page
import 'package:demostack/test2page.dart';
import 'package:flutter/material.dart';
class Test1Page extends StatelessWidget {
const Test1Page({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: TextButton(
onPressed: () {
// Navigat to Other Page
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const Test2Page(),
));
},
child: const Text('goto 2',style: TextStyle(fontSize: 30),)),
),
);
}
}
//Test2Page
import 'package:demostack/test3page.dart';
import 'package:flutter/material.dart';
class Test2Page extends StatefulWidget {
const Test2Page({Key? key}) : super(key: key);
@override
_Test2PageState createState() => _Test2PageState();
}
class _Test2PageState extends State<Test2Page> {
//one bool var to know is processing or not
//you can make this variable when your files are processing
bool isProgress=false;
@override
void initState() {
Future.delayed(Duration(seconds: 3),(){
setState(() {
//make this variable true when you get your files
isProgress=true;
});
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
//set this condition where you are showing your files.
child:isProgress==false?CircularProgressIndicator(color: Colors.red,): TextButton(
onPressed: () => Navigator.of(context).push(MaterialPageRoute(
builder: (context) => const Test3Page(),
)),
child: const Text('goto 3',style: TextStyle(fontSize: 30))),
),
);
}
}