Flutter-24- 类似iOS 页面左滑

Cupertino UI:

其实早都知道Flutter有两套UI模板,一套是material,另一套就是Cupertino。Cupertino主要针对的的就是IOS系统的UI,所以用的右滑返回上一级就是在这个Cupertino里。

Cupertino的引入方法

import 'package:flutter/cupertino.dart';

CupertinoPageScaffold:

return CupertinoPageScaffold(
child: Center(
child: Container(
height: 100.0,
width:100.0,
color: CupertinoColors.activeBlue,
child: CupertinoButton(
child: Icon(CupertinoIcons.add),
onPressed: (){
Navigator.of(context).push(
CupertinoPageRoute(builder: (BuildContext context){
return RightBackDemo();
})
);
},
),
),
),
);
在Cupertino下也有很多Widget控件,他们都是以Cupertino开头的,这就让我们很好区分,当然两种皮肤是可以进行混用的。

main.dart文件代码:

import 'package:flutter/material.dart';
import 'right_back_demo.dart';

void main()=>runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title:'Flutter Demo',
theme:ThemeData(primarySwatch: Colors.blue),
home: RightBackDemo(),
);
}
}

right_back_demo。dart文件:

import 'package:flutter/cupertino.dart';

class RightBackDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
child: Center(
child: Container(
height: 100.0,
width:100.0,
color: CupertinoColors.activeBlue,
child: CupertinoButton(
child: Icon(CupertinoIcons.add),
onPressed: (){
Navigator.of(context).push(
CupertinoPageRoute(builder: (BuildContext context){
return RightBackDemo();
})
);
},
),
),
),
);
}
}

你可能感兴趣的:(Flutter-24- 类似iOS 页面左滑)