`
class SearchOffScreen extends StatelessWidget {
const SearchOffScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return DefaultLayout(
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
children: [
const SizedBox(height: 200.0,),
InkWell(
child: IgnorePointer(
child: MainSearchTextFormField(),
),
onTap: () {
print("call");
},
),
]
)
),
),
);
}
}
`
我不知道為什么單擊 MainSearchTextFormField 時 MainSearchTextFormField 不起作用。我希望當我單擊 MainSearchTextFormField 時 SearchOffScreen 會切換 SearchOnScreen。
請幫我。
我希望當我單擊 MainSearchTextFormField 時 SearchOffScreen 將切換為 SearchOnScreen。一點也沒有。
// this is search_on_screen
class SearchOnScreen extends StatelessWidget {
const SearchOnScreen ({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return DefaultLayout(
child: SafeArea(
top: true,
bottom: false,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
child: Column(
children: [
CupertinoSearchTextField(
suffixInsets: EdgeInsets.only(right: 16),ts.only(left: 16),
padding: EdgeInsets.only(left: 15,top: 15, bottom: 15),
decoration: BoxDecoration(
border: Border(bottom: BorderSide(width: 0.5, color: Color(0xff868686)))
),
),
],
),
),
),
);
}
}
// This is search_off_screen
class SearchOffScreen extends StatelessWidget {
const SearchOffScreen({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return DefaultLayout(
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: GestureDetector(
onTap: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return SearchOnScreen();
}
),
);
},
child: Container(// <-- add this
child: Column(
children: [
const SizedBox(height: 200.0,),
IgnorePointer( // <-- add this
child: MainSearchTextFormField(),
)
], //children
),
),
)
),
),
);
}
}
// This is dart.main
void main() {
runApp(
_App(),
);
}
class _App extends StatelessWidget {
const _App({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
fontFamily: 'NotoSans',
),
debugShowCheckedModeBanner: false,
home: SearchOffScreen(),
);
}
}
uj5u.com熱心網友回復:
鎖定18小時。對此答案的評論已被禁用,但它仍在接受其他互動。了解更多。因為textfield有指向它自己的指標,所以你需要禁用它才能GestureDetector點擊作業,所以用包裝你MainSearchTextFormField,IgnorePointer然后用GestureDetector替換InkWell:
child: Column(
children: [
const SizedBox(height: 200.0,),
InkWell(
child: IgnorePointer(
child: MainSearchTextFormField(),
),
onTap: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return SearchOnScreen();
}
),
);
},
),
]
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/523376.html
標籤:扑镖颤振布局
