1

背景の画像に重点を置いたAPPを作成しています.1行ごとにその画像にアラビア語のテキストがあり、このテキストの上に「マテリアルボタン」を追加したいと考えています。私はこれを行うことができました...しかし、左にスワイプするとボタンが見えなくなり、右にスワイプすると再び表示され、ジェスチャー検出器を使用し、右にスワイプすると画面に印刷されますまたは左にスワイプ..マテリアルボタン内にジェスチャー検出器を入力しようとしていましたが、これを試みるたびにエラーが送信されるため、コード全体の下部にジェスチャー検出器があります...助けてください...

助けてください

import 'dart:io';
import 'package:Quran_highlighter/main.dart';
import 'package:flutter/rendering.dart';
import 'package:system_shortcuts/system_shortcuts.dart';
import 'package:Quran_highlighter/Widgets/NavDrawer.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:zoom_widget/zoom_widget.dart';
import 'package:flutter/gestures.dart';

class Aliflaammeem extends StatefulWidget {
  @override
  _AliflaammeemState createState() => _AliflaammeemState();
}

class _AliflaammeemState extends State<Aliflaammeem> {
  var nameList = new List<String>();
    final items = List<String>.generate(20, (i) => "Item ${i + 1}");

  List<MaterialButton> buttonsList = new List<MaterialButton>();

  @override
  void initState(){
    super.initState();
    nameList.add("I love");
    nameList.add("my ALLAH");
    nameList.add("SWT Very Much");

List<Widget> buildButtonswithName(){
  int length = nameList.length;
  for (int i=0; i<length; i++){
    buttonsList.add(new MaterialButton(
      height:40.0,
      minWidth: 300.0,
      color: Colors.blue,
      textColor: Colors.white,

  ));
  }
}  }

List<String> labels = ['apple', 'banana', 'pineapple', 'kiwi'];
// List<VoidCallback> actions = [_buyApple, _doSomething, _downloadData, () => print('Hi')
// ];
   bool _visible = true;
  int _counter = 0;
  double _initial = 0.0;

  var textHolder = "";

  changeTextEnglish() {
    setState(() {
      bool _visible = true;
         _visible =  _visible;
      textHolder = "All Praise and Thanks is to Allah the lord of the worlds";
    });
  }

  changeTextArabic() {
    bool _visible = true;
    setState(() {
      _visible =  _visible;
    });
  }

  @override
  Widget build(BuildContext context) {
    final title = 'Dismissing Items';
    // appBar: AppBar(
    //   title: Text('Para 1, Pg2'),
    //   backgroundColor: Colors.teal[400],

    // SystemChrome.setPreferredOrientations(
    //     [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]);
    return Scaffold(
        body: Center(
            child: Stack(fit: StackFit.expand, children: <Widget>[
      Stack(
        children: <Widget>[
          SingleChildScrollView(
            scrollDirection: Axis.vertical,
            child: SafeArea(
              top: true,
              bottom: true,
              right: true,
              left: true,
              child: Image(
                  image: AssetImage('test/assets/quranpg0.png'),
                  fit: BoxFit.cover
              ),   
            ),
          ),
        ],
          ),
        
  

      Stack(
        children: <Widget>[
        // for(int i = 0; i< labels.length; i++)
        // weather_app/lib/page/settings_page.dart -- line ~81
    // ListView.builder(
    //       itemCount: items.length,
    //       itemBuilder: (context, index) {
    //         final item = items[index];

    //         return Dismissible(
    //           // Each Dismissible must contain a Key. Keys allow Flutter to
    //           // uniquely identify widgets.
    //           key: Key(item),
    //           // Provide a function that tells the app
    //           // what to do after an item has been swiped away.
    //           onDismissed: (direction) {
    //             // Remove the item from the data source.
    //             setState(() {
    //               items.removeAt(index);
    //             });
    //         // Then show a snackbar.
    //             Scaffold.of(context)
    //                 .showSnackBar(SnackBar(content: Text("$item dismissed")));
    //           },
    //           // Show a red background as the item is swiped away.
    //           background: Container(color: Colors.green),
    //           secondaryBackground: Container(color: Colors.red),
    //           child: ListTile(title: Text('$item'))
        
         
    //         );
    //           },
    //         ),

        Container(
          child: Align(
            alignment: Alignment(.27, 0.1
            ),
          //   child: Visibility(
          // visible: _visible,
          // maintainSize: true,
          // maintainAnimation: true,
          // maintainState: true,
              child: MaterialButton(
              height: 70.0,
              // minWidth: 36.5,
              minWidth: 85.0,
              onPressed: () => changeTextArabic(),
              onLongPress: () => changeTextEnglish(),
              // child: Text(labels[i]),
              child: Text('$textHolder'),
              color: Colors.cyan[400],
              // color: Colors.purple[300],
              highlightColor: Colors.blue,
              textColor: Colors.white,
              padding: EdgeInsets.only(left: 10, top: 2, right: -1, bottom: 5
              ),
              ),
            ),
            ),
            for(int i = 0; i< labels.length; i++)
               Container(
          child: Align(
            alignment: Alignment(-.5, 0.1
            ),
//  child: Text("The Most Loving",
//  style: TextStyle(
//    fontSize: 15.0,
//    backgroundColor: Colors.cyan,
//    height: 1.0,
//    fontWeight: FontWeight.bold
//    ),
            child: MaterialButton(
              height: 70.0,
              minWidth: 36.5,
              onPressed: () => changeTextArabic(),
              onLongPress: () => changeTextEnglish(),
              // Positioned(
              // top: 21,
              child: Text(labels[i]),
              disabledTextColor: Colors.transparent,
              color: Colors.cyan[300],
              // color: Colors.purple[300],
              highlightColor: Colors.blue,
              textColor: Colors.white,
              padding: EdgeInsets.only(left: 46, top: 2, right: -20, bottom: 5),
            ),
//  ),
          ),
        )
      ],
      ),
        GestureDetector(onPanUpdate: (DragUpdateDetails details) {
        if (details.delta.dx > 0) {
          print("right swipe english");
          changeTextEnglish();
          setState(() {
 
          });
        } else if (details.delta.dx < 0) {
          print("left swipe arabic");
          changeTextArabic();
          setState(() {
          });
        }
      })
    ])));
  }
}
4

1 に答える 1