stryder-dev / flutter_platform_widgets

Target the specific design of Material for Android and Cupertino for iOS widgets through a common set of Platform aware widgets
MIT License
1.59k stars 174 forks source link

Dark mode does not work for Flutter `3.10` #402

Closed Myzel394 closed 1 year ago

Myzel394 commented 1 year ago

Dark mode is not properly recognized when using version ^3.0.0 of this package and Flutter 3.10 (when using darkTheme and theme). Related to #401

aqwert commented 1 year ago

Can you provide an example code that replicates this. The example project seems to work ok but there might be something else going on

Myzel394 commented 1 year ago

I created a new Flutter project (using Flutter 3.10.0) and added this package using flutter pub add flutter_platform_widgets and replaced MaterialApp with PlatformApp:

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

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

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

  @override
  Widget build(BuildContext context) {
    return PlatformApp(
      title: 'Flutter Demo',
      material: (_, __) => MaterialAppData(
        theme: ThemeData(),
        darkTheme: ThemeData.dark(),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
aqwert commented 1 year ago

I have published v3.3.4 that should fix this for you