Git Product home page Git Product logo

flutter.widgets's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter.widgets's Issues

ScrollablePositionedList: Provide a header builder

This is very useful when creating Apps that support book libraries. It is always good to show the reader the data in the book. I currently use the NestedScrollView with headerSliverBuilder but has bugs in the scroll, sometimes jumps.

v0.1.8 didn't fit flutter version range in environment

Some code are using functions of BuildContext such as findAncestorStateOfType which doesn't exist before flutter 1.12 but the environment in pubspec.yaml is flutter: ^1.9.1.
This makes the app which is using flutter 1.9 or 1.10 failure when building.

ScrollablePositionedList '_scrollableListState != null': is not true.

I am getting crash when the screen which have
ScrollablePositionedList getting closed/disposed (back button)

I am using ChangeNotifierProvider and Consumer pattern.

The error happen after the notifyListeners() in provider get called then I press back button.

the Error:

The following assertion was thrown while finalizing the widget tree:
'package:flutter_widgets/src/scrollable_positioned_list/src/scrollable_positioned_list.dart': Failed assertion: line 195 pos 12: '_scrollableListState != null': is not true.

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=BUG.md

When the exception was thrown, this was the stack: 
#2      ItemScrollController._detach (package:flutter_widgets/src/scrollable_positioned_list/src/scrollable_positioned_list.dart:195:12)
#3      _ScrollablePositionedListState.dispose (package:flutter_widgets/src/scrollable_positioned_list/src/scrollable_positioned_list.dart:232:34)
#4      StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4435:12)
#5      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1748:13)
#6      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1746:7)

My Code:

class AyahListPage extends StatefulWidget {

  Surah surah;

  AyahListPage(this.surah);

  @override
  _AyahListPageState createState() => _AyahListPageState();
}

class _AyahListPageState extends State<AyahListPage> {
  AyahPool_Provider ayahPool_Provider = AyahPool_Provider();

  ItemScrollController itemScrollController;
  ItemPositionsListener itemPositionListener;


  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {

    MasterProvider masterProvider = Provider.of<MasterProvider>(context);


    return FutureBuilder(
      future: loadTask(),
      builder: (context, snapshot) {

        if(! snapshot.hasData)
          return CircularProgressIndicator();

        return ChangeNotifierProvider<AyahPool_Provider>(
            create: (context) => ayahPool_Provider,
            child: Scaffold(
                appBar: AppBar(title: Text(masterProvider.appTitle)),
                body: Container(margin: EdgeInsets.all(8),
                    child:
                    Consumer<AyahPool_Provider>(
                        builder: (context, provider, _) {

                          var checkBox = CheckboxListTile(title: Text('Trans'),value: provider.ayahMode_withWordTrans,
                            onChanged: (flag) {
                              provider.ayahMode_withWordTrans = flag;
                            },);

                          var checkBox_2 = CheckboxListTile(title: Text('Lemma'),value: provider.ayahMode_withWordLemma,
                            onChanged: (flag) {
                              provider.ayahMode_withWordLemma = flag;
                            },);

                          var pageContent = Column(children: <Widget>[Wrap(children: <Widget>[checkBox, checkBox_2]),
                            Expanded(child: AyahListView(widget.surah))],);

                          return pageContent;


                        }))));

      },
    );



  }

  Future<AyahList> loadTask() async {
    ayahPool_Provider.surah = widget.surah;
    ayahPool_Provider.bislAllah_glyph = await DAO_TB_Glyph.db_getBismallah();
    ayahPool_Provider.ayahList = await DAO_TB_Glyph.db_getBySurah_asAyahList(widget.surah.ID);
    return ayahPool_Provider.ayahList;
  }


   // --------------- Ayah List part ----------------------------

  Widget AyahListView(Surah surah) {
    ayahPool_Provider.addBismAllahItem_ifSurahHave(widget.surah);

    var ayahList_listView = listView_fromAyahList(ayahPool_Provider);

    return ayahList_listView;
  }

  Widget listView_fromAyahList(AyahPool_Provider ayahPool_Provider,
      {double size = Quran_Ui.quranText_defaultSize}) {


    // This is to scroll to specific item (LATER).
    itemScrollController = ItemScrollController(); //TODO: this make bug if i set it.
    itemPositionListener = ItemPositionsListener.create();
    var listView = ScrollablePositionedList.builder(
        itemCount: ayahPool_Provider.ayahList.ayahList.length,
        itemPositionsListener: itemPositionListener,
        itemScrollController: itemScrollController,
        itemBuilder: (BuildContext context, int index) {
          Ayah ayah = ayahPool_Provider.ayahList.ayahList[index];

          if (ayah.translationAndExplaination_mapList != null || ayah.isThisBismallahItem())
            return buildAyahItem(index, ayahPool_Provider, size);

          return FutureBuilder(
              future: loadTransBox(ayahPool_Provider.surah, ayah),
              builder: (context, snapshot) {
                // this will hide the widget if the data still not loaded
                double opacityVal = (snapshot.hasData) ? 1 : 0;
                return Opacity(
                    child: buildAyahItem(
                        index, ayahPool_Provider, size),
                    opacity: opacityVal);
              }
          );
        });

    return listView;

  }

Can't build app on Android or IOS

indepent from the platform i can't build the app.
it gave me this error

Compiler message:
../.pub-cache/hosted/pub.dartlang.org/flutter_widgets-0.1.5/lib/src/visibility_detector/src/visibility_detector_layer.dart:277:18: Error: This expression has type 'void' and can't be used.
return super.addToScene(builder, layerOffset);

BoxShadow showing above the other widgets in ScrollablePositionedList

I have Container as the child of the ScrollablePositionedList's item builder and the Container has some decoration and box-shadow. However, the box-shadow is showing above the other list items.

I tried using ListView's builder and its working as expected, not showing the box-shadow above the other list items. Any suggestions on what's causing the issue?

image

ScrollablePositionedList.builder(
itemCount: services.length,
itemBuilder: (context, index) {
  var service = services[index];
  return Container(
    padding:
        EdgeInsets.symmetric(horizontal: 30, vertical: 15),
    margin: EdgeInsets.symmetric(horizontal: 20, vertical: 5),
    decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(Radius.circular(15)),
        boxShadow: [
          BoxShadow(
              color: Color(0x1a000000),
              blurRadius: 20,
              spreadRadius: 0,
              offset: Offset(0, 10))
        ]),
    child: Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: <Widget>[
        SizedBox(
          width: 200,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Text(
                service.name,
                style: TextStyle(fontSize: 20),
              ),
              Text(
                service.description,
                style: TextStyle(fontSize: 12),
                overflow: TextOverflow.ellipsis,
                maxLines: 2,
              ),
            ],
          ),
        ),
        MaterialButton(
          minWidth: 0,
          child: Text('Edit'),
          onPressed: () {
            Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => AddServiceDetails(
                          serviceEdit: _serviceChanged,
                        )));
          },
          shape: new RoundedRectangleBorder(
              borderRadius: BorderRadius.all(
            Radius.circular(10),
          )),
          clipBehavior: Clip.antiAlias,
          textColor: Colors.teal,
        )
      ],
    ),
  );
}),

ScrollablePositionedList: Another exception was thrown: NoSuchMethodError: invalid member on null: '_jumpTo'

_jumpTo wont work in stateless widget


class NewsListView extends StatelessWidget {
  final List<News> news;
  final News focusedNews;
  final ItemScrollController _scrollController = ItemScrollController();
  BuildContext context;
  int focusedIndex;
  NewsListView(this.news, {this.defaultItemAction, this.focusedNews, Key key})
      : super(key: key);
  final NewsListItemActions defaultItemAction;

  @override
  Widget build(BuildContext context) {
    WidgetsBinding.instance
        .addPostFrameCallback((_) => _scrollToFocused());
    this.context = context;
    return Scrollbar(
        child: news.isEmpty
            ? Text("loading..")
            : ScrollablePositionedList.builder(
                itemScrollController: _scrollController,
                itemCount: news.length,
                itemBuilder: (context, index) {
                  var data = news[index];
                  var isFocused =
                      focusedNews != null ? data.id == focusedNews.id : false;
                  if (isFocused) focusedIndex = index;
                  return NewsListItem(
                    data,
                    isFocused: isFocused,
                    actions: defaultItemAction,
                  );
                },
              ));
  }

  _scrollToFocused() {
    print("index $focusedIndex");
    if (focusedIndex != null) {
      _scrollController.jumpTo(index: focusedIndex);
      print('scroll jumped to $focusedIndex');
    }
  }
}

Another exception was thrown: NoSuchMethodError: invalid member on null: '_jumpTo'

ScrollablePositionedList rebuild a deleted list item

Hello,

I am using a ScrollablePositionedList coupled with a ChangeNotifierProvider.
I want to give the user the possibility to delete an item of the list.

  • The user click on the delete button associated to an item.
  • Then provider is called and remove this item from the model.
  • Then notifyListeners() is called.
  • ScrollablePositionedList is rebuild with the updated list of item.

For some reasons, the widget associated to the deleted item is also rebuild, which causes an error.

For now, if it occurs, I return an empty container but it is only a quick fix.

I'm pretty sure the problem comes from ScrollablePositionedList because everything works fine with a ListView.

Here is a minimal example to reproduce the problem:

import 'package:flutter/material.dart';
import 'package:flutter_widgets/flutter_widgets.dart';
import 'package:provider/provider.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider<MyModel>(
      builder: (context) => MyModel(),
      child: MaterialApp(
        home: Scaffold(
          appBar: AppBar(title: const Text('My App')),
          body: Container(
            padding: const EdgeInsets.only(left: 16.0),
            width: 200,
            child: Consumer<MyModel>(
              builder: (context, myModel, child) {
                print('Build ScrollablePositionedList');
                print('itemIDs: ${myModel.itemIDs}');
                print('itemsMap: ${myModel.itemsMap}');
                return ScrollablePositionedList.builder(
                  scrollDirection: Axis.vertical,
                  itemCount: myModel.itemIDs.length,
                  itemBuilder: (BuildContext context, int index) {
                    final itemID = myModel.itemIDs[index];
                    return CustomItem(
                      key: Key('customItem_$itemID'),
                      itemID: itemID,
                    );
                  },
                );
              },
            ),
          ),
        ),
      ),
    );
  }
}

class CustomItem extends StatelessWidget {
  const CustomItem({
    Key key,
    this.itemID,
  }) : super(key: key);

  final String itemID;

  @override
  Widget build(BuildContext context) {
    final myModel = Provider.of<MyModel>(context);
    print('Build CustomItem $itemID');

    // DEBUG ********
    if (myModel.itemsMap[itemID] == null) {
      print('Building a deleted item...');
      return Container(
        width: 0.0,
        height: 0.0,
      );
    }
    // **************

    return Row(
      children: <Widget>[
        Text(myModel.itemsMap[itemID]['label']),
        IconButton(
          icon: Icon(Icons.delete),
          disabledColor: Colors.grey,
          onPressed: myModel.itemIDs.length > 1 ? () => myModel.removeItem(itemID) : null,
        )
      ],
    );
  }
}

class MyModel with ChangeNotifier {
  List<String> itemIDs = ['A', 'B', 'C'];
  Map<String, Map<String, dynamic>> itemsMap = {
    'A': {
      'label': 'Item A',
    },
    'B': {
      'label': 'Item B',
    },
    'C': {
      'label': 'Item C',
    },
  };

  void removeItem(itemID) {
    print('Remove item $itemID');
    final itemIndex = itemIDs.indexWhere((id) => id == itemID);
    if (itemIndex > -1) {
      itemIDs.removeAt(itemIndex);
      itemsMap.remove(itemID);
    }

    notifyListeners();
  }
}

flutter_widgets 0.1.6-dev.1 is incompatible with flutter v1.9.1+hotfix.2

As a followup of #20 being fixed, I tried upgrade to flutter v1.9.1+hotfix.2 (now beta and I am assuming it will become stable soon), but pub get complains that intl in flutter sdk (0.15.8) is behind what flutter_widgets requires (0.16.0):

Because every version of app_ui from path depends on hux from path which depends on flutter_widgets 0.1.6-dev.1, every version of app_ui from path requires flutter_widgets 0.1.6-dev.1.
And because flutter_widgets >=0.1.6-dev.1 depends on intl ^0.16.0 and every version of flutter_localizations from sdk depends on intl 0.15.8, app_ui from path is incompatible with flutter_localizations from sdk.
So, because hue_blue_app depends on app_ui from path which depends on flutter_localizations any from sdk, version solving failed.
pub get failed (1)

Is it strictly needed for flutter_widgets to use 0.16.0?

ScrollablePositionedList: Assert when reuse the ScrollablePositionedList

Well, it's not breaking things, just an assert triggered when dispose.

flutter doctor -v:

[✓] Flutter (Channel master, v1.10.1-pre.42, on Mac OS X 10.14.5 18F132, locale zh-Hans-CN)
    • Flutter version 1.10.1-pre.42 at /Users/li9s/github/flutter
    • Framework revision 681178ab45 (71 minutes ago), 2019-09-09 16:47:49 +0800
    • Engine revision c9ea4dba8d
    • Dart version 2.5.0 (build 2.5.0-dev.4.0 ec7ec4ecf7)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
    • Android SDK at /Users/li9s/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.0
    • ANDROID_HOME = /Users/li9s/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/li9s/Library/Android/sdk
    • Java binary at: /Applications/Dev/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
    • Xcode at /Applications/Dev/Xcode.app/Contents/Developer
    • Xcode 10.3, Build version 10G8
    • CocoaPods version 1.7.1

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Dev/Android Studio.app/Contents
    • Flutter plugin version 36.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Dev/Android Studio.app/Contents
    • Flutter plugin version 36.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.3)
    • IntelliJ at /Applications/Dev/IntelliJ IDEA.app
    • Flutter plugin version 37.1.3
    • Dart plugin version 191.7830

[✓] Connected device (1 available)
    • LON AL00 • TEV0216C22001731 • android-arm64 • Android 9 (API 28)

I/flutter (12153): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (12153): The following assertion was thrown while finalizing the widget tree:
I/flutter (12153): 'package:mhwo/third_party/scrollable_positioned_list/scrollable_positioned_list.dart': Failed
I/flutter (12153): assertion: line 157 pos 12: '_scrollableListState != null': is not true.
I/flutter (12153): 
I/flutter (12153): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (12153): more information in this error message to help you determine and fix the underlying cause.
I/flutter (12153): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (12153):   https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (12153): 
I/flutter (12153): When the exception was thrown, this was the stack:
I/flutter (12153): #2      ItemScrollController._detach (package:mhwo/third_party/scrollable_positioned_list/scrollable_positioned_list.dart:157:12)
I/flutter (12153): #3      _ScrollablePositionedListState.dispose (package:mhwo/third_party/scrollable_positioned_list/scrollable_positioned_list.dart:192:34)
I/flutter (12153): #4      StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4135:12)
I/flutter (12153): #5      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1738:13)
I/flutter (12153): #6      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1736:7)
I/flutter (12153): #7      ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3983:14)
I/flutter (12153): #8      _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1734:13)
I/flutter (12153): #9      _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1736:7)
I/flutter (12153): #10     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3983:14)
I/flutter (12153): #11     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1734:13)
I/flutter (12153): #12     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1736:7)
I/flutter (12153): #13     MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5218:16)
I/flutter (12153): #14     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1734:13)
I/flutter (12153): #15     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1736:7)
I/flutter (12153): #16     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3983:14)
I/flutter (12153): #17     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1734:13)
I/flutter (12153): #18     _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1736:7)
I/flutter (12153): #19     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3983:14)
I/flutter (12153): #20     _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1734:13)

VisibilityDetector no longer compiles

When trying to include VisibilityDetector, any flutter command fails with

Running Gradle task 'assembleDevelopmentDebug'...

Compiler message:
../../../../.pub-cache/hosted/pub.dartlang.org/flutter_widgets-0.1.5/lib/src/visibility_detector/src/visibility_detector_layer.dart:277:18: Error: This expression has type 'void' and can't be used.
    return super.addToScene(builder, layerOffset);
                 ^

This is due to a breaking change which hasn't been fixed here.

https://github.com/flutter/flutter/pull/36402/files#diff-58600d3d2645a66835eb03f3c41b447bR848

Cancel timers when the VisibilityDetector is removed.

VisibilityDetector

The VisibilityDetector should cancel timers, when it is removed from the widget tree.

For example the following test case should work:

void main() {
  testWidgets('Does not crash without waiting for the update interval.',
      (WidgetTester tester) async {
    final _uniqueKey = UniqueKey();
    await tester.pumpWidget(MaterialApp(home: VisibilityDetector(
        key: _uniqueKey,
        child: Container(),
        onVisibilityChanged: (_) {})));
    await tester.pumpWidget(Placeholder());
    // await widgetTester.pump(VisibilityDetectorController.instance.updateInterval);
  }, timeout: Timeout.none);
}

But it fails with Timer still pending.

Currently we have to uncomment the last line to make it work. This looks like an issue with cancelling timers, or flutter not correctly identifying cancelled timers.

ScrollablePositionedList - shrinkWrap

Could you add the shrinkWrap property to the ScrollablePositionedList ?
It will be used in the UnboundedCustomScrollView. In this class shrinkWrap is always false.

ScrollablePositionedList builder itemsCount zero

Hi. It's so disappointing. When itemCount is zero it executes builder with index 0
The same goes when itemCount: 1

ScrollablePositionedList.builder(
  itemCount: 0,
  itemBuilder: (context, index) =>
      Text('Item $index'),
)

Please fix this. Thanks

Why FeatureDisocery widget is not exported

Is there any reason why FeatureDiscovery widget is not exported publicly?

I can import package:flutter_widgets/src/feature_discovery/feature_discovery.dart', but this gives me warning while running flutter analyze.

FeatureDiscovery for non-icon widgets

Currently FeatureDiscovery only supports discovery of Icon widgets. Imagine a situation when feature that you want your users to discover is not an icon eg.:

  • a Button - sometimes buttons have only text without an icon, like "Select All", "Send to all" or "Mark as done",
  • a TextField - you could guide users though required form inputs when they see fairly complex form for the first time,
  • a ScrollList - when it is not obvious that part of the screen can be scrolled eg. with Google Calendar for Android one cannot tell that it can be scrolled left and right to previous and next month.

In such cases it would be good to have the ability to use the same widget (that gives users the same look and feel) as for other part of app (that were using icons).

ScrollablePositionedList: Exception when setState

NullPointer happens when the page is detached from window, if (mounted) maybe needed.

NoSuchMethodError
NoSuchMethodError: The method 'markNeedsBuild' was called on null. Receiver: null Tried calling: markNeedsBuild
1 #0 State.setState (package:flutter/src/widgets/framework.dart:1168)
2 #1 _ScrollablePositionedListState._startScroll.<anonymous closure> (package:flutter_widgets/src/scrollable_positioned_list/src/scrollable_positioned_list.dart:409)
3 #2 _ScrollablePositionedListState._startScroll.<anonymous closure> (package:flutter_widgets/src/scrollable_positioned_list/src/scrollable_positioned_list.dart:420)
4 #3 _rootRunUnary (dart:async/zone.dart:1134)
5 #4 _CustomZone.runUnary (dart:async/zone.dart:1031)
6 #5 _FutureListener.handleValue (dart:async/future_impl.dart:139)
7 #6 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680)
8 #7 Future._propagateToListeners (dart:async/future_impl.dart:709)
9 #8 Future._completeWithValue (dart:async/future_impl.dart:524)
10 #9 Future.wait.<anonymous closure> (dart:async/future.dart:400)
11 #10 _rootRunUnary (dart:async/zone.dart:1134)
12 #11 _CustomZone.runUnary (dart:async/zone.dart:1031)
13 #12 _FutureListener.handleValue (dart:async/future_impl.dart:139)
14 #13 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680)
15 #14 Future._propagateToListeners (dart:async/future_impl.dart:709)
16 #15 Future._completeWithValue (dart:async/future_impl.dart:524)
17 #16 Future.wait.<anonymous closure> (dart:async/future.dart:400)
18 #17 _rootRunUnary (dart:async/zone.dart:1134)
19 #18 _CustomZone.runUnary (dart:async/zone.dart:1031)
20 #19 _FutureListener.handleValue (dart:async/future_impl.dart:139)
21 #20 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680)
22 #21 Future._propagateToListeners (dart:async/future_impl.dart:709)
23 #22 Future._completeWithValue (dart:async/future_impl.dart:524)
24 #23 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:554)
25 #24 _rootRun (dart:async/zone.dart:1126)
26 #25 _CustomZone.run (dart:async/zone.dart:1023)
27 #26 _CustomZone.runGuarded (dart:async/zone.dart:925)
28 #27 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965)
29 #28 _microtaskLoop (dart:async/schedule_microtask.dart:43)
30 #29 _startMicrotaskLoop (dart:async/schedule_microtask.dart:52)

ScrollablePositionedList: Use ScrollablePositionedList inside a CustomScrollVIew

It would be awesome to be able to use ScrollablePositionedList inside a CustomScrollView.
I am currently working on a MVP that uses Slivers for reading some content, and by using ScrollablePositionedList with another library, I would be able to save the position inside the content when the user has left the page on any device.

VisibilityDetector VisibilityFraction no longer 0 when new route slides on top

After upgrading to flutter_widgets: 0.1.6 to make it compatible with latest Flutter release, when sliding a route on top of the route with the visibility widget, is now still considered visible with fractions of ~ 0.8601489100280483, while in reality, should be zero.

When switching tabs or opening a root route, visible fraction is set to 0 as expected.

The route I'm pushing on top of the element is custom

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

class OBSlideRightRoute<T> extends PageRouteBuilder<T> {
  final Widget widget;
  final Key key;

  OBSlideRightRoute({this.widget, this.key})
      : super(
            opaque: false,
            transitionDuration: const Duration(milliseconds: 200),
            pageBuilder: (BuildContext context, Animation<double> animation,
                Animation<double> secondaryAnimation) {
              return Dismissible(
                  background: const DecoratedBox(decoration: const BoxDecoration(
                      color: Color.fromARGB(0, 0, 0, 0)
                  ),),
                  direction: DismissDirection.startToEnd,
                  onDismissed: (direction) {
                    Navigator.pop(context);
                  },
                  key: key,
                  child: Material(
                    child: widget,
                  ));
            },
            transitionsBuilder: (BuildContext context,
                Animation<double> animation,
                Animation<double> secondaryAnimation,
                Widget child) {
              return SlideTransition(
                  position: new Tween<Offset>(
                    begin: const Offset(1.0, 0.0),
                    end: Offset.zero,
                  ).animate(
                      CurvedAnimation(parent: animation, curve: Curves.fastOutSlowIn)),
                  child: child);
            });
}

