我正在使用一个名为 Icapp_license for flutter会创建一个文件,其中包含您使用的所有插件的许可证,因此输出为该文件,我想转换为listview
已生成 在此处link
提交答案 0 :(得分:0)
您可以在下面复制粘贴运行完整代码
执行命令flutter packages pub run icapps_license
后
license.dart
将在目录util
中自动生成
您可以import './util/license.dart';
代码段
ListView.builder(
itemCount: LicenseUtil.getLicenses().length,
itemBuilder: (BuildContext context, int index) {
final item = LicenseUtil.getLicenses()[index];
工作演示
完整代码
import 'package:flutter/material.dart';
import './util/license.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: ListView.builder(
itemCount: LicenseUtil.getLicenses().length,
itemBuilder: (BuildContext context, int index) {
final item = LicenseUtil.getLicenses()[index];
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
color: Colors.grey.withOpacity(0.5),
child: Column(
children: [
Text(item.name),
Text(item.version),
Text(item.url),
Container(height: 8),
Text(item.license),
],
),
),
);
},
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}