我是新手,如何使用插件 URL 启动器在 flutter_deep_linking-master / 多级项目中扩展 StatelessWidget 的变量值
如何获取${person.pdf}的变量值并将其插入String link = variable ; 并将这个新变量放入onClicked: () => Utils.openLink(url: link ),
class PersonPage extends StatelessWidget {
final Family family;
final Person person;
const PersonPage({required this.family, required this.person, Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: Text(person.name)), body:
Text('\n\n' ' Le manuel recherché du ${family.name} ${person.name} est ici : \n\n'
' => **${person.pdf}** \n\n'));
}
//get the variable value of ${person.pdf} and insert it in : String link = => variable_value;
String link = variable_value;
class PersonPage extends StatelessWidget {
final Family family;
final Person person;
const PersonPage({required this.family, required this.person, Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: Text(person.name)), body:
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
buildButton(
text: 'Lien fichier pdf',
//put this new variable in : (url: link),
onClicked: () => Utils.openLink(url: =>link),
),
],
),
),
);
Widget buildButton({
required String text,
required VoidCallback onClicked,
}) =>
Container(
padding: const EdgeInsets.symmetric(vertical: 12),
child: ElevatedButton(
onPressed: onClicked,
child: Text(
text,
style: TextStyle(fontSize: 24),
),
),
);
}
class Four04Page extends StatelessWidget {
final String message;
const Four04Page({required this.message, Key? key}) : super(key: key);
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Page Not Found')),
body: Center(child: Text(message)),
);
}
'谢谢'