I've conducted a long research on the internet about this (what I think is mischievous) use of Material
widget in flutter, Any flutter developer faced the No Material widget found.
exception even when using cupertino design widgets.
A simple example to produce is
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class Example extends StatelessWidget {
const Example({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text('Example'),
leading: IconButton(
onPressed: () {},
icon: Icon(
Icons.close,
color: Colors.black54,
),
),
),
child: Center(
child: IconButton(
onPressed: () {},
icon: Icon(
Icons.close,
color: Colors.black54,
),
),
),
);
}
}
Neither the navigationBar
nor the body
IconButton
will work resulting in the same exception.
When facing this exception I always wrap it inside a Material
to bypass it, but I think am doing it wrong.IconButton
is not the only widget and I've searched a lot with no avail.
Please tell me what am I missing ? and thanks in advance.