<p dir="auto">Got the following when building (app still runs though):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="flutter: The following assertion was thrown building MaterialApp(dirty, state: _MaterialAppState#c51fa):
flutter: 'package:flutter/src/widgets/app.dart': Failed assertion: line 169 pos 15: 'navigatorObservers !=
flutter: null': is not true.
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter:   https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #2      new WidgetsApp (package:flutter/src/widgets/app.dart:169:15)
flutter: #3      _MaterialAppState.build (package:flutter/src/material/app.dart:410:14)
flutter: #4      StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
flutter: #5      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
flutter: #6      Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: #7      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: #8      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
flutter: #9      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: #10     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: #11     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: #12     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
flutter: #13     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: #14     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: #15     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
flutter: #16     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: #17     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: #19     RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:909:16)
flutter: #20     RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:880:5)
flutter: #21     RenderObjectToWidgetAdapter.attachToRenderTree.&lt;anonymous closure&gt; (package:flutter/src/widgets/binding.dart:826:17)
flutter: #22     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
flutter: #23     RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:825:13)
flutter: #24     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding&amp;ServicesBinding&amp;SchedulerBinding&amp;PaintingBinding&amp;SemanticsBinding&amp;RendererBinding&amp;WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:712:7)
flutter: #25     runApp (package:flutter/src/widgets/binding.dart:756:7)"><pre class="notranslate"><code class="notranslate">flutter: The following assertion was thrown building MaterialApp(dirty, state: _MaterialAppState#c51fa):
flutter: 'package:flutter/src/widgets/app.dart': Failed assertion: line 169 pos 15: 'navigatorObservers !=
flutter: null': is not true.
flutter:
flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially
flutter: more information in this error message to help you determine and fix the underlying cause.
flutter: In either case, please report this assertion by filing a bug on GitHub:
flutter:   https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #2      new WidgetsApp (package:flutter/src/widgets/app.dart:169:15)
flutter: #3      _MaterialAppState.build (package:flutter/src/material/app.dart:410:14)
flutter: #4      StatefulElement.build (package:flutter/src/widgets/framework.dart:3809:27)
flutter: #5      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
flutter: #6      Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: #7      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: #8      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
flutter: #9      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: #10     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: #11     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: #12     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
flutter: #13     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
flutter: #14     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
flutter: #15     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
flutter: #16     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
flutter: #17     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
flutter: #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
flutter: #19     RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:909:16)
flutter: #20     RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:880:5)
flutter: #21     RenderObjectToWidgetAdapter.attachToRenderTree.&lt;anonymous closure&gt; (package:flutter/src/widgets/binding.dart:826:17)
flutter: #22     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2266:19)
flutter: #23     RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:825:13)
flutter: #24     _WidgetsFlutterBinding&amp;BindingBase&amp;GestureBinding&amp;ServicesBinding&amp;SchedulerBinding&amp;PaintingBinding&amp;SemanticsBinding&amp;RendererBinding&amp;WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:712:7)
flutter: #25     runApp (package:flutter/src/widgets/binding.dart:756:7)
</code></pre></div>
<p dir="auto">By specifying the <code class="notranslate">builder</code> of a <code class="notranslate">MaterialApp</code> widget, it should be possible to use a custom <code class="notranslate">Navigator</code> (or no navigator at all. The assertions of the <code class="notranslate">WidgetsApp</code> constructor make it impossible.</p>
<p dir="auto">Error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="I/flutter (19749): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (19749): The following assertion was thrown building MaterialApp(dirty, state: _MaterialAppState#f5965):
I/flutter (19749): 'package:flutter/src/widgets/app.dart': Failed assertion: line 93 pos 15: 'navigatorObservers !=
I/flutter (19749): null': is not true."><pre class="notranslate"><code class="notranslate">I/flutter (19749): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (19749): The following assertion was thrown building MaterialApp(dirty, state: _MaterialAppState#f5965):
I/flutter (19749): 'package:flutter/src/widgets/app.dart': Failed assertion: line 93 pos 15: 'navigatorObservers !=
I/flutter (19749): null': is not true.
</code></pre></div>
<p dir="auto">Removing these 2 assertions fixes the problem:</p>
<div class="highlight highlight-source-dart notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="assert(navigatorObservers != null),
assert(onGenerateRoute != null || navigatorObservers == const &lt;NavigatorObserver&gt;[]),"><pre class="notranslate"><span class="pl-k">assert</span>(navigatorObservers <span class="pl-k">!=</span> <span class="pl-c1">null</span>),
<span class="pl-k">assert</span>(onGenerateRoute <span class="pl-k">!=</span> <span class="pl-c1">null</span> <span class="pl-k">||</span> navigatorObservers <span class="pl-k">==</span> <span class="pl-k">const</span> <span class="pl-k">&lt;</span><span class="pl-c1">NavigatorObserver</span><span class="pl-k">&gt;</span>[]),</pre></div>
<p dir="auto">Example App:</p>
<div class="highlight highlight-source-dart notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import 'package:flutter/material.dart';

void main() =&gt; runApp(new MyApp());

final Map&lt;String, WidgetBuilder&gt; routes = {
  '/': (context) =&gt; HomePage(),
  '/credits': (context) =&gt; CreditsPage(),
};

RouteFactory customOnGenerateRoute = (RouteSettings settings) {
  var name = settings.name;
  print('going to route $name');
  return new MaterialPageRoute(
    builder: routes[name],
    settings: settings,
  );
};

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Navigator Demo',
      theme: new ThemeData(primarySwatch: Colors.blue),
      builder: (BuildContext context, Widget child) {
        return Navigator(
          onGenerateRoute: customOnGenerateRoute,
        );
      },
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Home')),
      body: Center(
        child: RaisedButton(
          child: Text('Credits'),
          onPressed: () {
            Navigator.of(context).pushNamed('/credits');
          },
        ),
      ),
    );
  }
}

class CreditsPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Credits')),
      body: Center(
        child: Text('made by boformer'),
      ),
    );
  }
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s">'package:flutter/material.dart'</span>;

<span class="pl-k">void</span> <span class="pl-en">main</span>() <span class="pl-k">=&gt;</span> <span class="pl-en">runApp</span>(<span class="pl-k">new</span> <span class="pl-c1">MyApp</span>());

<span class="pl-k">final</span> <span class="pl-c1">Map</span>&lt;<span class="pl-c1">String</span>, <span class="pl-c1">WidgetBuilder</span>&gt; routes <span class="pl-k">=</span> {
  <span class="pl-s">'/'</span><span class="pl-k">:</span> (context) <span class="pl-k">=&gt;</span> <span class="pl-c1">HomePage</span>(),
  <span class="pl-s">'/credits'</span><span class="pl-k">:</span> (context) <span class="pl-k">=&gt;</span> <span class="pl-c1">CreditsPage</span>(),
};

<span class="pl-c1">RouteFactory</span> customOnGenerateRoute <span class="pl-k">=</span> (<span class="pl-c1">RouteSettings</span> settings) {
  <span class="pl-k">var</span> name <span class="pl-k">=</span> settings.name;
  <span class="pl-en">print</span>(<span class="pl-s">'going to route $<span class="pl-v">name</span>'</span>);
  <span class="pl-k">return</span> <span class="pl-k">new</span> <span class="pl-c1">MaterialPageRoute</span>(
    builder<span class="pl-k">:</span> routes[name],
    settings<span class="pl-k">:</span> settings,
  );
};

<span class="pl-k">class</span> <span class="pl-c1">MyApp</span> <span class="pl-k">extends</span> <span class="pl-c1">StatelessWidget</span> {
  <span class="pl-k">@override</span>
  <span class="pl-c1">Widget</span> <span class="pl-en">build</span>(<span class="pl-c1">BuildContext</span> context) {
    <span class="pl-k">return</span> <span class="pl-k">new</span> <span class="pl-c1">MaterialApp</span>(
      title<span class="pl-k">:</span> <span class="pl-s">'Navigator Demo'</span>,
      theme<span class="pl-k">:</span> <span class="pl-k">new</span> <span class="pl-c1">ThemeData</span>(primarySwatch<span class="pl-k">:</span> <span class="pl-c1">Colors</span>.blue),
      builder<span class="pl-k">:</span> (<span class="pl-c1">BuildContext</span> context, <span class="pl-c1">Widget</span> child) {
        <span class="pl-k">return</span> <span class="pl-c1">Navigator</span>(
          onGenerateRoute<span class="pl-k">:</span> customOnGenerateRoute,
        );
      },
    );
  }
}

<span class="pl-k">class</span> <span class="pl-c1">HomePage</span> <span class="pl-k">extends</span> <span class="pl-c1">StatelessWidget</span> {
  <span class="pl-k">@override</span>
  <span class="pl-c1">Widget</span> <span class="pl-en">build</span>(<span class="pl-c1">BuildContext</span> context) {
    <span class="pl-k">return</span> <span class="pl-c1">Scaffold</span>(
      appBar<span class="pl-k">:</span> <span class="pl-c1">AppBar</span>(title<span class="pl-k">:</span> <span class="pl-c1">Text</span>(<span class="pl-s">'Home'</span>)),
      body<span class="pl-k">:</span> <span class="pl-c1">Center</span>(
        child<span class="pl-k">:</span> <span class="pl-c1">RaisedButton</span>(
          child<span class="pl-k">:</span> <span class="pl-c1">Text</span>(<span class="pl-s">'Credits'</span>),
          onPressed<span class="pl-k">:</span> () {
            <span class="pl-c1">Navigator</span>.<span class="pl-en">of</span>(context).<span class="pl-en">pushNamed</span>(<span class="pl-s">'/credits'</span>);
          },
        ),
      ),
    );
  }
}

<span class="pl-k">class</span> <span class="pl-c1">CreditsPage</span> <span class="pl-k">extends</span> <span class="pl-c1">StatelessWidget</span> {
  <span class="pl-k">@override</span>
  <span class="pl-c1">Widget</span> <span class="pl-en">build</span>(<span class="pl-c1">BuildContext</span> context) {
    <span class="pl-k">return</span> <span class="pl-c1">Scaffold</span>(
      appBar<span class="pl-k">:</span> <span class="pl-c1">AppBar</span>(title<span class="pl-k">:</span> <span class="pl-c1">Text</span>(<span class="pl-s">'Credits'</span>)),
      body<span class="pl-k">:</span> <span class="pl-c1">Center</span>(
        child<span class="pl-k">:</span> <span class="pl-c1">Text</span>(<span class="pl-s">'made by boformer'</span>),
      ),
    );
  }
}</pre></div>