'No Material widget found which widget is inside of Scaffold

The following assertion was thrown building IconButton(Icon, padding: EdgeInsets.all(8.0), dirty): No Material widget found.

But you'll see from the code below we have a Material widget present

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: Theme.of(context).platform == TargetPlatform.iOS
          ? CupertinoNavigationBar(
              actionsForegroundColor: Color.fromRGBO(135, 170, 20, 1),
              middle: Text('News Feed'),
              trailing: Wrap(
                // spacing: 12, // space between two icons
                children: <Widget>[
                  IconButton(
                    // padding: EdgeInsets.only(right: 28.0),
                    icon: Icon(CupertinoIcons.person_add_solid),
                    onPressed: () => Navigator.push(
                      context,
                      MaterialPageRoute(
                        builder: (_) => SearchScreen(),
                      ),
                    ),
                  ),

Exception Error

======== Exception caught by widgets library =======================================================
The following assertion was thrown building IconButton(Icon, padding: EdgeInsets.all(8.0), dirty):
No Material widget found.

IconButton widgets require a Material widget ancestor.
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: IconButton
  Icon
  padding: EdgeInsets.all(8.0)
  dirty
The ancestors of this widget were: 
  : Wrap
    direction: horizontal
    alignment: start
    spacing: 0.0
    runAlignment: start
    runSpacing: 0.0
    crossAxisAlignment: 0.0
    dependencies: [Directionality]
    renderObject: RenderWrap#b32a3 NEEDS-LAYOUT NEEDS-PAINT
  : MaterialApp
    state: _MaterialAppState#8caca
  : ChangeNotifierProvider<UserData>
    state: _DelegateWidgetState#ba9bc
  : MyApp
  ...
The relevant error-causing widget was: 
  IconButton file:///Users/paulmcguane/Development/threetwoonego/lib/screens/activity/Feed.dart:108:19
When the exception was thrown, this was the stack: 
#0      debugCheckHasMaterial.<anonymous closure> (package:flutter/src/material/debug.dart:28:7)
#1      debugCheckHasMaterial (package:flutter/src/material/debug.dart:50:4)
#2      IconButton.build (package:flutter/src/material/icon_button.dart:328:12)
#3      StatelessElement.build (package:flutter/src/widgets/framework.dart:4755:28)
#4      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4681:15)
...
====================================================================================================


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source