小编faj*_*nul的帖子

在 Flutter 应用程序中设置默认语言

我正在尝试在我的应用程序中支持多种语言。我想在我的应用程序中支持两种语言:英语 (en) 和 Bahasa (id)。但是,我希望我的应用程序使用 Bahasa 作为默认语言。我尝试使用插件easy_localization来做到这一点

这是我的 main.app 文件中的一些代码

return EasyLocalizationProvider(
      data: data,
      child: MaterialApp(
        debugShowCheckedModeBanner: false,
        title: APP_NAME,

        localizationsDelegates: [
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
          //app-specific localization
          EasylocaLizationDelegate(
              locale: data.locale,
              path: 'assets/strings'
          ),
        ],
        navigatorKey: locator<NavigationService>().navigatorKey,

        supportedLocales: [ Locale('id', 'ID'), Locale('en', 'US')],
        locale: data.savedLocale,


        theme: ThemeData(
          primaryColor: KaskuColor.primary,
          accentColor: Color(0xFFCB0E00),
          fontFamily: PRIMARY_FONT_FAMILY,
          textTheme: TextTheme(
            headline: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold),
            title: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic),
            body1: TextStyle(fontSize: 14.0),
          ),
          primarySwatch: Colors.red,
          cursorColor: KaskuColor.primary,
          snackBarTheme: SnackBarThemeData(
            backgroundColor: KaskuColor.snackBarColor
          ) …
Run Code Online (Sandbox Code Playgroud)

lang flutter

7
推荐指数
2
解决办法
6467
查看次数

Flutter WillPopScope 用于嵌套导航

我有带有嵌套导航器的 Flutter 应用程序,我想WillPopScope在我的嵌套屏幕中使用覆盖“onBackPressed” 。

假设我有MainScreen, PrimaryScreen, 和SecondaryScreenPrimaryScreen嵌套导航仪,它有几个屏幕一样PrimaryOneScreenPrimaryTwoScreenPrimaryThreeScreen

SecondaryScreen也是一个嵌套的 Navigator,就像PrimaryScreen,它有 3 个屏幕。

这是我想要实现的目标的说明

MainScreen-> PrimaryScreen( PrimaryOneScreen-> PrimaryTwoScreen-> PrimaryThreeScreen)

当我在 上的位置时PrimaryTwoScreen,我想回到PrimaryOneScreen使用WillPopScopeWidget覆盖“onBackPressed”的状态。但是onWillPop当我按下后退按钮时从未调用过,我的屏幕直接返回到MainScreen.

这是我的代码

主屏幕.dart

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData( …
Run Code Online (Sandbox Code Playgroud)

android flutter flutter-navigation

7
推荐指数
1
解决办法
2058
查看次数

Laravel 5验证修剪

我是Laravel 5的初学者.

如何删除验证器中的空格?我已阅读文档,但没有修剪验证器(删除空格).

在这里我的规则

$rules = [
        'name' =>'required',
        'email' => 'required|email',
        'address' => 'required',
        'phones' => 'required'
    ];
Run Code Online (Sandbox Code Playgroud)

感谢您的回答.

php trim laravel

4
推荐指数
3
解决办法
2万
查看次数

如何修剪文本表单字段 onchange 值上的文本

我想在值更改时修剪 TextFormField 上的文本,以便用户输入名称。用户只允许输入全名,单词之间不能有多余的空格。(例如:我的名字伊斯罗梅奥)

我已经使用 TextEditingController 但仍然无法正常工作。这是我实现目标的代码片段

final myController = TextEditingController();

...

return new TextFormField(
      onChanged: (value){
        myController..text = value.trim()
          ..selection = TextSelection.collapsed(offset: myController.text.length);
      },
      controller: myController,
      keyboardType: TextInputType.phone,
      style: FormStyles.inputStyles(),
      decoration: InputDecoration(
        focusedBorder: UnderlineInputBorder(borderSide: BorderSide(color: Color(0xFFCACCCF))),
        hintText: 'hint',
        contentPadding: EdgeInsets.only(bottom: 8),
        hintStyle: FormStyles.hintStyles(),
        enabledBorder: UnderlineInputBorder(borderSide: BorderSide(color: Color(0xFFCACCCF)),),
        errorStyle: FormStyles.errorStyles(),
      ),
    );

Run Code Online (Sandbox Code Playgroud)

如果我只输入空格,上面的代码工作正常,但在第一个单词后输入空格后,光标移动到第一个字符。有什么建议吗?

提前致谢!

validation flutter

3
推荐指数
1
解决办法
2988
查看次数

标签 统计

flutter ×3

android ×1

flutter-navigation ×1

lang ×1

laravel ×1

php ×1

trim ×1

validation ×1