No Material widget found.
TextField widgets require a Material widget ancestor within the closest LookupBoundary.
In Material Design, most widgets are conceptually "printed" on a sheet of material. In Flutter's material library, that material is represented by the Material widget. It is the Material widget that renders ink splashes, for instance. Because of this, many material library widgets require that there be a Material widget in the tree above them.
To introduce a Material widget, you can either directly include one, or use a widget that contains Material itself, such as a Card, Dialog, Drawer, or Scaffold.
The specific widget that could not find a Material ancestor was: TextField
а это WidgetTree
введите здесь описание изображения
что мне делать?
я думаю, что
textField нужен MaterialApp, но метод push Navigator -> новый UiStack в MateriApp -> Нет MaterialApp
Я хочу перейти в MyApp -> Home -> SearchStore но это не работает. это мой код виджета MyApp, Home, SearchStore Виджет MyApp [code]class MyApp extends StatelessWidget { const MyApp({super.key});
// This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, theme: AppStyle().appTheme, home: Scaffold( body: FutureBuilder( future: checkUserInfo(context), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return Center( child: SvgPicture.asset( 'assets/brand/big_logo.svg', ), ); } else if (snapshot.data!) { return const Home(); } else { return const SignIn(); } }, ), ), ); } } [/code] Виджет «Главная» [code]class Home extends StatelessWidget { const Home ({super.key});
[/code] я хочу, чтобы Navigator толкнул домой -> виджет SearchStore, но при использовании метода Navigator.push выдается ошибка это стек вызовов ошибок [code]debugCheckHasMaterial. (c:\Users\jun\flutter\packages\flutter\lib\src\material\debug.dart:38) debugCheckHasMaterial (c:\Users\jun\flutter\packages\flutter\lib\src\material\debug.dart:63) _TextFieldState.build (c:\Users\jun\flutter\packages\flutter\lib\src\material\text_field.dart:1324) StatefulElement.build (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5592) ComponentElement.performRebuild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5480) StatefulElement.performRebuild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5643) Element.rebuild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5196) ComponentElement._firstBuild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5462) StatefulElement._firstBuild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5634) ComponentElement.mount (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5456) Element.inflateWidget (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:4335) Element.updateChild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:3846) ComponentElement.performRebuild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5505) Element.rebuild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5196) ComponentElement._firstBuild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5462) ComponentElement.mount (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5456) Element.inflateWidget (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:4335) Element.updateChild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:3846) ComponentElement.performRebuild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5505) StatefulElement.performRebuild (c:\Users\jun\flutter\packages\flutter\lib\src\widgets\framework.dart:5643
[/code] а это консоль отладки [code]No Material widget found. TextField widgets require a Material widget ancestor within the closest LookupBoundary. In Material Design, most widgets are conceptually "printed" on a sheet of material. In Flutter's material library, that material is represented by the Material widget. It is the Material widget that renders ink splashes, for instance. Because of this, many material library widgets require that there be a Material widget in the tree above them. To introduce a Material widget, you can either directly include one, or use a widget that contains Material itself, such as a Card, Dialog, Drawer, or Scaffold. The specific widget that could not find a Material ancestor was: TextField [/code] а это WidgetTree введите здесь описание изображения что мне делать? я думаю, что textField нужен MaterialApp, но метод push Navigator -> новый UiStack в MateriApp -> Нет MaterialApp [list] [*]Оберните MaterialAPP и Scaffold[/list] [code] Hero( tag: 'hero', child: TextField( readOnly: true, onTap: () { Navigator.of(context).push( MaterialPageRoute( builder: (context) => MaterialApp( home: Scaffold( body: SearchStore(), ), ), ), ); }, decoration: InputDecoration( prefixIcon: Icon(Icons.search), prefixIconColor: AppStyle().brandColor, hintText: 'need store name.', enabledBorder: OutlineInputBorder( borderSide: BorderSide( color: AppStyle().brandColor, width: 1.5, ), borderRadius: BorderRadius.circular(15), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( color: AppStyle().brandColor, width: 1.5, ), borderRadius: BorderRadius.circular(15), ), ), ), ) [/code] но тот же стек вызовов ошибок, консоль отладки я не знаю, что мне делать