AMcoder - javascript, python, java, html, php, sql

Flutter - Ինչպես ձևավորել առանձին տեքստային դաշտեր

Ես կցանկանայի ունենալ 3 տարբեր տեքստային դաշտեր՝ էկրանի ներքևի մասում մենյուով, որը թույլ կտա օգտվողին հարմարեցնել յուրաքանչյուրը առանձին: Ես ստեղծել եմ տեքստի խմբագրման 3 կարգավորիչ, բայց պետք է ձևաչափը փոխելու, որի ձևաչափը երբևէ գործող տեքստային դաշտը ներկայումս ակտիվ է, կարո՞ղ եք մտածել: Ահա իմ կոդը...

 class InsideRight extends StatefulWidget {
      const InsideRight({
        @required this.message,
        Key key
      }) : super(key: key);
    
    
      final String message;
    
      @override
      _InsideRightState createState() => _InsideRightState(message: this.message);
    }

class _InsideRightState extends State<InsideRight> {

  String message;

  _InsideRightState({
    @required this.message,
  });



  List<ColorModel> _colors = [
    ColorModel(color: Colors.black, colorName: 'Black'),
    ColorModel(color: Colors.blue, colorName: "Blue"),
    ColorModel(color: Colors.purple, colorName: "Purple"),
    ColorModel(color: Colors.pink, colorName: "Pink"),
    ColorModel(color: Colors.teal, colorName: "Teal"),
    ColorModel(color: Colors.amber, colorName: "Amber"),
    ColorModel(color: Colors.brown, colorName: "Brown"),
  ];

  List<UserFontModel> _fonts = [
    UserFontModel(fontFamily: 'Regular', fontWeight: FontWeight.w400),
    UserFontModel(fontFamily: 'Bold', fontWeight: FontWeight.w700),
    UserFontModel(fontFamily: 'Medium', fontWeight: FontWeight.w500),
    UserFontModel(fontFamily: 'Light', fontWeight: FontWeight.w300),
    UserFontModel(fontFamily: 'Thin', fontWeight: FontWeight.w100),
  ];


  final topLineController = TextEditingController(
  );
  final middleLineController = TextEditingController(
  );
  final bottomLineController = TextEditingController(
  );


  @override
  void dispose() {
    // Clean up the controller when the widget is disposed.
    topLineController.dispose();
    super.dispose();
  }