`flutter run` doesn't work for the Gallery app

run script:

# cleanup
	cd $(FLU_EX_FSPATH) && flutter clean

	flutter emulators
	flutter emulators --launch apple_ios_simulator
	#flutter emulators --launch Pixel_2_API_28
	
	#cd $(FLU_EX_FSPATH) && flutter run -d all
	cd $(FLU_EX_FSPATH) && flutter run 

Crash log:

Flutter crash report; please file at https://github.com/flutter/flutter/issues.

## command

flutter run

## exception

FileSystemException: FileSystemException: Cannot open file, path = '/Users/apple/workspace/go/src/github.com/google/flutter.widgets/gallery/ios/Runner.xcodeproj/project.pbxproj' (OS Error: No such file or directory, errno = 2)

```
#0      _File.open.<anonymous closure> (dart:io/file_impl.dart:364:9)
#1      _rootRunUnary (dart:async/zone.dart:1132:38)
#2      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#3      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
#4      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:639:45)
#5      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
#6      Future._completeWithValue (dart:async/future_impl.dart:483:5)
#7      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
#8      _rootRun (dart:async/zone.dart:1124:13)
#9      _CustomZone.run (dart:async/zone.dart:1021:19)
#10     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#11     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#12     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#13     _runPendingImmediateCallback (dart:isolate/runtime/libisolate_patch.dart:115:13)
#14     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:172:5)
```

## flutter doctor

```
�[32m[✓]�[39m Flutter (Channel dev, v1.2.0, on Mac OS X 10.14.3 18D42, locale en-DE)
    �[32m•�[39m Flutter version 1.2.0 at /Users/apple/workspace/flutter/flutter_macos_v0.2.8-beta/flutter
    �[32m•�[39m Framework revision 06b979c4d5 (7 days ago), 2019-01-25 14:27:35 -0500
    �[32m•�[39m Engine revision 36acd02c94
    �[32m•�[39m Dart version 2.1.1 (build 2.1.1-dev.3.2 f4afaee422)

�[33m[!]�[39m Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    �[32m•�[39m Android SDK at /Users/apple/Library/Android/sdk
    �[32m•�[39m Android NDK location not configured (optional; useful for native profiling support)
    �[32m•�[39m Platform android-28, build-tools 28.0.3
    �[32m•�[39m ANDROID_HOME = /Users/apple/Library/Android/sdk
    �[32m•�[39m Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    �[32m•�[39m Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    �[31m✗�[39m Android license status unknown.

�[32m[✓]�[39m iOS toolchain - develop for iOS devices (Xcode 10.1)
    �[32m•�[39m Xcode at /Applications/Xcode.app/Contents/Developer
    �[32m•�[39m Xcode 10.1, Build version 10B61
    �[32m•�[39m ios-deploy 1.9.4
    �[32m•�[39m CocoaPods version 1.5.3

�[32m[✓]�[39m Android Studio (version 3.3)
    �[32m•�[39m Android Studio at /Applications/Android Studio.app/Contents
    �[32m•�[39m Flutter plugin version 32.0.1
    �[32m•�[39m Dart plugin version 182.5124
    �[32m•�[39m Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

�[32m[✓]�[39m VS Code (version 1.30.2)
    �[32m•�[39m VS Code at /Applications/Visual Studio Code.app/Contents
    �[32m•�[39m Flutter extension version 2.22.3

�[32m[✓]�[39m Connected device (1 available)
    �[32m•�[39m iPhone 8 Plus • 356EB044-F3C1-45CA-9CEE-C5A5BCC933A0 • ios • iOS 12.1 (simulator)

�[33m!�[39m Doctor found issues in 1 category.
```

Using [ScrollablePositionedList] will report an error: 'minScrollExtent <= maxScrollExtent': is not true.

'package:flutter/src/widgets/scroll_position.dart': Failed assertion: line 457 pos 14: 'minScrollExtent <= maxScrollExtent': is not true.

My code

ScrollablePositionedList.builder(
        itemCount: dataList.length,
        itemBuilder: (context, i) {
          if (dataList.isEmpty) return Container();

          return Padding(
            padding: const EdgeInsets.only(bottom: 5.0),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text("${dataList[i].roleName}:"),
                dataList[i].imgUrl == null
                    ? Flexible(
                        child: Text(dataList[i].text),
                      )
                    : Flexible(
                        child: CachedNetworkImage(imageUrl: dataList[i].imgUrl),
                      )
              ],
            ),
          );
        },
        itemScrollController: itemScrollController,
      )

[linked_scroll_controller] How to add unique keys to scrollables when linking dynamically?

If you add controllers dynamically, the corresponding scrollables must be given unique keys to avoid the scroll offset going out of sync.

LinkedScrollControllerGroup controllers;
List scrollCTRLList;  

createAndLinkControllers(count) {
    for (var i = 0; i < count; i++) {
      var scrollControllerInstance = ScrollController();
      scrollControllerInstance = controllers.addAndGet();
      scrollCTRLList.add(scrollControllerInstance);
    }
  }

I have been building a custom data table widget for FlutterWeb use in particular. It can be scrolled in both directions. There is a single ListView.builder (for horizontal scrolling) and it holds dynamically added ListView.builders (for vertical scrolling as columns).

I've just figured out that the vertical scrollers go out of sync, unfortunately. It happens when some vertical ListView.builders are out of the visible area.

As I said, I can scroll horizontally. For example, 0-1-2-3-4 columns are visible. I scroll down to an arbitrary point such as somewhere near the 250th row. Then I scroll to right to see the 3-4-5-6 columns. The columns 5-6 were invisible until I scroll. At that moment they are out of sync.

If I then scroll up or down they become in sync immediately.

How can I solve that?

ScrollablePositionedList: Not scrolling to the position

I have a list where i have dynamic row sizes. When i use jump to method it works perfectly but it's not smooth . So i tried using scroll To but it scrolls to a certain distance and then stops. It doesn't animate to the specific index . Also can you add more animations to this package.

The last item should be this bottom of screen when jumping to the end of the list by using ScrollablePositionedList

C:\Users\ad>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.9.1+hotfix.4, on Microsoft Windows [Version 10.0.18362.356], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.5)
[√] Connected device (1 available)

jump last item code:
Widget get jumpControlButtons => Row( children: <Widget>[ const Text('jump to'), jumpButton(0), jumpButton(5), jumpButton(10), jumpButton(100), //jumpButton(1000), jumpButton(numberOfItems-1), ], );
it should be:
QQ图片20191011095720
not this:
QQ图片20191011095716

Question: Try to recover the state of ScrollablePositionedList

I want to save the offset for a ScrollablePositionedList and recover it if the state has disposed and init again.
I noticed there are two parameters to do the jumping, one is the 'index' and the other one is 'alignment'.
And I found there are 'itemLeadingEdge' and 'itemTrailingEdge' in the ItemPosition from the ItemPositionsListener, which are likely the same thing as alignment.
But I'm not sure which one to use. I did some test about it, which makes me more confused.

The first question is about the index. I try to jump to index 0, but the index from the ItemPosition is 6. I don't know if it's an inner variable or not. Can I save it and use it when recovering the List? Like jumpTo(index:6) to recover the actual index 0?

The second question is about alignment. It is limited from 0.0 to 1.0. I noticed the itemLeadingEdge could be negative so it cannot be used directly. itemTrailingEdge is always positive but it can be more than 1.0. I also noticed that itemTrailingEdge minus itemLeadingEdge is always the same - maybe it represents as the item height?

I tried to use above parameters to do the recover. It seems that I can go to the same offset, but the index is 1 right before the actual index.
I'm currently digging the code deeper to find out what happened, but it would be more helpful to know the idea of these parameters.

Thank you!

@tarobins

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.