syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.6k stars 790 forks source link

SfTheme not applying dark theme to SfPdfViewer #1908

Closed pickwick9 closed 4 months ago

pickwick9 commented 6 months ago

Bug description

When following the steps here in an attempt to get a PDF file to display dark/nightmode, it didn't seem to have any effect.

Steps to reproduce

  1. flutter create
  2. paste code sample into main.dart
  3. open emulator
  4. flutter run

Code sample

import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
import 'package:syncfusion_flutter_core/theme.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SfTheme(
        data: SfThemeData(
          brightness: Brightness.dark,
        ),
        child: SfPdfViewer.network(
            "https://www.lysator.liu.se/mit-guide/MITLockGuide.pdf"),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration https://github.com/syncfusion/flutter-widgets/assets/103296645/bb15c761-5d9d-4ea6-9137-1c82751d7a9b

Stack Traces

Stack Traces ```dart [output.txt](https://github.com/user-attachments/files/15613514/output.txt) ```

On which target platforms have you observed this bug?

Android

Flutter Doctor output

Doctor output ```console ➜ ~ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.22.1, on Pop!_OS 22.04 LTS 6.8.0-76060800daily20240311-generic, locale en_US.UTF-8) [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [✓] Chrome - develop for the web [✓] Linux toolchain - develop for Linux desktop [✓] Android Studio (version 2023.3) [✓] Connected device (3 available) [✓] Network resources • No issues found! ➜ ~ ```
immankumarsync commented 5 months ago

Hi @pickwick9,

At present we do not have support for night mode in SfPdfViewer. We do not have any immediate plans to implement this feature. At the planning stage for every release cycle, we review all open features and identify features for implementation based on specific parameters including product vision, technological feasibility, and customer interest. We will let you know when this feature is implemented. For further details, please refer to the feedback below.

Feedback link: Support for night mode

To display the UI elements in dark mode, you can assign brightness to the ThemeData / ColorScheme in the MaterialApp. Please refer to the code below,

import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
import 'package:syncfusion_flutter_core/theme.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
            seedColor: Colors.deepPurple, brightness: Brightness.dark),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SfTheme(
        data: SfThemeData(
          brightness: Brightness.dark,
        ),
        child: SfPdfViewer.network(
            "https://www.lysator.liu.se/mit-guide/MITLockGuide.pdf"),
      ),
    );
  }
}
Deepak1799 commented 4 months ago

@pickwick9 , Please use the above solution if that help or you can track the feature from the feedback link: Support for night mode