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

[BUG] MapOptions.backgroundColor doesn't get updated on rebuilds #1646

Closed
lonelyteapot opened this issue Sep 9, 2023 · 0 comments · Fixed by #1647
Closed

[BUG] MapOptions.backgroundColor doesn't get updated on rebuilds #1646

lonelyteapot opened this issue Sep 9, 2023 · 0 comments · Fixed by #1647
Labels
bug This issue reports broken functionality or another error P: 2 (soon™?)

Comments

@lonelyteapot
Copy link
Contributor

lonelyteapot commented Sep 9, 2023

What is the bug?

When the backgroundColor passed to FlutterMap.options changes, the actual displayed color does not update.

How can we reproduce it?

import 'dart:math';

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

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

class MainApp extends StatefulWidget {
  const MainApp({super.key});

  @override
  State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
  Color backgroundColor = Colors.green;

  void randomizeBackgroundColor() {
    setState(() {
      backgroundColor =
          Colors.primaries[Random().nextInt(Colors.primaries.length)];
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: FlutterMap(
        options: MapOptions(
          backgroundColor: backgroundColor,
        ),
        nonRotatedChildren: [
          Center(
            child: ElevatedButton(
              onPressed: randomizeBackgroundColor,
              child: Text(
                'Color: #${backgroundColor.value.toRadixString(16)}\n'
                'Press to randomize',
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Do you have a potential solution?

No response

Platforms

flutter_map 6.0.0-dev.3. Android, Web.

Severity

Minimum: Allows normal functioning

@lonelyteapot lonelyteapot added bug This issue reports broken functionality or another error needs triage This new bug report needs reproducing and prioritizing labels Sep 9, 2023
@JaffaKetchup JaffaKetchup added P: 2 (soon™?) and removed needs triage This new bug report needs reproducing and prioritizing labels Sep 9, 2023
@JaffaKetchup JaffaKetchup changed the title [BUG] backgroundColor doesn't get updated on rebuilds [BUG] MapOptions.backgroundColor doesn't get updated on rebuilds Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue reports broken functionality or another error P: 2 (soon™?)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants