title: How to navigate to page based on condition in Flutter
body: <p>I want to navigate to a page based on a condition. When I select 'license' and press the <em>next</em> button it should redirect to license page. When I select 'unlicensed' and press <em>next</em> button it should redirect me to unlicensed page.</p>
  
  <p>After selecting the 'licence'/'unlicensed' value from drop-down it should use that value to determine which page to redirect to.</p>
  
  <p>Here is some code I've tried so far:</p>
  
  <pre><code>import 'dart:io';
  import 'package:flutter/material.dart';
  import 'package:flutter_form_builder/flutter_form_builder.dart';
  
  class BspSignupPage extends StatefulWidget {         
    @override
    _BspSignupPageState createState() =&gt; _BspSignupPageState();
  }
  
  class _BspSignupPageState extends State&lt;BspSignupPage&gt; {
    bool bspcheck = false;
    final GlobalKey&lt;FormState&gt; _formKey = GlobalKey&lt;FormState&gt;();
    String _dropdownError;
  
    File _image;
  
    List&lt;String&gt; _colors = &lt;String&gt;[
      '',
      'Licensed / Register',
      'Unregistered',
    ];
  
    List&lt;DropdownMenuItem&lt;String&gt;&gt; _dropDownItem() {
      List&lt;String&gt; ddl = ["License/Registered", "UN-Registered"];
      return ddl
          .map((value) =&gt; DropdownMenuItem(
                value: value,
                child: Text(value),
              ))
          .toList();
    }
  
    Widget _buildbusinesstype() {
      String _selectedGender;
      return new FormBuilder(
          autovalidate: true,
          child: FormBuilderCustomField(
            attribute: "Business Type",
            validators: [
              FormBuilderValidators.required(),
            ],
            formField: FormField(
              builder: (FormFieldState&lt;dynamic&gt; field) {
                return InputDecorator(
                  decoration: InputDecoration(
                      prefixIcon: Icon(Icons.merge_type),
                      errorText: field.errorText),
                  //isEmpty: _color == '',
                  child: new DropdownButtonHideUnderline(
                    child: new DropdownButton(
                      value: _selectedGender,
                      items: _dropDownItem(),
                      onChanged: (value) {
                        _selectedGender = value;
                      },
                      hint: Text('Select Business Type'),
                    ),
                  ),
                );
              },
            ),
          ));
    }
  
    @override
    Widget build(BuildContext context) {
      return new Scaffold(
        appBar: AppBar(
          title: Text("BSP Signup"),
          leading: IconButton(
            icon: Icon(Icons.arrow_back_ios),
            onPressed: () {
              Navigator.pop(context);
            },
          ),
          centerTitle: true,
        ),
        bottomNavigationBar: Container(
          color: Colors.transparent,
          height: 56,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: &lt;Widget&gt;[
              new FlatButton.icon(
                icon: Icon(Icons.close),
                label: Text('Clear'),
                //  color: Colors.redAccent,
                textColor: Colors.black,
                // padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(7),
                ),
                onPressed: () {},
              ),
              new FlatButton.icon(
                  icon: Icon(Icons.ac_unit),
                  label: Text('Next'),
                  color: Colors.amber,
                  textColor: Colors.white,
                  //padding: EdgeInsets.symmetric(vertical: 10, horizontal: 20),
  
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(7),
                  ),
                  onPressed: () async {
                    if (_formKey.currentState.validate()) {
                      Navigator.push(
                          context,
                          MaterialPageRoute(
                              builder: (context) =&gt; BspSignupPage()));
                    }
                  }),
            ],
          ),
        ),
        body: Container(
          height: double.infinity,
          width: double.infinity,
          child: Form(
            autovalidate: true,
            key: _formKey,
            child: Stack(
              children: &lt;Widget&gt;[
                SingleChildScrollView(
                  padding: const EdgeInsets.all(30.0),
                  child: new Container(
                    child: new Column(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        _buildbusinesstype(),
                      ],
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      );
    }
  }
  </code></pre>