入口文件
import 'package:flutter/material.dart';
import 'right_back_demo.dart';
main(){
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue
),
home: RightBackDemo(),
);
}
}
方法文件
import 'package:flutter/cupertino.dart';
class RightBackDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
child: Center(
child: Container(
width: 100,
height: 100,
color: CupertinoColors.activeBlue,
child: CupertinoButton(
child: Icon(CupertinoIcons.add,color: Color.fromARGB(333, 333, 333, 333),),
// 触发事件
onPressed: (){
Navigator.of(context).push(
CupertinoPageRoute(builder: (BuildContext context){
// 每次点击再打开一次当前的页面
return RightBackDemo();
})
);
},
),
),
),
);
}
}