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

There is a problem with ar language? (rtl direction) #335

Open
ThatPham2000 opened this issue Oct 16, 2024 · 0 comments
Open

There is a problem with ar language? (rtl direction) #335

ThatPham2000 opened this issue Oct 16, 2024 · 0 comments

Comments

@ThatPham2000
Copy link

ThatPham2000 commented Oct 16, 2024

The children of SpeedDial are displayed incorrectly.

Image:
image

Code:

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_speed_dial/flutter_speed_dial.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  var theme = ValueNotifier(ThemeMode.dark);

  @override
  Widget build(BuildContext context) {
    const appTitle = 'Flutter Speed Dial Example';
    return ValueListenableBuilder<ThemeMode>(
        valueListenable: theme,
        builder: (context, value, child) => MaterialApp(
              locale: Locale('ar'),
              supportedLocales: [Locale('ar')],
              localizationsDelegates: const [
                GlobalMaterialLocalizations.delegate,
                GlobalWidgetsLocalizations.delegate,
                GlobalCupertinoLocalizations.delegate,
              ],
              title: appTitle,
              home: MyHomePage(theme: theme),
              debugShowCheckedModeBanner: false,
              theme: ThemeData(
                brightness: Brightness.light,
                primaryColor: Colors.blue,
              ),
              darkTheme: ThemeData(
                brightness: Brightness.dark,
                primaryColor: Colors.lightBlue[900],
              ),
              themeMode: value,
            ));
  }
}

class MyHomePage extends StatefulWidget {
  final ValueNotifier<ThemeMode> theme;

  const MyHomePage({Key? key, required this.theme}) : super(key: key);

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

class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
  var extend = false;
  var customDialRoot = false;
  var isDialOpen = ValueNotifier<bool>(false);

  @override
  Widget build(BuildContext context) {
    final mediaQuery = MediaQuery.of(context);
    final maxWidth = mediaQuery.size.width - 32;

    return WillPopScope(
      onWillPop: () async {
        if (isDialOpen.value) {
          isDialOpen.value = false;
          return false;
        }
        return true;
      },
      child: Scaffold(
        appBar: AppBar(
          title: const Text("Flutter Speed Dial Example"),
        ),
        floatingActionButton: SpeedDial(
          icon: Icons.more_vert_rounded,
          activeIcon: Icons.close_rounded,
          curve: Curves.bounceIn,
          overlayOpacity: 0.5,
          openCloseDial: isDialOpen,
          switchLabelPosition: Directionality.of(context) == TextDirection.rtl,
          children: [
            SpeedDialChild(
              backgroundColor: Colors.red,
              foregroundColor: Colors.white,
              labelWidget: Container(
                constraints: BoxConstraints(maxWidth: maxWidth),
                child: OutlinedButton(
                  onPressed: () {},
                  child: const Text('First 111111111111'),
                ),
              ),
            ),
            SpeedDialChild(
              backgroundColor: Colors.deepOrange,
              foregroundColor: Colors.white,
              labelWidget: Container(
                constraints: BoxConstraints(maxWidth: maxWidth),
                child: OutlinedButton(
                  onPressed: () {},
                  child: const Text('Second 222'),
                ),
              ),
            ),
            SpeedDialChild(
              backgroundColor: Colors.indigo,
              foregroundColor: Colors.white,
              labelWidget: Container(
                constraints: BoxConstraints(maxWidth: maxWidth),
                child: OutlinedButton(
                  onPressed: () {},
                  child: const Text('Third 333333333333333333333'),
                ),
              ),
              visible: true,
            ),
          ],
        ),
      ),
    );
  }
}

extension EnumExt on FloatingActionButtonLocation {
  /// Get Value of The SpeedDialDirection Enum like Up, Down, etc. in String format
  String get value => toString().split(".")[1];
}



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant