Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppBar within CupertinoApp no longer working #21872

Closed
calvinmuller opened this issue Sep 14, 2018 · 5 comments
Closed

AppBar within CupertinoApp no longer working #21872

calvinmuller opened this issue Sep 14, 2018 · 5 comments

Comments

@calvinmuller
Copy link

calvinmuller commented Sep 14, 2018

As far as I am aware this worked until I did a flutter upgrade today - so i'm not sure what would have changed, any insight would be useful according to #7508 this should work.

Steps to Reproduce

import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your apubpplication.
  @override
  Widget build(BuildContext context) {
    return new CupertinoApp(
      title: 'Flutter Demo',
      home: new MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {

    var appBar = AppBar(
      elevation: 0.0,
      titleSpacing: 0.0,
      title: Text('title'),
      actions: <Widget>[
        new IconButton(
          icon: Icon(
            Icons.search,
            semanticLabel: 'login',
          ),
          onPressed: () {
          },
        ),
        new IconButton(
          icon: Icon(
            Icons.tune,
            semanticLabel: 'login',
          ),
          onPressed: () {
          },
        ),
      ],
    );

    return new WillPopScope(
      // Prevent swipe popping of this page. Use explicit exit buttons only.
      onWillPop: () => new Future<bool>.value(true),
      child: Scaffold(
        appBar: appBar,
        body: Container(),
      ),
    );
  }
}

Logs

flutter.log

[✓] Flutter (Channel master, v0.8.3-pre.58, on Mac OS X 10.13.6 17G65, locale en-ZA)
    • Flutter version 0.8.3-pre.58 at /Users/calvinmuller/iStreet/Mobile/FlutterMastre
    • Framework revision dda7382e49 (65 minutes ago), 2018-09-14 12:42:20 +0200
    • Engine revision 931d3cbbc2
    • Dart version 2.1.0-dev.4.0.flutter-c28db2d6e1

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.io/setup/#android-setup for detailed instructions).
      If Android SDK has been installed to a custom location, set $ANDROID_HOME to that location.

[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 9.4.1, Build version 9F2000
    • ios-deploy 1.9.2
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.5)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 25.0.2
    • Dart plugin version 181.4892.1

[✓] Connected devices (1 available)
    • iPhone X • 2F58DD45-8972-49C0-8136-7AE1B1917B7D • ios • iOS 11.4 (simulator)

! Doctor found issues in 1 category.

@filleduchaos
Copy link
Contributor

This is definitely new - seems to be a result of #20787

@jonahwilliams
Copy link
Member

Using most Material widgets requires MaterialLocalizations. To fix this, you can add a material localization delegate to your Cupertino app:

CupertinoApp(
  localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
      DefaultMaterialLocalizations.delegate,
      DefaultWidgetsLocalizations.delegate,
  ],
  title: 'Flutter Demo',
  home: new MyHomePage(title: 'Flutter Demo Home Page'),
)

Previously there were many configurations that happened to work without them, but adding/removing certain properties might trigger a certain code path that broke. For example if you added a drawer to your AppBar it would throw the same exception.

@calvinmuller
Copy link
Author

Thanks Jonah.

@lucasjinreal
Copy link

@jonahwilliams This works, thank you very much!

@github-actions
Copy link

github-actions bot commented Sep 1, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants