2017-01-15 12 views
1

package:flutter/material.dartを使用するFlutterアプリケーションを作成しました。 iOS Simulatorでアプリを実行すると、次のようになります。ご覧のように、コンポーネント間のパディングは1行にあり、コンポーネントはパディング/マージン/ボーダーなしに上下左右に移動します。私の質問は次のとおりです:Material Designに準拠したパディングをFlutter Scaffoldに適用するにはどうすればよいですか?

コンバート先とドロップダウンボタンの間のラベル - コンポーネント - ギャップなど、マテリアル対応のパディングを適用するための推奨方法は何ですか?コンテナにコンポーネントをパックし、そこにパディングを適用しますか?

ありがとうございます。

Working Flutter application

これは、アプリケーションのコードです:質問はフラッターは何かが欠けていることを暗示されるものではない

import 'package:flutter/material.dart'; 
import 'converter.dart'; 
import 'model.dart'; 

const _appName = 'Temperature Converter'; 

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

class MyApp extends StatelessWidget { 
    @override 
    Widget build(BuildContext context) { 
    return new MaterialApp(
     title: _appName, 
     theme: new ThemeData(
     primarySwatch: Colors.blue, 
    ), 
     home: new MyHomePage(title: _appName), 
    ); 
    } 
} 

class MyHomePage extends StatefulWidget { 
    MyHomePage({Key key, this.title}) : super(key: key); 

    final String title; 

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

class _MyHomePageState extends State<MyHomePage> { 
    final Model model = new Model(); 
    var _currentInput = const InputValue(); 

    @override 
    Widget build(BuildContext context) { 
    return new Scaffold(
     appBar: new AppBar(
     title: new Text(config.title), 
    ), 
     body: new Column(children: <Widget>[ 
     new Row(children: <Widget>[ 
      new Expanded(
       child: new Input(
        hintText: 'Temperature', 
        value: _currentInput, 
        onChanged: (input) => _currentInput = input)), 
      new DropdownButton(
       items: createUnit(), 
       onChanged: (temperatureUnit newValue) { 
       setState(() { 
        model.inUnit = newValue; 
       }); 
       }, 
       value: model.inUnit) 
     ]), 
     new Row(children: <Widget>[ 
      new Text("Convert to"), 
      new DropdownButton(
       items: createUnit(), 
       onChanged: (temperatureUnit newValue) { 
       setState(() { 
        model.outUnit = newValue; 
       }); 
       }, 
       value: model.outUnit), 
     ]), 
     new FlatButton(
      child: new Text('Calculate'), 
      onPressed:() { 
       setState(() { 
       double inTemp = stringToDouble(_currentInput.text); 
       model.inTemperature = inTemp; 
       model.calculateOutTemperature(); 
       }); 
      }), 
     new Text(model.outTemperatureAsString) 
     ]), // This trailing comma tells the Dart formatter to use 
     // a style that looks nicer for build methods. 
    ); 
    } 

    List<DropdownMenuItem> createUnit() { 
    var l = new List<DropdownMenuItem<temperatureUnit>>(); 
    // degrees Celsius 
    l.add(new DropdownMenuItem<temperatureUnit>(
     value: temperatureUnit.degreesCelsius, 
     child: new Text(unitDegreesCelsius))); 
    // degrees Fahrenheit 
    l.add(new DropdownMenuItem<temperatureUnit>(
     value: temperatureUnit.degreesFahrenheit, 
     child: new Text(unitDegreesFahrenheit))); 
    // Kelvin 
    l.add(new DropdownMenuItem<temperatureUnit>(
     value: temperatureUnit.kelvin, child: new Text(unitKelvin))); 
    return l; 
    } 
} 

。私はただそれを正しいものにしたいだけです。 ;-)

答えて

2

通常、Scaffoldの子としてBlockを使用することをお勧めします。設定できる値はpaddingです。

Paddingウィジェットを使用することもできます。

0

私はだから私は今のところ最善の解決策が一定の値を持っているし、あなたのパディングを適用するためにコンテナを使用することだと思い

ButtonTheme.of(context).padding

パディング値を持つButtonThemeを知っています。

私は間違っているかもしれませんが、マテリアルパディングを自動的に適用するウィジェットはわかりません。

関連する問題