  var fontSize = 12.0;
  Color _selectedColor;
  String _selectedFontStyle;
  FontWeight fontWeight = FontWeight.w400;
  @override
  Widget build(BuildContext context) {
    try {
      fontWeight = _fonts.where((font) => font.fontFamily == _selectedFontStyle).toList()[0].fontWeight;
    } catch(e){
      fontWeight = fontWeight;
    };
    return Container(
      child: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          children: [
            Container(
                decoration: BoxDecoration(
                  border: Border.all(color: Colors.black26),
                ),
                width: MediaQuery.of(context).size.width * 0.8,
                height: MediaQuery.of(context).size.height * 0.1,
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: TextField(
                    decoration: new InputDecoration.collapsed(
                        hintStyle: TextStyle(fontFamily: FontNameDefault),
                        hintText: ''),
                    keyboardType: TextInputType.multiline,
                    maxLines: null,
                    controller: topLineController,
                    style: TextStyle(fontSize: fontSize, color: _selectedColor
                        , fontWeight: fontWeight),
                      onChanged:  (String _) {
                      setState(() {
                        print(_);
                        message = _;
                      });
                    },
                  ),
                )),
            SizedBox(height:25),
            Container(
                decoration: BoxDecoration(
                  border: Border.all(color: Colors.black26),
                ),
                width: MediaQuery.of(context).size.width * 0.8,
                height: MediaQuery.of(context).size.height * 0.4,
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: TextField(
                    decoration: new InputDecoration.collapsed(
                        hintStyle: TextStyle(fontFamily: FontNameDefault),
                        hintText: ''),
                    keyboardType: TextInputType.multiline,
                    maxLines: null,
                    controller: middleLineController,
                    style: TextStyle(fontSize: fontSize, color: _selectedColor
                        , fontWeight: fontWeight),
                    onChanged:  (String _) {
                      setState(() {
                        print(_);
                        message = _;
                      });
                    },
                  ),
                )),
            SizedBox(height:25),
            Container(
                decoration: BoxDecoration(
                  border: Border.all(color: Colors.black26),
                ),
                width: MediaQuery.of(context).size.width * 0.8,
                height: MediaQuery.of(context).size.height * 0.1,
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: TextField(
                    decoration: new InputDecoration.collapsed(
                        hintStyle: TextStyle(fontFamily: FontNameDefault),
                        hintText: ''),
                    keyboardType: TextInputType.multiline,
                    maxLines: null,
                    controller: bottomLineController,
                    style: TextStyle(fontSize: fontSize, color: _selectedColor
                        , fontWeight: fontWeight),
                    onChanged:  (String _) {
                      setState(() {
                        print(_);
                        message = _;
                      });
                    },
                  ),
                )),
            SizedBox(height:20),
            Row(
              children: [
                new DropdownButton<String>(
                  hint: Text('Size'),
                  items: new List<double>.generate(72, (i) => i + 2.0).map((double value) {
                    return new DropdownMenuItem<String>(
                      value: value.toString(),
                      child: new Text(value.toString()),
                    );
                  }).toList(),
                  onChanged: (String _) {
                    setState(() {
                      fontSize = double.parse(_);
                    });
                  },
                ),
                SizedBox(width: 10,),
                DropdownButton<Color>(
                  value: _selectedColor,
                  items: _colors
                      .map((color) => DropdownMenuItem<Color>(
                    child: Container(
                      width: MediaQuery.of(context).size.width * 0.2,
                      color: color.color,
                        child: Text('')),
                    value: color.color,
                  ))
                      .toList(),
                  hint: Text('Color'),
                  onChanged: (Color value) {
                    setState(() => _selectedColor = value);
                  },
                ),
                SizedBox(width: 10,),
                DropdownButton<String>(
                  hint: Text("Style"),
                  value: _selectedFontStyle,
                  onChanged: (String value) {
                    setState(() {
                      _selectedFontStyle = value;
                    });
                  },
                  items: _fonts.map((fonts) {
                    return  DropdownMenuItem<String>(
                        value: fonts.fontFamily,
                        child: new Container(
                          width: MediaQuery.of(context).size.width * 0.2,
                          child: Text(fonts.fontFamily, style: TextStyle(fontWeight: fonts.fontWeight),),
                        )
                    );
                  }).toList(),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

Այս պահին ես կարող եմ ստեղծել առանձին տեքստային արժեքներ, բայց երբ ես ընտրում եմ, օրինակ, տառաչափը, օգտագործելով ներքևի ընտրացանկը, բոլոր 3 արժեքները փոխվում են, երբ ես կուզենայի, որ փոխվի միայն ակտիվ տեքստի խմբագրման կարգավորիչին հատկացված արժեքը: Շնորհակալություն։


Պատասխանները:


1

Փորձեք այս?

Օգտագործեք ListView-ը

index==_selectedIndex?selectedFontSize:unselectedFontSize
28.09.2020
Նոր նյութեր

Օգտագործելով Fetch Vs Axios.Js-ը՝ HTTP հարցումներ կատարելու համար
JavaScript-ը կարող է ցանցային հարցումներ ուղարկել սերվեր և բեռնել նոր տեղեկատվություն, երբ դա անհրաժեշտ լինի: Օրինակ, մենք կարող ենք օգտագործել ցանցային հարցումը պատվեր ներկայացնելու,..

Տիրապետել հանգստության արվեստին. մշակողի ուղեցույց՝ ճնշման տակ ծաղկելու համար
Տիրապետել հանգստության արվեստին. մշակողի ուղեցույց՝ ճնշման տակ ծաղկելու համար Ինչպե՞ս հանգստացնել ձեր միտքը և աշխատեցնել ձեր պրոցեսորը: Ինչպես մնալ հանգիստ և զարգանալ ճնշման տակ...

Մեքենայի ուսուցում բանկային և ֆինանսների ոլորտում
Բարդ, խելացի անվտանգության համակարգերը և հաճախորդների սպասարկման պարզեցված ծառայությունները բիզնեսի հաջողության բանալին են: Ֆինանսական հաստատությունները, մասնավորապես, պետք է առաջ մնան կորի..

Ես AI-ին հարցրի կյանքի իմաստը, այն ինչ ասում էր, ցնցող էր:
Այն պահից ի վեր, երբ ես իմացա Արհեստական ​​ինտելեկտի մասին, ես հիացած էի այն բանով, թե ինչպես է այն կարողանում հասկանալ մարդկային նորմալ տեքստը, և այն կարող է առաջացնել իր սեփական արձագանքը դրա..

Ինչպես սովորել կոդավորումը Python-ում վագրի պես:
Սովորելու համար ծրագրավորման նոր լեզու ընտրելը բարդ է: Անկախ նրանից, թե դուք սկսնակ եք, թե առաջադեմ, դա օգնում է իմանալ, թե ինչ թեմաներ պետք է սովորել: Ծրագրավորման լեզվի հիմունքները, դրա..

C++-ի օրական բիթ(ե) | Ամենաերկար պալինդրոմային ենթաշարը
C++ #198-ի ամենօրյա բիթ(ե), Ընդհանուր հարցազրույցի խնդիր. Ամենաերկար պալինդրոմային ենթատող: Այսօր մենք կանդրադառնանք հարցազրույցի ընդհանուր խնդրին. Ամենաերկար palindromic substring...

Kydavra ICAReducer՝ ձեր տվյալների ծավալայինությունը նվազեցնելու համար
Ի՞նչ է ICAReducer-ը: ICAReducer-ն աշխատում է հետևյալ կերպ. այն նվազեցնում է նրանց միջև բարձր փոխկապակցված հատկանիշները մինչև մեկ սյունակ: Բավականին նման է PCAreducer-ին, չնայած այն..