Q&A
前提
Rowの中にColumnを入れ子の状態にしてTextウィジェットを定義したときに、テキストが左寄せできないことについてです。
columnに中央寄せを定義しているからか、Textウィジェットを左寄せすることができません。
実現したいこと
入れ子にして定義したTextが二つあるのですが、左寄せしたいです。
どなたかアドバイスいただけないでしょうか。
該当のソースコード
Dart
1import 'package:flutter/material.dart'; 2import 'package:flutter/cupertino.dart'; 3 4class PushNotification extends StatefulWidget { 5 const PushNotification({Key? key}) : super(key: key); 6 7 State<PushNotification> createState() => _PushNotification(); 8} 9 10class _PushNotification extends State<PushNotification> { 11 bool _isOn2 = true; 12 13 14 Widget build(BuildContext context) { 15 final double deviceHeight = MediaQuery.of(context).size.height; 16 final double devicewWdth = MediaQuery.of(context).size.width; 17 return Scaffold( 18 backgroundColor: Color.fromARGB(255, 243, 243, 243), 19 appBar: PreferredSize( 20 preferredSize: Size.fromHeight(70), 21 child: AppBar( 22 iconTheme: IconThemeData(color: Colors.black, size: 23), 23 leadingWidth: devicewWdth * 0.2, 24 backgroundColor: Color.fromARGB(255, 243, 243, 243), 25 elevation: 0.0, 26 centerTitle: true, 27 title: Text('テキスト', 28 style: TextStyle( 29 fontWeight: FontWeight.w600, 30 fontSize: 14, 31 color: Colors.black)), 32 bottom: PreferredSize( 33 child: Container( 34 height: 0.3, 35 color: Color.fromARGB(255, 156, 156, 156), 36 ), 37 preferredSize: Size.fromHeight(5)), 38 ), 39 ), 40 body: Center( 41 child: Container( 42 color: Color.fromARGB(255, 243, 243, 243), 43 child: Column( 44 children: <Widget>[ 45 Container( 46 height: deviceHeight * 0.08, 47 width: devicewWdth, 48 decoration: BoxDecoration( 49 border: Border( 50 bottom: BorderSide( 51 color: Color.fromARGB(255, 156, 156, 156), 52 width: 0.3, 53 ), 54 ), 55 color: Colors.white, 56 ), 57 child: Row( 58 mainAxisAlignment: MainAxisAlignment.spaceBetween, 59 children: <Widget>[ 60 Row( 61 children: <Widget>[ 62 Column( 63 mainAxisAlignment: MainAxisAlignment.center, 64 children: <Widget>[ 65 Text( 66 'テキスト', 67 textAlign: TextAlign.left, 68 ), 69 Text( 70 'テキスト', 71 style: TextStyle( 72 fontSize: 10, 73 color: Color.fromARGB(255, 156, 156, 156)), 74 ), 75 ], 76 ), 77 ], 78 ), 79 CupertinoSwitch( 80 value: _isOn2, 81 onChanged: (bool? value) => 82 setState(() => _isOn2 = value!), 83 ), 84 ], 85 ), 86 ), 87 ], 88 ), 89 ), 90 ), 91 ); 92 } 93} 94
試したこと
Textウィジェットを一つずつContainerで包んんで左寄せしてみましたが変化ありませんでした。
補足情報(FW/ツールのバージョンなど)
[✓] Flutter (Channel stable, 3.3.8, on macOS 13.0.1 22A400 darwin-arm, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.73.0)
回答2件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2022/11/26 04:18