我需要从opJson获取id
,并在Widget中显示
对象是:
flutter: "{id: 2, ......}
@override
void function() async {
final prefs = await SharedPreferences.getInstance();
var usu = prefs.getString('user') ?? 0;
String opJson = json.jsonEncode(usu);
print('+++++++');
print(opJson);
}
Widget _buildDrawer(BuildContext context) {
function();
return Drawer(
child: ListView(
dragStartBehavior: DragStartBehavior.down,
children: <Widget>[
Image.asset('assets/l.png'),
const DrawerHeader(child:
Center(child:
Text('A',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w700,
fontSize: 28.0)))),
ListTile(
leading: Icon(Icons.account_balance),
title: Text('User:'),
onTap: () {
Navigator.popAndPushNamed(context, '/dashboard');
},
enabled: true,
),