2017-03-12 106 views
2

我正在試驗Windows上的Flutter開發。我有一個簡單的測試應用程序與一個InputField。我希望第一個鍵盤輸入是大寫字母,但目前看不到實現該功能的方法(例如,按下Shift鍵啓動鍵盤)。有任何想法嗎?如何在Flutter的文本輸入字段中配置自動大寫行爲?

代碼(有點簡單)是:

import 'package:flutter/material.dart'; 

void main() { 
    runApp(new MaterialApp(
     theme: new ThemeData.dark(), 
     home: new MainScreen() 
)); 
} 

class MainScreen extends StatelessWidget { 
    @override 
    Widget build(BuildContext context) { 
    return new Scaffold(
     appBar: new AppBar(
      leading: new IconButton(
       icon: new Icon(Icons.menu), 
       tooltip: 'Navigation menu', 
       onPressed: null, 
      ), 
      title: new Text('Test'), 
     ), 
     body: new NewTest(), 
    ); 
    } 
} 

/// Widget 
class NewTest extends StatefulWidget { 
    @override 
    _NewTestInputState createState() => new _NewTestInputState(); 
} 
/// State 
class _NewTestInputState extends State<NewTest> { 
    InputValue _currentInput; 

    void _handleInputChange(InputValue input) { 
    if (input != _currentInput){ 
     setState(() { 
     _currentInput = input; 
     }); 
    } 
    } 

    void _handleInputSubmitted(InputValue input) { 
    setState(() { 
     _currentInput = const InputValue(); 
    }); 
    } 

    @override 
    Widget build(BuildContext context) { 
    InputField _widget = new InputField(
     value: _currentInput, 
     hintText: 'Enter text', 
     keyboardType: TextInputType.text, 
     autofocus: true, 
     onChanged: _handleInputChange, 
     onSubmitted: _handleInputSubmitted, 
     style: new TextStyle(fontSize: 20.0), 
    ); 
    Container _container = new Container(
     child: _widget, 
     decoration: new BoxDecoration(
      border: new Border.all(
       color: Colors.green[300], 
       width: 2.0, 
      ), 
     ), 
     padding: new EdgeInsets.all(16.0), 
    ); 
    return _container; 
    } 
} 
+0

你能舉一個具有這種行爲的Android或iOS應用程序的例子嗎? 或者我們應該通過Flutter的默認鍵盤包裝揭示一個示例iOS或Android API? 如果是這樣,我們很樂意這樣做!並歡迎https://github.com/flutter/flutter/issues/new –

+0

提供功能請求。當然 - www.swipesapp.com是一個帶有IOS應用程序的待辦事項網站,當您添加新任務時支持此功能。 – iBob101

+0

或者iPhone上的標準Notes應用程序如何?按照我的意願,開始一個新音符並按下Shift鍵開始鍵盤。 – iBob101

回答

2

出發小寫的是一個錯誤在我們的iOS執行顫振的鍵盤包裝,這已經被固定爲今天的!

我申請的錯誤使這一配置的(這樣你就可以禁用autocapitalize句子行爲)位置:https://github.com/flutter/flutter/issues/9363

請不要猶豫,伸出手,如果這不解決您的問題。

相關問題