flutter 使用SfDateRangePicker抖动时出错

wvt8vs2t  于 2023-02-09  发布在  Flutter
关注(0)|答案(2)|浏览(128)

我一添加import语句就发生此错误:import 'package:syncfusion_flutter_datepicker/datepicker.dart';重新创建此错误不需要剩余代码
代码:

import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_datepicker/datepicker.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Container(
          child: SfDateRangePicker(),
        ));
  }
}

错误:

../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/syncfusion_flutter_datepicker-20.4.48/lib/src/date_picker/date_picker.dart:7596:37: Error: The argument type 'ScrollableState?' can't be assigned to the parameter type 'ScrollableState' because 'ScrollableState?' is nullable and 'ScrollableState' isn't.
 - 'ScrollableState' is from 'package:flutter/src/widgets/scrollable.dart' ('../../snap/flutter/common/flutter/packages/flutter/lib/src/widgets/scrollable.dart').
        scrollableState: Scrollable.of(context),
6ioyuze2

6ioyuze21#

此错误在此问题中提及。
https://github.com/syncfusion/flutter-examples/issues/730
您应该修复pubspec.yaml中syncfusion_flutter_datepicker的版本

Don't use version:
    syncfusion_flutter_datepicker: ^20.4.48

    Use like this:
    syncfusion_flutter_datepicker: "20.4.44"

https://github.com/syncfusion/flutter-examples/issues/730#issuecomment-1413788831

hgb9j2n6

hgb9j2n62#

使用MaterialApp Package 您的支架

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      body: SfDateRangePicker(),
    ));
  }
}

相关问题