Home.dart
import 'package:flutter/material.dart';
import 'package:untitled1/Pages/SearchPage.dart';
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
children: <Widget>[
RaisedButton(
child: Text('跳转到搜索页面',style: TextStyle(
color: Colors.white
),),
onPressed: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (context)=>SearchPage(title: '搜索传值',)
)
);
},
color: Theme.of(context).accentColor,
textTheme: ButtonTextTheme.primary,//文字主题
)
],
),
);
}
}
SearchPage.dart
import 'package:flutter/material.dart';
class SearchPage extends StatelessWidget {
String title;
SearchPage({this.title='搜索'});
@override
Widget build(BuildContext context) {
return Scaffold(
//返回按钮
floatingActionButton: FloatingActionButton(
child: Text('返回',style: TextStyle(
color: Colors.white
),),
onPressed: (){
Navigator.of(context).pop();
},
),
appBar: AppBar(
title: Text(this.title,style: TextStyle(
color: Colors.amber
),),
),
body: Text('搜索页面'),
);
}
}