Coder Social home page Coder Social logo

Comments (6)

letsar avatar letsar commented on August 15, 2024 1

Should be fixed in version 0.4.3

from flutter_slidable.

keremkayabay avatar keremkayabay commented on August 15, 2024 1

Thank you!

from flutter_slidable.

letsar avatar letsar commented on August 15, 2024

Hi @keremkayabay,
Have you a code sample to reproduce this?

from flutter_slidable.

keremkayabay avatar keremkayabay commented on August 15, 2024

Hello @letsar

I've found out, when there are two actions on the left and one action on the right (secondaryActions), it would throw this exception. If the number of actions on the left and right are equal, it works fine.

Btw thanks for the cool package!

Here is a sample code:

import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';

String _name = "Flutter";

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
        title: "Flutter Slidable Animation Test",
        theme: new ThemeData(
          primarySwatch: Colors.blue,
          //primaryColor: Colors.grey[200],
          accentColor: Colors.blueAccent[400],
        ),
        home: new ChatScreen(),
    );
  }
}

class ChatScreen extends StatefulWidget {
  @override
  State createState() => new ChatScreenState();
}

class ChatScreenState extends State<ChatScreen> {
  final TextEditingController _textController = new TextEditingController();
  bool _isComposing = false;
  List<ChatMessage> _messages = <ChatMessage>[];

  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("Chat"),
        elevation: 0.0,
      ),
      body: new Column(
        children: <Widget>[
          new Flexible(
            child: new ListView.builder(
              padding: new EdgeInsets.all(0.0),
              reverse: true,
              itemBuilder: (_, int index) => _messages[index],
              itemCount: _messages.length,
            ),
          ),
          new Divider(height: 0.0),
          new Container(
            decoration: new BoxDecoration(
                color: Theme.of(context).cardColor),
            child: _buildTextComposer(),
          ),
        ],
      ),
    );
  }

  Widget _buildTextComposer() {
    return new IconTheme(
      data: new IconThemeData(color: Theme.of(context).accentColor),
      child: new Container(
        margin: const EdgeInsets.symmetric(horizontal: 8.0),
        child: new Row(
          children: <Widget>[
            new Flexible(
              child: new TextField(
                controller: _textController,
                onChanged: (String text) {
                  setState(() {
                    _isComposing = text.length > 0;
                  });
                },
                onSubmitted: _handleSubmitted,
                decoration: new InputDecoration.collapsed(
                    hintText: "What's in your mind"),
              ),
            ),
            new Container(
              margin: new EdgeInsets.symmetric(horizontal: 4.0),
              child: new IconButton(
                icon: new Icon(Icons.send),
                onPressed: _isComposing
                    ? () => _handleSubmitted(_textController.text)
                    : null,
              ),
            ),
          ],
        ),
      ),
    );
  }

  void _handleSubmitted(String text) {
    _textController.clear();

    setState(() {
      _isComposing = false;
    });

    ChatMessage message = new ChatMessage(
      text: text,
      parent: this,
    );

    setState(() {
      _messages.insert(0, message);
    });
  }

  void _removeMessage(ChatMessage message) {
    setState(() {
      _messages.remove(message);
    });
  }
}

class ChatMessage extends StatelessWidget {
  ChatMessage({this.text, this.parent});
  final String text;
  final ChatScreenState parent;

  @override
  Widget build(BuildContext context) {
    return new Container(
      margin: const EdgeInsets.symmetric(vertical: 2.0),
      child: new Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          new Expanded(
            child: Slidable(
              //controller: slidableController,
              delegate: new SlidableDrawerDelegate(),
              actionExtentRatio: 0.25,
              child: new Container(
                color: Colors.white,
                child: new ListTile(
                  leading: new CircleAvatar(
                    backgroundColor: Colors.blueAccent,
                    child: new Text(_name[0]),
                    foregroundColor: Colors.white,
                  ),
                  title: new Text(_name),
                  subtitle: new Text(text),
                ),
              ),
              actions: <Widget>[
                new IconSlideAction(
                  caption: 'Action 1',
                  color: Colors.black38,
                  icon: Icons.assignment,
                ),
                new IconSlideAction(
                  caption: 'Action 2',
                  color: Colors.indigo,
                  icon: Icons.forward,
                ),
              ],
              secondaryActions: <Widget>[
                new IconSlideAction(
                  caption: 'Delete',
                  color: Colors.red,
                  icon: Icons.delete,
                  onTap: () => parent._removeMessage(this),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}

from flutter_slidable.

keremkayabay avatar keremkayabay commented on August 15, 2024

And it doesn't happen at all with SlidableScrollDelegate

from flutter_slidable.

letsar avatar letsar commented on August 15, 2024

Thanks for the feedback @keremkayabay 😃.
I found why this issue was happening. Now I have to fix this :-).

from flutter_slidable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.