Giter Site home page Giter Site logo

jpnurmi / cupertino_list_tile Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 10.0 5.28 MB

Cupertino version of the Material ListTile in Flutter

License: BSD 3-Clause "New" or "Revised" License

Kotlin 0.06% Swift 0.19% Objective-C 0.02% Dart 94.33% CMake 3.37% C++ 1.84% C 0.19%
cupertino dart flutter flutter-widget listtile

cupertino_list_tile's Introduction

ArkUI Bash C C++ Dart Flutter Husky JavaScript Linux OpenHarmony Python QML Qt Raspberry Pi Rust Slint TypeScript Ubuntu Yocto

cupertino_list_tile's People

Contributors

aaqibismail avatar jpnurmi avatar rledisez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cupertino_list_tile's Issues

Updating to Flutter 2.8 falls with error

Error: A value of type 'bool?' can't be returned from a function with return type 'bool' because 'bool?' is nullable and 'bool' isn't.
    return dense ?? tileTheme.dense;

File: cupertino_list_tile-0.2.0/lib/src/list_tile.dart:139:18

Hero Animation Support?

I have a use case where I need Hero animation on the Cupertino List Tile, everything seems to work fine except the divider which isn't smooth and jumps from initial position to the final position.

Do you know any workaround for this? or is this something you would be willing to support in later releases?

Thank you!


Here is a quick example:

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.orange,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.black,
        appBar: AppBar(
          title: Text('Cupertino List Tile Hero Test'),
        ),
        body: Container(
          height: double.infinity,
          width: double.infinity,
          child: Center(
            child: Hero(
              tag: Key('test'),
              child: CupertinoListTile(
                leading: Icon(
                  Icons.settings,
                  color: Colors.white,
                  size: 18,
                ),
                title: Text(
                  'Settings',
                  style: TextStyle(color: Colors.white),
                ),
                subtitle: Text(
                  'Change functionality here',
                  style: TextStyle(color: Colors.white),
                ),
                onTap: () {
                  Navigator.push(context,
                      CupertinoPageRoute(builder: (_) => MyHomePage2()));
                },
              ),
            ),
          ),
        ));
  }
}

class MyHomePage2 extends StatefulWidget {
  @override
  _MyHomePage2State createState() => _MyHomePage2State();
}

class _MyHomePage2State extends State<MyHomePage2> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.black,
        appBar: AppBar(
          title: Text('Cupertino List Tile Hero Test'),
        ),
        body: Container(
          child: Hero(
            tag: Key('test'),
            child: CupertinoListTile(
              leading: Icon(
                Icons.settings,
                color: Colors.white,
                size: 18,
              ),
              title: Text(
                'Settings',
                style: TextStyle(color: Colors.white),
              ),
              subtitle: Text(
                'Change functionality here',
                style: TextStyle(color: Colors.white),
              ),
              onTap: () {
                Navigator.pop(context);
              },
            ),
          ),
        ));
  }
}

Wrapping CupertinoListTile with SizeTransition removes the divider

I have a use case to hide the CupertinoListTile and when wrapping the CupertinoListTile with SizeTransition, the divider is no longer visible. The workaround is to wrap the tile with a Container and provide explicit height but this leads to gaps between the tiles which unfortunately degrades the aesthetics of the CupertinoListTile.

Example

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CupertinoApp(
      localizationsDelegates: <LocalizationsDelegate<dynamic>>[
        DefaultMaterialLocalizations.delegate,
        DefaultWidgetsLocalizations.delegate,
        DefaultCupertinoLocalizations.delegate,
      ],
      title: 'Cupertino List Divider Test',
      theme: CupertinoThemeData(brightness: Brightness.dark),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
  @override
  Widget build(BuildContext context) {
    var controller = AnimationController(
      duration: Duration.zero,
      vsync: this,
    )..forward();

    var animation = CurvedAnimation(
      parent: controller,
      curve: Curves.linear,
    );

    return CupertinoPageScaffold(
      navigationBar: CupertinoNavigationBar(
        middle: Text('Cupertino List Divider Test'),
      ),
      child: ListView.builder(
        itemCount: 10,
        itemBuilder: (context, index) {
          return SizeTransition(
            sizeFactor: animation,
            child: CupertinoListTile(
              title: Center(child: Text(index.toString())),
            ),
          );
        },
      ),
    );
  }
}

Flutter Doctor

[✓] Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B29 darwin-x64, locale en-CA)
• Flutter version 1.22.4 at /Users/sid/Work/Software/Flutter/flutter
• Framework revision 1aafb3a8b9 (4 days ago), 2020-11-13 09:59:28 -0800
• Engine revision 2c956a31c0
• Dart version 2.10.4

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/sid/Work/Software/Flutter/android
• Platform android-30, build-tools 29.0.2
• ANDROID_HOME = /Users/sid/Work/Software/Flutter/android
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.1, Build version 12A7403
• CocoaPods version 1.10.0

[✓] VS Code (version 1.51.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.16.0

Screenshot

Simulator Screen Shot - iPhone 12 Pro - 2020-11-17 at 16 28 23

Support Flutter v1.20.1

Thank you for this package. There are some breaking changes when upgrading Flutter to v1.20.1, so creating an issue.

../../flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_list_tile-0.1.0/lib/src/list_tile_background.dart:168:17: Error: Type 'ActionFactory' not found.
  Map<LocalKey, ActionFactory> _actionMap;                              
                ^^^^^^^^^^^^^                                           
../../flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_list_tile-0.1.0/lib/src/list_tile_background.dart:168:17: Error: 'ActionFactory' isn't a type.
  Map<LocalKey, ActionFactory> _actionMap;                              
                ^^^^^^^^^^^^^                                           
../../flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_list_tile-0.1.0/lib/src/list_tile_background.dart:177:22: Error: Getter not found: 'key'.
      ActivateAction.key,                                               
                     ^^^                                                
../../flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_list_tile-0.1.0/lib/src/list_tile_background.dart:176:26: Error: Too many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.                            
    return CallbackAction(                                              
                         ^                                              
../../flutter/packages/flutter/lib/src/widgets/actions.dart:348:3: Context: Found this candidate, but the arguments don't match.
  CallbackAction({@required this.onInvoke}) : assert(onInvoke != null); 
  ^^^^^^^^^^^^^^                                                        
../../flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_list_tile-0.1.0/lib/src/list_tile_background.dart:185:29: Error: 'ActionFactory' isn't a type.
    _actionMap = <LocalKey, ActionFactory>{                             
                            ^^^^^^^^^^^^^                               
../../flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_list_tile-0.1.0/lib/src/list_tile_background.dart:186:22: Error: Getter not found: 'key'.
      ActivateAction.key: _createAction,                                
                     ^^^                                                
../../flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_list_tile-0.1.0/lib/src/list_tile_background.dart:344:16: Error: The argument type 'Map<LocalKey, invalid-type>' can't be assigned to the parameter type 'Map<Type, Action<Intent>>'.
 - 'Map' is from 'dart:core'.                                           
 - 'LocalKey' is from 'package:flutter/src/foundation/key.dart' ('../../flutter/packages/flutter/lib/src/foundation/key.dart').
 - 'Type' is from 'dart:core'.                                          
 - 'Action' is from 'package:flutter/src/widgets/actions.dart' ('../../flutter/packages/flutter/lib/src/widgets/actions.dart').
 - 'Intent' is from 'package:flutter/src/widgets/actions.dart' ('../../flutter/packages/flutter/lib/src/widgets/actions.dart').
      actions: _actionMap,                                              
               ^            

Content padding moves selection out of bounds

Hello JP,

I think I ran into another issue. When adding content padding, the selection is going out of bounds, i.e, the the separator isn't at the edge of the selection. Not sure if this intended.

EDIT:

Happens only when adding bottom padding to the content padding.


Example

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

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.orange,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        title: Text('Cupertino List Tile Padding Test'),
      ),
      body: Container(
        height: double.infinity,
        width: double.infinity,
        child: Center(
          child: CupertinoListTile(
            contentPadding: EdgeInsets.all(20),
            leading: Icon(
              Icons.settings,
              size: 18,
            ),
            title: Text(
              'Settings',
            ),
            subtitle: Text(
              'Change functionality here',
            ),
            onTap: () {
            },
          ),
        ),
      ),
    );
  }
}

Screen Shot 2020-08-23 at 6 14 29 PM

Error: No named parameter with the name 'nullOk'.

The package example project does not work either. I get the following error.

../pub-cache/hosted/pub.dartlang.org/cupertino_list_tile-0.1.4/lib/src/list_tile_background.dart:266:32: Error: No named parameter with the name 'nullOk'. MediaQuery.of(context, nullOk: true)?.navigationMode ?? ^^^^^^ ../src/flutter/packages/flutter/lib/src/widgets/media_query.dart:814:25: Context: Found this candidate, but the arguments don't match. static MediaQueryData of(BuildContext context) { ^^ ../src/flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_list_tile-0.1.4/lib/src/list_tile_background.dart:357:32: Error: No named parameter with the name 'nullOk'. MediaQuery.of(context, nullOk: true)?.navigationMode ?? ^^^^^^ ../src/flutter/packages/flutter/lib/src/widgets/media_query.dart:814:25: Context: Found this candidate, but the arguments don't match. static MediaQueryData of(BuildContext context) {

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.