Pinput doesn't work on Flutter 3.47.0, if you use the new material_ui/cupertino_ui packages.
In particular, it crashes with a "No Material widget found":
#0 debugCheckHasMaterial.<anonymous closure> (package:flutter/src/material/debug.dart:40:7)
#1 debugCheckHasMaterial (package:flutter/src/material/debug.dart:67:4)
#2 _PinputState.build (package:pinput/src/pinput_state.dart:289:12)
The problem is this line in pinput_state.dart
assert(debugCheckHasMaterial(context));
I believe that the problem is that debugCheckHasMaterial looks for a Material class in the ancestors, but the Material class in material_ui is a different class.
To Reproduce
- Install Flutter 3.47.0
- Go the example folder of pinput
- Modify the pubspec.yaml to force the latest version of flutter:
sdk: ^3.13.0
flutter: '>=3.46.0'
- Run the upgrader
dart fix --apply --code=migrate_design_widgets
- Run the example app - it will work.
- Modify the example app, and replace
import 'package:flutter/material.dart'; with import 'package:material_ui/material_ui.dart';
- The app will no longer work.
To avoid
I can do something nasty to avoid the problem - which is to wrap the Pinput in the "old" Material class:
import 'package:material_ui/material_ui.dart';
import 'package:flutter/material.dart' as hack;
Widget myPut() {
return hack.Material(child: Pinput(....));
}
Pinput doesn't work on Flutter 3.47.0, if you use the new material_ui/cupertino_ui packages.
In particular, it crashes with a "No Material widget found":
The problem is this line in
pinput_state.dartI believe that the problem is that
debugCheckHasMateriallooks for aMaterialclass in the ancestors, but theMaterialclass inmaterial_uiis a different class.To Reproduce
dart fix --apply --code=migrate_design_widgetsimport 'package:flutter/material.dart';withimport 'package:material_ui/material_ui.dart';To avoid
I can do something nasty to avoid the problem - which is to wrap the
Pinputin the "old"Materialclass: