Skip to content

Setting View property of SfCalendar dynamically doesn't work correctly #11

Closed

Description

@xxJeevesxx

Was working in 18.2.59 but now in 18.3.38 it's not working. I reverted back to 18.2.59 and it works like before. I have a Floating Action Button that calls a function that that sets the state of and toggles a variable between CalendarView.day and Calendar.workWeek. I've confirmed that the variable changes state but the UI doesn't update. In 18.2.59 it did as I expected and once the state is updated the UI updates as well. Did something change? Am I missing something? Thanks in advance!

[√] Flutter (Channel stable, 1.22.1-0.0.pre.2, on Microsoft Windows [Version 10.0.18362.1082], locale en-US)
• Flutter version 1.22.1-0.0.pre.2 at C:\Users<username>\Documents\flutter
• Framework revision 46098c6e5f (3 days ago), 2020-10-06 18:02:43 -0700
• Engine revision 5babba6c4d
• Dart version 2.10.0

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users<username>\Documents\android
• Platform android-30, build-tools 30.0.2
• ANDROID_SDK_ROOT = C:\Users<username>\Documents\android
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.

[!] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.49.3)
• VS Code at C:\Users<username>\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.15.0

[√] Connected device (1 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)

! Doctor found issues in 1 category.

Activity

  1. Nijamudeen-Mohamed commented on Oct 12, 2020

    @Nijamudeen-Mohamed

    Hi @xxJeevesxx,

    We have validated the reported issue ‘Setting view property of SfCalendar does not work dynamically’. We have introduced view property on the controller, that handles dynamic view updates, and the view property on SfCalendar does not support dynamic updates.

    Please find the code snippet for the dynamically changes in the calendar view.

    CalendarController _controller;
    
    @override
    void initState() {
      _controller = CalendarController();
      _controller.view = CalendarView.day;
      super.initState();
    }
    
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: Center(
          child: SfCalendar(
            controller: _controller,
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () => _controller.view = CalendarView.week,
          tooltip: 'Week View',
          child: Icon(Icons.view_week),
        ), 
      );
    }
    

    We hope that this helps you. Please let us know if you need further assistance.

  2. xxJeevesxx commented on Oct 12, 2020

    @xxJeevesxx
    Author

    Great! Thanks for that. I didn't see anything about that in the breaking changes section of the notes so I came here. Works great. Thank you!!

    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions